D10160: push: indent the some part of the command
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Thu Mar 11 16:53:34 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
That code will be put in a loop in the next changeset, pre-indenting make the
next change clearer.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10160
AFFECTED FILES
mercurial/commands.py
CHANGE DETAILS
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5699,79 +5699,84 @@
# this lets simultaneous -r, -b options continue working
opts.setdefault(b'rev', []).append(b"null")
- path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
- if not path:
- raise error.ConfigError(
- _(b'default repository not configured!'),
- hint=_(b"see 'hg help config.paths'"),
- )
- dest = path.pushloc or path.loc
- branches = (path.branch, opts.get(b'branch') or [])
- ui.status(_(b'pushing to %s\n') % util.hidepassword(dest))
- revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get(b'rev'))
- other = hg.peer(repo, opts, dest)
-
- try:
- if revs:
- revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
- if not revs:
- raise error.InputError(
- _(b"specified revisions evaluate to an empty set"),
- hint=_(b"use different revision arguments"),
- )
- elif path.pushrev:
- # It doesn't make any sense to specify ancestor revisions. So limit
- # to DAG heads to make discovery simpler.
- expr = revsetlang.formatspec(b'heads(%r)', path.pushrev)
- revs = scmutil.revrange(repo, [expr])
- revs = [repo[rev].node() for rev in revs]
- if not revs:
- raise error.InputError(
- _(b'default push revset for path evaluates to an empty set')
- )
- elif ui.configbool(b'commands', b'push.require-revs'):
- raise error.InputError(
- _(b'no revisions specified to push'),
- hint=_(b'did you mean "hg push -r ."?'),
+ if True:
+ path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
+ if not path:
+ raise error.ConfigError(
+ _(b'default repository not configured!'),
+ hint=_(b"see 'hg help config.paths'"),
)
-
- repo._subtoppath = dest
+ dest = path.pushloc or path.loc
+ branches = (path.branch, opts.get(b'branch') or [])
+ ui.status(_(b'pushing to %s\n') % util.hidepassword(dest))
+ revs, checkout = hg.addbranchrevs(
+ repo, repo, branches, opts.get(b'rev')
+ )
+ other = hg.peer(repo, opts, dest)
+
try:
- # push subrepos depth-first for coherent ordering
- c = repo[b'.']
- 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
+ if revs:
+ revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
+ if not revs:
+ raise error.InputError(
+ _(b"specified revisions evaluate to an empty set"),
+ hint=_(b"use different revision arguments"),
+ )
+ elif path.pushrev:
+ # It doesn't make any sense to specify ancestor revisions. So limit
+ # to DAG heads to make discovery simpler.
+ expr = revsetlang.formatspec(b'heads(%r)', path.pushrev)
+ revs = scmutil.revrange(repo, [expr])
+ revs = [repo[rev].node() for rev in revs]
+ if not revs:
+ raise error.InputError(
+ _(
+ b'default push revset for path evaluates to an empty set'
+ )
+ )
+ elif ui.configbool(b'commands', b'push.require-revs'):
+ raise error.InputError(
+ _(b'no revisions specified to push'),
+ hint=_(b'did you mean "hg push -r ."?'),
+ )
+
+ repo._subtoppath = dest
+ try:
+ # push subrepos depth-first for coherent ordering
+ c = repo[b'.']
+ 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
+
+ opargs = dict(
+ opts.get(b'opargs', {})
+ ) # copy opargs since we may mutate it
+ opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', []))
+
+ pushop = exchange.push(
+ repo,
+ other,
+ opts.get(b'force'),
+ revs=revs,
+ newbranch=opts.get(b'new_branch'),
+ bookmarks=opts.get(b'bookmark', ()),
+ publish=opts.get(b'publish'),
+ opargs=opargs,
+ )
+
+ result = not pushop.cgresult
+
+ if pushop.bkresult is not None:
+ if pushop.bkresult == 2:
+ result = 2
+ elif not result and pushop.bkresult:
+ result = 2
finally:
- del repo._subtoppath
-
- opargs = dict(
- opts.get(b'opargs', {})
- ) # copy opargs since we may mutate it
- opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', []))
-
- pushop = exchange.push(
- repo,
- other,
- opts.get(b'force'),
- revs=revs,
- newbranch=opts.get(b'new_branch'),
- bookmarks=opts.get(b'bookmark', ()),
- publish=opts.get(b'publish'),
- opargs=opargs,
- )
-
- result = not pushop.cgresult
-
- if pushop.bkresult is not None:
- if pushop.bkresult == 2:
- result = 2
- elif not result and pushop.bkresult:
- result = 2
- finally:
- other.close()
+ other.close()
return result
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list