1.1 --- a/micropython/data.py Tue Jun 05 01:54:54 2012 +0200
1.2 +++ b/micropython/data.py Sat Jun 09 02:01:56 2012 +0200
1.3 @@ -390,7 +390,6 @@
1.4 # usage with the usage recorded directly on the user.
1.5
1.6 self.get_usage_from_contributors(user)
1.7 - self.set_contributors(user)
1.8
1.9 # Record the defining user on each contributor.
1.10
1.11 @@ -485,21 +484,6 @@
1.12 attrtypes[name] = objtypes
1.13 return attrtypes
1.14
1.15 - def set_contributors(self, node):
1.16 - if not hasattr(node, "_attrcontributors"):
1.17 - node._attrcontributors = None
1.18 - all_contributors = set()
1.19 -
1.20 - for contributor in node._attrbranches:
1.21 - all_contributors.add(contributor)
1.22 - self.set_contributors(contributor)
1.23 -
1.24 - contributors = contributor._attrcontributors
1.25 - if contributors is not None:
1.26 - all_contributors.update(contributors)
1.27 -
1.28 - node._attrcontributors = all_contributors
1.29 -
1.30 def get_usage_from_contributors(self, node):
1.31
1.32 """
1.33 @@ -513,6 +497,7 @@
1.34
1.35 if not hasattr(node, "_attrcombined"):
1.36 node._attrcombined = None
1.37 + node._attrcontributors = None
1.38
1.39 for contributor in node._attrbranches:
1.40
1.41 @@ -522,23 +507,33 @@
1.42
1.43 # Collect unfinished contributors and affected nodes.
1.44
1.45 - if node._attrcombined is None:
1.46 + # Where the contributor is already set to None, a loop has
1.47 + # occurred and this node will need to have its usage
1.48 + # recalculated later for the unfinished contributor.
1.49 +
1.50 + if contributor._attrcombined is None:
1.51 if not unfinished.has_key(contributor):
1.52 unfinished[contributor] = []
1.53 unfinished[contributor].append(node)
1.54 continue
1.55
1.56 + # Where the contributor provides usage details, it may also
1.57 + # communicate unfinished contributor information. As a
1.58 + # consequence, this node is also affected.
1.59 +
1.60 for unfinished_contributor, nodes in unfinished_contributors.items():
1.61 if not unfinished.has_key(unfinished_contributor):
1.62 unfinished[unfinished_contributor] = nodes
1.63 else:
1.64 unfinished[unfinished_contributor] += nodes
1.65
1.66 - unfinished[contributor].append(node)
1.67 + if node not in unfinished[unfinished_contributor]:
1.68 + unfinished[unfinished_contributor].append(node)
1.69
1.70 # Set the current state of the usage on this node.
1.71
1.72 - node._attrcombined = self.get_usage_from_contributors_for_node(node)
1.73 + node._attrcombined, node._attrcontributors = \
1.74 + self.get_usage_from_contributors_for_node(node)
1.75
1.76 # Complete unfinished contributors relying on this node.
1.77
1.78 @@ -547,7 +542,10 @@
1.79 for contributor in unfinished[node]:
1.80 if not contributor in processed:
1.81 processed.add(contributor)
1.82 - contributor._attrcombined = self.get_usage_from_contributors_for_node(contributor)
1.83 +
1.84 + contributor._attrcombined, contributor._attrcontributors = \
1.85 + self.get_usage_from_contributors_for_node(contributor)
1.86 +
1.87 del unfinished[node]
1.88
1.89 return unfinished
1.90 @@ -558,12 +556,18 @@
1.91
1.92 contributor_usage = {}
1.93 all_contributions = []
1.94 + all_contributors = set()
1.95
1.96 for contributor in node._attrbranches:
1.97 usage = contributor._attrcombined
1.98 if usage is not None:
1.99 all_contributions.append(usage)
1.100
1.101 + all_contributors.add(contributor)
1.102 + contributors = contributor._attrcontributors
1.103 + if contributors is not None:
1.104 + all_contributors.update(contributors)
1.105 +
1.106 # Get contributed usage for each contributor.
1.107 # This gathers usage for each name such as {(a, b), (c, d)} and
1.108 # {(a, b), (e, f)} into a single set {(a, b), (c, d), (e, f)}.
1.109 @@ -578,7 +582,7 @@
1.110 # Thus, usage of {(f, g)} combined with {(a, b), (c, d)} would give
1.111 # {(f, g, a, b), (f, g, c, d)}.
1.112
1.113 - return combine_mapping_dicts(deepen_mapping_dict(node._attrnames), contributor_usage)
1.114 + return combine_mapping_dicts(deepen_mapping_dict(node._attrnames), contributor_usage), all_contributors
1.115
1.116 def use_attribute(self, name, attrname, value=None):
1.117