[PATCH 2 of 2] cmdutil: factor out pushsubrepos
Ryan McElroy
rmcelroy at fb.com
Thu Feb 12 02:41:05 CST 2015
# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1423729275 28800
# Thu Feb 12 00:21:15 2015 -0800
# Node ID ffd1a811f1c7c1998460e7bb64169183ad2c1657
# Parent 05e7d10145be0af89e1eb6cf70c56e97f81101ab
cmdutil: factor out pushsubrepos
In the remotenames extension, we replace large parts of the functionality of
the push command. By factoring out this code, we can call it from the extension
and avoid rewriting it in the extension.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2977,3 +2977,16 @@ def pushdest(ui, repo, dest, opts):
raise
return (dest, branches, revs, other)
+
+def pushsubrepos(repo, dest, opts):
+ repo._subtoppath = dest
+ try:
+ # push subrepos depth-first for coherent ordering
+ c = repo['']
+ subs = c.substate # only repos that are committed
+ for s in sorted(subs):
+ result = c.sub(s).push(opts)
+ if result == 0:
+ return not result
+ finally:
+ del repo._subtoppath
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5088,17 +5088,8 @@ def push(ui, repo, dest=None, **opts):
if revs:
revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
- repo._subtoppath = dest
- try:
- # push subrepos depth-first for coherent ordering
- c = repo['']
- subs = c.substate # only repos that are committed
- for s in sorted(subs):
- result = c.sub(s).push(opts)
- if result == 0:
- return not result
- finally:
- del repo._subtoppath
+ cmdutil.pushsubrepos(repo, dest, opts)
+
pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
newbranch=opts.get('new_branch'),
bookmarks=opts.get('bookmark', ()))
More information about the Mercurial-devel
mailing list