comparison mercurial/localrepo.py @ 20928:91b47139d0cb

localrepo: move the getlocalbundle method in changegroup module This is a gratuitous code move aimed at reducing the localrepo bloatness. The method had 3 callers total, far too few for being kept in local repo.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 01 Apr 2014 14:33:23 -0700
parents 24a443948627
children 4a987060d97e
comparison
equal deleted inserted replaced
20927:24a443948627 20928:91b47139d0cb
1681 pass 1681 pass
1682 1682
1683 def push(self, remote, force=False, revs=None, newbranch=False): 1683 def push(self, remote, force=False, revs=None, newbranch=False):
1684 return exchange.push(self, remote, force, revs, newbranch) 1684 return exchange.push(self, remote, force, revs, newbranch)
1685 1685
1686 def getlocalbundle(self, source, outgoing, bundlecaps=None):
1687 """Like getbundle, but taking a discovery.outgoing as an argument.
1688
1689 This is only implemented for local repos and reuses potentially
1690 precomputed sets in outgoing."""
1691 if not outgoing.missing:
1692 return None
1693 bundler = changegroup.bundle10(self, bundlecaps)
1694 return changegroup.getsubset(self, outgoing, bundler, source)
1695
1696 def getbundle(self, source, heads=None, common=None, bundlecaps=None): 1686 def getbundle(self, source, heads=None, common=None, bundlecaps=None):
1697 """Like changegroupsubset, but returns the set difference between the 1687 """Like changegroupsubset, but returns the set difference between the
1698 ancestors of heads and the ancestors common. 1688 ancestors of heads and the ancestors common.
1699 1689
1700 If heads is None, use the local heads. If common is None, use [nullid]. 1690 If heads is None, use the local heads. If common is None, use [nullid].
1708 common = [n for n in common if hasnode(n)] 1698 common = [n for n in common if hasnode(n)]
1709 else: 1699 else:
1710 common = [nullid] 1700 common = [nullid]
1711 if not heads: 1701 if not heads:
1712 heads = cl.heads() 1702 heads = cl.heads()
1713 return self.getlocalbundle(source, 1703 outgoing = discovery.outgoing(cl, common, heads)
1714 discovery.outgoing(cl, common, heads), 1704 return changegroup.getlocalbundle(self, source, outgoing,
1715 bundlecaps=bundlecaps) 1705 bundlecaps=bundlecaps)
1716 1706
1717 def changegroup(self, basenodes, source): 1707 def changegroup(self, basenodes, source):
1718 # to avoid a race we use changegroupsubset() (issue1320) 1708 # to avoid a race we use changegroupsubset() (issue1320)
1719 return changegroup.changegroupsubset(self, basenodes, self.heads(), 1709 return changegroup.changegroupsubset(self, basenodes, self.heads(),
1720 source) 1710 source)