~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_known_graph_py.py

  • Committer: John Arbash Meinel
  • Date: 2009-08-17 20:41:26 UTC
  • mto: This revision was merged to the branch mainline in revision 4629.
  • Revision ID: john@arbash-meinel.com-20090817204126-fokcicx22mwsgud0
Change the KnownGraph.merge_sort api.

Instead of being a tuple api, it is now an Object api. TIMEIT testing at least
seems to say that _MergeSortNode.key is no slower than using a tuple.
Allocating the nodes is also not much slower (especially since we already needed
them.)

In the end it makes for an api which, IMO, is much easier to use, so
since performance isn't impacted, it is worth switching.


Also, determined that we needed to implement the new get_known_graph... on
the weave code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
            self.parent_keys, self.child_keys)
42
42
 
43
43
 
 
44
class _MergeSortNode(object):
 
45
    """Information about a specific node in the merge graph."""
 
46
 
 
47
    __slots__ = ('key', 'merge_depth', 'revno', 'end_of_merge')
 
48
 
 
49
    def __init__(self, key, merge_depth, revno, end_of_merge):
 
50
        self.key = key
 
51
        self.merge_depth = merge_depth
 
52
        self.revno = revno
 
53
        self.end_of_merge = end_of_merge
 
54
 
 
55
 
44
56
class KnownGraph(object):
45
57
    """This is a class which assumes we already know the full graph."""
46
58
 
215
227
        # We intentionally always generate revnos and never force the
216
228
        # mainline_revisions
217
229
        # Strip the sequence_number that merge_sort generates
218
 
        return [info[1:] for info in tsort.merge_sort(as_parent_map, tip_key,
219
 
                                mainline_revisions=None,
220
 
                                generate_revno=True)]
 
230
        return [_MergeSortNode(key, merge_depth, revno, end_of_merge)
 
231
                for _, key, merge_depth, revno, end_of_merge
 
232
                 in tsort.merge_sort(as_parent_map, tip_key,
 
233
                                     mainline_revisions=None,
 
234
                                     generate_revno=True)]