##// END OF EJS Templates
fix pull racing with push/commit (issue1320)...
Benoit Boissinot -
r7233:9f0e52e1 default
parent child Browse files
Show More
@@ -1578,6 +1578,20 b' class localrepository(repo.repository):'
1578 1578 the linkrev.
1579 1579 """
1580 1580
1581 if extranodes is None:
1582 # can we go through the fast path ?
1583 heads.sort()
1584 allheads = self.heads()
1585 allheads.sort()
1586 if heads == allheads:
1587 common = []
1588 # parents of bases are known from both sides
1589 for n in bases:
1590 for p in self.changelog.parents(n):
1591 if p != nullid:
1592 common.append(p)
1593 return self._changegroup(common, source)
1594
1581 1595 self.hook('preoutgoing', throw=True, source=source)
1582 1596
1583 1597 # Set up some initial variables
@@ -1854,16 +1868,22 b' class localrepository(repo.repository):'
1854 1868 return util.chunkbuffer(gengroup())
1855 1869
1856 1870 def changegroup(self, basenodes, source):
1871 # to avoid a race we use changegroupsubset() (issue1320)
1872 return self.changegroupsubset(basenodes, self.heads(), source)
1873
1874 def _changegroup(self, common, source):
1857 1875 """Generate a changegroup of all nodes that we have that a recipient
1858 1876 doesn't.
1859 1877
1860 1878 This is much easier than the previous function as we can assume that
1861 the recipient has any changenode we aren't sending them."""
1879 the recipient has any changenode we aren't sending them.
1880
1881 common is the set of common nodes between remote and self"""
1862 1882
1863 1883 self.hook('preoutgoing', throw=True, source=source)
1864 1884
1865 1885 cl = self.changelog
1866 nodes = cl.nodesbetween(basenodes, None)[0]
1886 nodes = cl.findmissing(common)
1867 1887 revset = dict.fromkeys([cl.rev(n) for n in nodes])
1868 1888 self.changegroupinfo(nodes, source)
1869 1889
@@ -590,6 +590,46 b' class revlog(object):'
590 590 yield i
591 591 break
592 592
593 def findmissing(self, common=None, heads=None):
594 '''
595 returns the topologically sorted list of nodes from the set:
596 missing = (ancestors(heads) \ ancestors(common))
597
598 where ancestors() is the set of ancestors from heads, heads included
599
600 if heads is None, the heads of the revlog are used
601 if common is None, nullid is assumed to be a common node
602 '''
603 if common is None:
604 common = [nullid]
605 if heads is None:
606 heads = self.heads()
607
608 common = [self.rev(n) for n in common]
609 heads = [self.rev(n) for n in heads]
610
611 # we want the ancestors, but inclusive
612 has = dict.fromkeys(self.ancestors(*common))
613 has[nullrev] = None
614 for r in common:
615 has[r] = None
616
617 # take all ancestors from heads that aren't in has
618 missing = {}
619 visit = [r for r in heads if r not in has]
620 while visit:
621 r = visit.pop(0)
622 if r in missing:
623 continue
624 else:
625 missing[r] = None
626 for p in self.parentrevs(r):
627 if p not in has:
628 visit.append(p)
629 missing = missing.keys()
630 missing.sort()
631 return [self.node(r) for r in missing]
632
593 633 def nodesbetween(self, roots=None, heads=None):
594 634 """Return a tuple containing three elements. Elements 1 and 2 contain
595 635 a final list bases and heads after all the unreachable ones have been
@@ -2,4 +2,4 b''
2 2 adding a
3 3 % try hgweb request
4 4 0
5 54086fe9a47b47d83204f38bda0b90c2 page1
5 1f424bb22ec05c3c6bc866b6e67efe43 page1
@@ -100,7 +100,7 b' searching for changes'
100 100 adding changesets
101 101 adding manifests
102 102 adding file changes
103 added 1 changesets with 1 changes to 1 files
103 added 1 changesets with 1 changes to 2 files
104 104 % parent should be 2 (no automatic update)
105 105 2
106 106
1 NO CONTENT: modified file, binary diff hidden
@@ -22,7 +22,7 b' searching for changes'
22 22 adding changesets
23 23 adding manifests
24 24 adding file changes
25 added 2 changesets with 1 changes to 1 files
25 added 2 changesets with 1 changes to 2 files
26 26 adding foo
27 27 updating working directory
28 28 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
General Comments 0
You need to be logged in to leave comments. Login now