170
class Grapher(object):
171
def __init__(self, branch, other_branch):
172
object.__init__(self)
174
self.other_branch = other_branch
175
greedy_fetch(branch, other_branch)
176
revision_a = self.branch.last_patch()
177
revision_b = self.other_branch.last_patch()
179
self.root, self.ancestors, self.descendants, self.common = \
180
combined_graph(revision_a, revision_b, self.branch)
181
except bzrlib.errors.NoCommonRoot:
182
raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
183
self.distances = node_distances(self.descendants, self.ancestors,
185
self.base = select_farthest(self.distances, self.common)
186
self.n_history = branch.revision_history()
187
self.m_history = other_branch.revision_history()
171
def graph_merge_pick(branch, other_branch, collapse=False):
172
greedy_fetch(branch, other_branch)
173
revision_a = branch.last_patch()
174
revision_b = other_branch.last_patch()
176
root, ancestors, descendants, common = \
177
combined_graph(revision_a, revision_b, branch)
178
except bzrlib.errors.NoCommonRoot:
179
raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
180
distances = node_distances(descendants, ancestors, root)
181
base = select_farthest(distances, common)
182
n_history = branch.revision_history()
183
m_history = other_branch.revision_history()
185
def dot_node(node, num):
189
def dot_node(self, node, num):
187
n_rev = n_history.index(node) + 1
191
n_rev = self.n_history.index(node) + 1
188
192
except ValueError:
191
m_rev = m_history.index(node) + 1
195
m_rev = self.m_history.index(node) + 1
192
196
except ValueError:
194
198
if (n_rev, m_rev) == (None, None):
218
222
assert m_rev is not None
219
223
cluster = "other_history"
220
224
color = "#ff0000"
225
if node == self.base:
222
226
color = "#33ff99"
225
committer = get_committer(node, branch)
229
committer = get_committer(node, self.branch)
226
230
if committer is not None:
227
231
label.append(committer)
229
if node in distances:
230
label.append('d%d' % distances[node])
233
if node in self.distances:
234
label.append('d%d' % self.distances[node])
232
236
d_node = Node("n%d" % num, color=color, label="\\n".join(label),
233
237
rev_id=node, cluster=cluster)
234
if node not in ancestors:
238
if node not in self.ancestors:
235
239
d_node.node_style.append('dotted')
242
visible_ancestors = compact_ancestors(descendants, ancestors, (base,))
244
visible_ancestors = ancestors
245
for node, parents in visible_ancestors.iteritems():
246
if node not in dot_nodes:
247
dot_nodes[node] = dot_node(node, num)
249
if visible_ancestors is ancestors:
250
parent_iter = ((f, 0) for f in parents)
243
def get_relations(self, collapse=False):
248
visible_ancestors = compact_ancestors(self.descendants,
249
self.ancestors, (self.base,))
252
parent_iter = (f for f in parents.iteritems())
253
for parent, skipped in parent_iter:
254
if parent not in dot_nodes:
255
dot_nodes[parent] = dot_node(parent, num)
251
visible_ancestors = self.ancestors
252
for node, parents in visible_ancestors.iteritems():
253
if node not in dot_nodes:
254
dot_nodes[node] = self.dot_node(node, num)
257
edge = Edge(dot_nodes[parent], dot_nodes[node])
259
edge.label = "%d" % skipped
260
node_relations.append(edge)
261
return node_relations
256
if visible_ancestors is self.ancestors:
257
parent_iter = ((f, 0) for f in parents)
259
parent_iter = (f for f in parents.iteritems())
260
for parent, skipped in parent_iter:
261
if parent not in dot_nodes:
262
dot_nodes[parent] = self.dot_node(parent, num)
264
edge = Edge(dot_nodes[parent], dot_nodes[node])
266
edge.label = "%d" % skipped
267
node_relations.append(edge)
268
return node_relations
264
271
def write_ancestry_file(branch, filename, collapse=True, antialias=True,