[PATCH 5 of 5 (4 more to go)] localrepo: move the getlocalbundle method in changegroup module
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Wed Apr 2 12:59:06 CDT 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1396388003 25200
# Tue Apr 01 14:33:23 2014 -0700
# Node ID 276adcc5b005bc457e1e5909d337f64a20571a3a
# Parent af6d0a35ce48ff09960e92c41a58c93730ddf00f
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
@@ -479,5 +479,15 @@ def changegroupsubset(repo, roots, heads
discbases.extend([p for p in cl.parents(n) if p != nullid])
outgoing = discovery.outgoing(cl, discbases, 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
@@ -1140,11 +1140,11 @@ def bundle(ui, repo, fname, dest=None, *
heads = revs and map(repo.lookup, revs) or revs
outgoing = discovery.findcommonoutgoing(repo, other,
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
changegroup.writebundle(cg, fname, bundletype)
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -185,11 +185,12 @@ def _pushchangeset(pushop):
outgoing,
bundler,
'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:
# local repo finds heads on server, finds out what
# revs it must push. once revs transferred, if server
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1677,20 +1677,10 @@ class localrepository(object):
pass
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.
If heads is None, use the local heads. If common is None, use [nullid].
@@ -1704,13 +1694,13 @@ class localrepository(object):
common = [n for n in common if hasnode(n)]
else:
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)
return changegroup.changegroupsubset(self, basenodes, self.heads(),
source)
More information about the Mercurial-devel
mailing list