# HG changeset patch # User Pierre-Yves David # Date 2014-04-01 21:33:23 # Node ID 91b47139d0cb3d1893199821c8f0f88302aea379 # Parent 24a44394862709ef29b00da62237b4276ea510f0 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. diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -480,3 +480,13 @@ def changegroupsubset(repo, roots, heads bundler = bundle10(repo) return getsubset(repo, outgoing, bundler, source) +def getlocalbundle(repo, source, outgoing, bundlecaps=None): + """Like getbundle, but taking a discovery.outgoing as an argument. + + This is only implemented for local repos and reuses potentially + precomputed sets in outgoing.""" + if not outgoing.missing: + return None + bundler = bundle10(repo, bundlecaps) + return getsubset(repo, outgoing, bundler, source) + diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1142,7 +1142,7 @@ def bundle(ui, repo, fname, dest=None, * onlyheads=heads, force=opts.get('force'), portable=True) - cg = repo.getlocalbundle('bundle', outgoing, bundlecaps) + cg = changegroup.getlocalbundle(repo, 'bundle', outgoing, bundlecaps) if not cg: scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded) return 1 diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -187,7 +187,8 @@ def _pushchangeset(pushop): 'push', fastpath=True) else: - cg = pushop.repo.getlocalbundle('push', outgoing, bundlecaps) + cg = changegroup.getlocalbundle(pushop.repo, 'push', outgoing, + bundlecaps) # apply changegroup to remote if unbundle: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1683,16 +1683,6 @@ class localrepository(object): def push(self, remote, force=False, revs=None, newbranch=False): return exchange.push(self, remote, force, revs, newbranch) - def getlocalbundle(self, source, outgoing, bundlecaps=None): - """Like getbundle, but taking a discovery.outgoing as an argument. - - This is only implemented for local repos and reuses potentially - precomputed sets in outgoing.""" - if not outgoing.missing: - return None - bundler = changegroup.bundle10(self, bundlecaps) - return changegroup.getsubset(self, outgoing, bundler, source) - def getbundle(self, source, heads=None, common=None, bundlecaps=None): """Like changegroupsubset, but returns the set difference between the ancestors of heads and the ancestors common. @@ -1710,9 +1700,9 @@ class localrepository(object): common = [nullid] if not heads: heads = cl.heads() - return self.getlocalbundle(source, - discovery.outgoing(cl, common, heads), - bundlecaps=bundlecaps) + outgoing = discovery.outgoing(cl, common, heads) + return changegroup.getlocalbundle(self, source, outgoing, + bundlecaps=bundlecaps) def changegroup(self, basenodes, source): # to avoid a race we use changegroupsubset() (issue1320)