comparison mercurial/localrepo.py @ 15837:cd956049fc14

discovery: introduce outgoing object for result of findcommonoutgoing Simplifies client logic in multiple places since it encapsulates the computation of the common and, more importantly, the missing node lists. This also allows an upcomping patch to communicate precomputed versions of these lists to clients.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 09 Jan 2012 03:47:16 +0100
parents 2673006f7989
children cc8287d51680
comparison
equal deleted inserted replaced
15836:926c9ee8d4be 15837:cd956049fc14
1737 csets, bases, heads = cl.nodesbetween(bases, heads) 1737 csets, bases, heads = cl.nodesbetween(bases, heads)
1738 # We assume that all ancestors of bases are known 1738 # We assume that all ancestors of bases are known
1739 common = set(cl.ancestors(*[cl.rev(n) for n in bases])) 1739 common = set(cl.ancestors(*[cl.rev(n) for n in bases]))
1740 return self._changegroupsubset(common, csets, heads, source) 1740 return self._changegroupsubset(common, csets, heads, source)
1741 1741
1742 def getlocalbundle(self, source, outgoing):
1743 """Like getbundle, but taking a discovery.outgoing as an argument.
1744
1745 This is only implemented for local repos and reuses potentially
1746 precomputed sets in outgoing."""
1747 if not outgoing.missing:
1748 return None
1749 return self._changegroupsubset(outgoing.common,
1750 outgoing.missing,
1751 outgoing.missingheads,
1752 source)
1753
1742 def getbundle(self, source, heads=None, common=None): 1754 def getbundle(self, source, heads=None, common=None):
1743 """Like changegroupsubset, but returns the set difference between the 1755 """Like changegroupsubset, but returns the set difference between the
1744 ancestors of heads and the ancestors common. 1756 ancestors of heads and the ancestors common.
1745 1757
1746 If heads is None, use the local heads. If common is None, use [nullid]. 1758 If heads is None, use the local heads. If common is None, use [nullid].
1754 common = [n for n in common if n in nm] 1766 common = [n for n in common if n in nm]
1755 else: 1767 else:
1756 common = [nullid] 1768 common = [nullid]
1757 if not heads: 1769 if not heads:
1758 heads = cl.heads() 1770 heads = cl.heads()
1759 common, missing = cl.findcommonmissing(common, heads) 1771 return self.getlocalbundle(source,
1760 if not missing: 1772 discovery.outgoing(cl, common, heads))
1761 return None
1762 return self._changegroupsubset(common, missing, heads, source)
1763 1773
1764 def _changegroupsubset(self, commonrevs, csets, heads, source): 1774 def _changegroupsubset(self, commonrevs, csets, heads, source):
1765 1775
1766 cl = self.changelog 1776 cl = self.changelog
1767 mf = self.manifest 1777 mf = self.manifest