56
56
for me, my_parents in ancestors.iteritems():
59
new_ancestors[me] = {}
59
new_ancestors[me] = {}
60
60
for parent in my_parents:
63
63
while can_skip(new_parent, descendants, ancestors):
64
64
if new_parent in exceptions:
69
69
new_parent = list(ancestors[new_parent])[0]
71
71
new_ancestors[me][new_parent] = distance
74
74
def get_rev_info(rev_id, source):
75
75
"""Return the committer, message, and date of a revision."""
128
128
self.n_history = branch.revision_history()
129
self.distances = node_distances(self.descendants, self.ancestors,
129
self.distances = node_distances(self.descendants, self.ancestors,
131
131
if other_branch is not None:
132
132
self.base = select_farthest(self.distances, self.common)
133
self.m_history = other_branch.revision_history()
133
self.m_history = other_branch.revision_history()
134
new_graph = getattr(branch.repository, 'get_graph', lambda: None)()
135
if new_graph is None:
139
self.new_base = new_graph.find_unique_lca(revision_a,
141
self.lcas = new_graph.find_lca(revision_a, revision_b)
136
146
self.m_history = []
138
148
def dot_node(self, node, num):
171
181
assert m_rev is not None
172
182
cluster = "other_history"
173
183
color = "#ff0000"
184
if node in self.lcas:
174
186
if node == self.base:
188
if node == self.new_base:
190
if node == self.new_base:
178
committer, message, nick, date = get_rev_info(node,
194
committer, message, nick, date = get_rev_info(node,
179
195
self.branch.repository)
180
196
if committer is not None:
181
197
label.append(committer)
195
d_node = Node("n%d" % num, color=color, label="\\n".join(label),
211
d_node = Node("n%d" % num, color=color, label="\\n".join(label),
196
212
rev_id=node, cluster=cluster, message=message,
198
214
d_node.rank = rank
201
217
d_node.node_style.append('dotted')
205
221
def get_relations(self, collapse=False, max_distance=None):
207
223
node_relations = []
210
visible_ancestors = compact_ancestors(self.descendants,
211
self.ancestors, (self.base,))
226
exceptions = self.lcas.union([self.base, self.new_base])
227
visible_ancestors = compact_ancestors(self.descendants,
213
visible_ancestors = self.ancestors
231
visible_ancestors = {}
232
for revision, parents in self.ancestors.iteritems():
233
visible_ancestors[revision] = dict((p, 0) for p in parents)
214
234
if max_distance is not None:
215
235
min_distance = max(self.distances.values()) - max_distance
216
visible_ancestors = dict((n, p) for n, p in visible_ancestors.iteritems() if
217
self.distances[n] >= min_distance)
236
visible_ancestors = dict((n, p) for n, p in
237
visible_ancestors.iteritems() if
238
self.distances[n] >= min_distance)
218
239
for node, parents in visible_ancestors.iteritems():
219
240
if node not in dot_nodes:
220
241
dot_nodes[node] = self.dot_node(node, num)
222
if visible_ancestors is self.ancestors:
223
parent_iter = ((f, 0) for f in parents)
225
parent_iter = (f for f in parents.iteritems())
226
for parent, skipped in parent_iter:
243
for parent, skipped in parents.iteritems():
227
244
if parent not in dot_nodes:
228
245
dot_nodes[parent] = self.dot_node(parent, num)