Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 14164:cb98fed52495
discovery: add new set-based discovery
Adds a new discovery method based on repeatedly sampling the still
undecided subset of the local node graph to determine the set of nodes
common to both the client and the server.
For small differences between client and server, it uses about the same
or slightly fewer roundtrips than the old tree-based discovery. For
larger differences, it typically reduces the number of roundtrips
drastically (from 150 to 4, for instance).
The old discovery code now lives in treediscovery.py, the new code is
in setdiscovery.py.
Still missing is a hook for extensions to contribute nodes to the
initial sample. For instance, Augie's remotebranches could contribute
the last known state of the server's heads.
Credits for the actual sampler and computing common heads instead of
bases go to Benoit Boissinot.
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Mon, 02 May 2011 19:21:30 +0200 |
parents | 3c3c53d8343a |
children | 0013d3eeb826 |
comparison
equal
deleted
inserted
replaced
14163:38184a72d793 | 14164:cb98fed52495 |
---|---|
615 assert orderedout | 615 assert orderedout |
616 assert roots | 616 assert roots |
617 assert heads | 617 assert heads |
618 return (orderedout, roots, heads) | 618 return (orderedout, roots, heads) |
619 | 619 |
620 def headrevs(self): | |
621 count = len(self) | |
622 if not count: | |
623 return [nullrev] | |
624 ishead = [1] * (count + 1) | |
625 index = self.index | |
626 for r in xrange(count): | |
627 e = index[r] | |
628 ishead[e[5]] = ishead[e[6]] = 0 | |
629 return [r for r in xrange(count) if ishead[r]] | |
630 | |
620 def heads(self, start=None, stop=None): | 631 def heads(self, start=None, stop=None): |
621 """return the list of all nodes that have no children | 632 """return the list of all nodes that have no children |
622 | 633 |
623 if start is specified, only heads that are descendants of | 634 if start is specified, only heads that are descendants of |
624 start will be returned | 635 start will be returned |
625 if stop is specified, it will consider all the revs from stop | 636 if stop is specified, it will consider all the revs from stop |
626 as if they had no children | 637 as if they had no children |
627 """ | 638 """ |
628 if start is None and stop is None: | 639 if start is None and stop is None: |
629 count = len(self) | 640 if not len(self): |
630 if not count: | |
631 return [nullid] | 641 return [nullid] |
632 ishead = [1] * (count + 1) | 642 return [self.node(r) for r in self.headrevs()] |
633 index = self.index | |
634 for r in xrange(count): | |
635 e = index[r] | |
636 ishead[e[5]] = ishead[e[6]] = 0 | |
637 return [self.node(r) for r in xrange(count) if ishead[r]] | |
638 | 643 |
639 if start is None: | 644 if start is None: |
640 start = nullid | 645 start = nullid |
641 if stop is None: | 646 if stop is None: |
642 stop = [] | 647 stop = [] |