~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to graph.py

  • Committer: Aaron Bentley
  • Date: 2006-12-22 18:31:21 UTC
  • mto: (481.1.1 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 485.
  • Revision ID: abentley@panoramicfeedback.com-20061222183121-fvvrasz8s2w6nbis
graph-ancestry can restrict the number of nodes shown by distance

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
            d_node.node_style.append('dotted')
202
202
 
203
203
        return d_node
204
 
        
205
 
    def get_relations(self, collapse=False):
 
204
       
 
205
    def get_relations(self, collapse=False, max_distance=None):
206
206
        dot_nodes = {}
207
207
        node_relations = []
208
208
        num = 0
211
211
                                                  self.ancestors, (self.base,))
212
212
        else:
213
213
            visible_ancestors = self.ancestors
 
214
        if max_distance is not None:
 
215
            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)
214
218
        for node, parents in visible_ancestors.iteritems():
215
219
            if node not in dot_nodes:
216
220
                dot_nodes[node] = self.dot_node(node, num)
231
235
 
232
236
 
233
237
def write_ancestry_file(branch, filename, collapse=True, antialias=True,
234
 
                        merge_branch=None, ranking="forced"):
 
238
                        merge_branch=None, ranking="forced", max_distance=None):
235
239
    b = Branch.open_containing(branch)[0]
236
240
    if merge_branch is not None:
237
241
        m = Branch.open_containing(merge_branch)[0]
243
247
            m.lock_read()
244
248
        try:
245
249
            grapher = Grapher(b, m)
246
 
            relations = grapher.get_relations(collapse)
 
250
            relations = grapher.get_relations(collapse, max_distance)
247
251
        finally:
248
252
            if m is not None:
249
253
                m.unlock()