Mercurial > hg > mercurial-crew
diff mercurial/revlog.py @ 7233:9f0e52e1df77
fix pull racing with push/commit (issue1320)
changegroup() has a problem when nodes which does not descend from a node
in <bases> are added to remote after the discovery phase.
If that happens, changegroup() won't send the correct set of nodes, ie.
some nodes will be missing.
To correct it we have to find the set of nodes that both remote and self
have (called <common>), and send all the nodes not in <common>.
This fix has some overhead, in the worst case it will re-send a whole branch.
A proper fix to avoid this overhead might be to change the protocol so that
the <common> nodes are sent (instead of the <bases> of the missing nodes).
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Tue, 21 Oct 2008 17:00:35 +0200 (2008-10-21) |
parents | 528b7fc1216c |
children | 9fe97eea5510 |
line wrap: on
line diff
--- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -590,6 +590,46 @@ yield i break + def findmissing(self, common=None, heads=None): + ''' + returns the topologically sorted list of nodes from the set: + missing = (ancestors(heads) \ ancestors(common)) + + where ancestors() is the set of ancestors from heads, heads included + + if heads is None, the heads of the revlog are used + if common is None, nullid is assumed to be a common node + ''' + if common is None: + common = [nullid] + if heads is None: + heads = self.heads() + + common = [self.rev(n) for n in common] + heads = [self.rev(n) for n in heads] + + # we want the ancestors, but inclusive + has = dict.fromkeys(self.ancestors(*common)) + has[nullrev] = None + for r in common: + has[r] = None + + # take all ancestors from heads that aren't in has + missing = {} + visit = [r for r in heads if r not in has] + while visit: + r = visit.pop(0) + if r in missing: + continue + else: + missing[r] = None + for p in self.parentrevs(r): + if p not in has: + visit.append(p) + missing = missing.keys() + missing.sort() + return [self.node(r) for r in missing] + def nodesbetween(self, roots=None, heads=None): """Return a tuple containing three elements. Elements 1 and 2 contain a final list bases and heads after all the unreachable ones have been