Mercurial > hg-stable
changeset 46776:954bad9c32a0
pull: pre-indent a part of the function
We are about to run it in a loop, so lets pre-indent it to clarify the actual
change in the next changesets.
Differential Revision: https://phab.mercurial-scm.org/D10158
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 10 Mar 2021 06:03:55 +0100 |
parents | 052ab8d0a538 |
children | 685383486d0a |
files | mercurial/commands.py |
diffstat | 1 files changed, 96 insertions(+), 93 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Mar 10 05:54:27 2021 +0100 +++ b/mercurial/commands.py Wed Mar 10 06:03:55 2021 +0100 @@ -5365,101 +5365,104 @@ hint = _(b'use hg pull followed by hg update DEST') raise error.InputError(msg, hint=hint) - source, branches = hg.parseurl(ui.expandpath(source), opts.get(b'branch')) - ui.status(_(b'pulling from %s\n') % util.hidepassword(source)) - ui.flush() - other = hg.peer(repo, opts, source) - update_conflict = None - try: - revs, checkout = hg.addbranchrevs( - repo, other, branches, opts.get(b'rev') + if True: + source, branches = hg.parseurl( + ui.expandpath(source), opts.get(b'branch') ) - - pullopargs = {} - - nodes = None - if opts.get(b'bookmark') or revs: - # The list of bookmark used here is the same used to actually update - # the bookmark names, to avoid the race from issue 4689 and we do - # all lookup and bookmark queries in one go so they see the same - # version of the server state (issue 4700). - nodes = [] - fnodes = [] - revs = revs or [] - if revs and not other.capable(b'lookup'): - err = _( - b"other repository doesn't support revision lookup, " - b"so a rev cannot be specified." - ) - raise error.Abort(err) - with other.commandexecutor() as e: - fremotebookmarks = e.callcommand( - b'listkeys', {b'namespace': b'bookmarks'} - ) - for r in revs: - fnodes.append(e.callcommand(b'lookup', {b'key': r})) - remotebookmarks = fremotebookmarks.result() - remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks) - pullopargs[b'remotebookmarks'] = remotebookmarks - for b in opts.get(b'bookmark', []): - b = repo._bookmarks.expandname(b) - if b not in remotebookmarks: - raise error.InputError( - _(b'remote bookmark %s not found!') % b + ui.status(_(b'pulling from %s\n') % util.hidepassword(source)) + ui.flush() + other = hg.peer(repo, opts, source) + update_conflict = None + try: + revs, checkout = hg.addbranchrevs( + repo, other, branches, opts.get(b'rev') + ) + + pullopargs = {} + + nodes = None + if opts.get(b'bookmark') or revs: + # The list of bookmark used here is the same used to actually update + # the bookmark names, to avoid the race from issue 4689 and we do + # all lookup and bookmark queries in one go so they see the same + # version of the server state (issue 4700). + nodes = [] + fnodes = [] + revs = revs or [] + if revs and not other.capable(b'lookup'): + err = _( + b"other repository doesn't support revision lookup, " + b"so a rev cannot be specified." + ) + raise error.Abort(err) + with other.commandexecutor() as e: + fremotebookmarks = e.callcommand( + b'listkeys', {b'namespace': b'bookmarks'} ) - nodes.append(remotebookmarks[b]) - for i, rev in enumerate(revs): - node = fnodes[i].result() - nodes.append(node) - if rev == checkout: - checkout = node - - wlock = util.nullcontextmanager() - if opts.get(b'update'): - wlock = repo.wlock() - with wlock: - pullopargs.update(opts.get(b'opargs', {})) - modheads = exchange.pull( - repo, - other, - heads=nodes, - force=opts.get(b'force'), - bookmarks=opts.get(b'bookmark', ()), - opargs=pullopargs, - confirm=opts.get(b'confirm'), - ).cgresult - - # brev is a name, which might be a bookmark to be activated at - # the end of the update. In other words, it is an explicit - # destination of the update - brev = None - - if checkout: - checkout = repo.unfiltered().changelog.rev(checkout) - - # order below depends on implementation of - # hg.addbranchrevs(). opts['bookmark'] is ignored, - # because 'checkout' is determined without it. - if opts.get(b'rev'): - brev = opts[b'rev'][0] - elif opts.get(b'branch'): - brev = opts[b'branch'][0] - else: - brev = branches[0] - repo._subtoppath = source - try: - update_conflict = postincoming( - ui, repo, modheads, opts.get(b'update'), checkout, brev - ) - except error.FilteredRepoLookupError as exc: - msg = _(b'cannot update to target: %s') % exc.args[0] - exc.args = (msg,) + exc.args[1:] - raise - finally: - del repo._subtoppath - - finally: - other.close() + for r in revs: + fnodes.append(e.callcommand(b'lookup', {b'key': r})) + remotebookmarks = fremotebookmarks.result() + remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks) + pullopargs[b'remotebookmarks'] = remotebookmarks + for b in opts.get(b'bookmark', []): + b = repo._bookmarks.expandname(b) + if b not in remotebookmarks: + raise error.InputError( + _(b'remote bookmark %s not found!') % b + ) + nodes.append(remotebookmarks[b]) + for i, rev in enumerate(revs): + node = fnodes[i].result() + nodes.append(node) + if rev == checkout: + checkout = node + + wlock = util.nullcontextmanager() + if opts.get(b'update'): + wlock = repo.wlock() + with wlock: + pullopargs.update(opts.get(b'opargs', {})) + modheads = exchange.pull( + repo, + other, + heads=nodes, + force=opts.get(b'force'), + bookmarks=opts.get(b'bookmark', ()), + opargs=pullopargs, + confirm=opts.get(b'confirm'), + ).cgresult + + # brev is a name, which might be a bookmark to be activated at + # the end of the update. In other words, it is an explicit + # destination of the update + brev = None + + if checkout: + checkout = repo.unfiltered().changelog.rev(checkout) + + # order below depends on implementation of + # hg.addbranchrevs(). opts['bookmark'] is ignored, + # because 'checkout' is determined without it. + if opts.get(b'rev'): + brev = opts[b'rev'][0] + elif opts.get(b'branch'): + brev = opts[b'branch'][0] + else: + brev = branches[0] + repo._subtoppath = source + try: + update_conflict = postincoming( + ui, repo, modheads, opts.get(b'update'), checkout, brev + ) + except error.FilteredRepoLookupError as exc: + msg = _(b'cannot update to target: %s') % exc.args[0] + exc.args = (msg,) + exc.args[1:] + raise + finally: + del repo._subtoppath + + finally: + other.close() if update_conflict: return 1 else: