Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 46777:25850879a215
push: indent the some part of the command
That code will be put in a loop in the next changeset, pre-indenting make the
next change clearer.
Differential Revision: https://phab.mercurial-scm.org/D10160
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 17 Mar 2021 15:20:45 +0100 |
parents | 471cd86c8eb4 |
children | 066b8d8f75b8 |
comparison
equal
deleted
inserted
replaced
46776:471cd86c8eb4 | 46777:25850879a215 |
---|---|
5704 opts.setdefault(b'rev', []).append(b) | 5704 opts.setdefault(b'rev', []).append(b) |
5705 else: | 5705 else: |
5706 # if we try to push a deleted bookmark, translate it to null | 5706 # if we try to push a deleted bookmark, translate it to null |
5707 # this lets simultaneous -r, -b options continue working | 5707 # this lets simultaneous -r, -b options continue working |
5708 opts.setdefault(b'rev', []).append(b"null") | 5708 opts.setdefault(b'rev', []).append(b"null") |
5709 | 5709 if True: |
5710 path = ui.getpath(dest, default=(b'default-push', b'default')) | 5710 path = ui.getpath(dest, default=(b'default-push', b'default')) |
5711 if not path: | 5711 if not path: |
5712 raise error.ConfigError( | 5712 raise error.ConfigError( |
5713 _(b'default repository not configured!'), | 5713 _(b'default repository not configured!'), |
5714 hint=_(b"see 'hg help config.paths'"), | 5714 hint=_(b"see 'hg help config.paths'"), |
5715 ) | |
5716 dest = path.pushloc or path.loc | |
5717 branches = (path.branch, opts.get(b'branch') or []) | |
5718 ui.status(_(b'pushing to %s\n') % util.hidepassword(dest)) | |
5719 revs, checkout = hg.addbranchrevs( | |
5720 repo, repo, branches, opts.get(b'rev') | |
5715 ) | 5721 ) |
5716 dest = path.pushloc or path.loc | 5722 other = hg.peer(repo, opts, dest) |
5717 branches = (path.branch, opts.get(b'branch') or []) | 5723 |
5718 ui.status(_(b'pushing to %s\n') % util.hidepassword(dest)) | 5724 try: |
5719 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get(b'rev')) | 5725 if revs: |
5720 other = hg.peer(repo, opts, dest) | 5726 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)] |
5721 | 5727 if not revs: |
5722 try: | 5728 raise error.InputError( |
5723 if revs: | 5729 _(b"specified revisions evaluate to an empty set"), |
5724 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)] | 5730 hint=_(b"use different revision arguments"), |
5725 if not revs: | 5731 ) |
5732 elif path.pushrev: | |
5733 # It doesn't make any sense to specify ancestor revisions. So limit | |
5734 # to DAG heads to make discovery simpler. | |
5735 expr = revsetlang.formatspec(b'heads(%r)', path.pushrev) | |
5736 revs = scmutil.revrange(repo, [expr]) | |
5737 revs = [repo[rev].node() for rev in revs] | |
5738 if not revs: | |
5739 raise error.InputError( | |
5740 _( | |
5741 b'default push revset for path evaluates to an empty set' | |
5742 ) | |
5743 ) | |
5744 elif ui.configbool(b'commands', b'push.require-revs'): | |
5726 raise error.InputError( | 5745 raise error.InputError( |
5727 _(b"specified revisions evaluate to an empty set"), | 5746 _(b'no revisions specified to push'), |
5728 hint=_(b"use different revision arguments"), | 5747 hint=_(b'did you mean "hg push -r ."?'), |
5729 ) | 5748 ) |
5730 elif path.pushrev: | 5749 |
5731 # It doesn't make any sense to specify ancestor revisions. So limit | 5750 repo._subtoppath = dest |
5732 # to DAG heads to make discovery simpler. | 5751 try: |
5733 expr = revsetlang.formatspec(b'heads(%r)', path.pushrev) | 5752 # push subrepos depth-first for coherent ordering |
5734 revs = scmutil.revrange(repo, [expr]) | 5753 c = repo[b'.'] |
5735 revs = [repo[rev].node() for rev in revs] | 5754 subs = c.substate # only repos that are committed |
5736 if not revs: | 5755 for s in sorted(subs): |
5737 raise error.InputError( | 5756 result = c.sub(s).push(opts) |
5738 _(b'default push revset for path evaluates to an empty set') | 5757 if result == 0: |
5739 ) | 5758 return not result |
5740 elif ui.configbool(b'commands', b'push.require-revs'): | 5759 finally: |
5741 raise error.InputError( | 5760 del repo._subtoppath |
5742 _(b'no revisions specified to push'), | 5761 |
5743 hint=_(b'did you mean "hg push -r ."?'), | 5762 opargs = dict( |
5763 opts.get(b'opargs', {}) | |
5764 ) # copy opargs since we may mutate it | |
5765 opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', [])) | |
5766 | |
5767 pushop = exchange.push( | |
5768 repo, | |
5769 other, | |
5770 opts.get(b'force'), | |
5771 revs=revs, | |
5772 newbranch=opts.get(b'new_branch'), | |
5773 bookmarks=opts.get(b'bookmark', ()), | |
5774 publish=opts.get(b'publish'), | |
5775 opargs=opargs, | |
5744 ) | 5776 ) |
5745 | 5777 |
5746 repo._subtoppath = dest | 5778 result = not pushop.cgresult |
5747 try: | 5779 |
5748 # push subrepos depth-first for coherent ordering | 5780 if pushop.bkresult is not None: |
5749 c = repo[b'.'] | 5781 if pushop.bkresult == 2: |
5750 subs = c.substate # only repos that are committed | 5782 result = 2 |
5751 for s in sorted(subs): | 5783 elif not result and pushop.bkresult: |
5752 result = c.sub(s).push(opts) | 5784 result = 2 |
5753 if result == 0: | |
5754 return not result | |
5755 finally: | 5785 finally: |
5756 del repo._subtoppath | 5786 other.close() |
5757 | |
5758 opargs = dict( | |
5759 opts.get(b'opargs', {}) | |
5760 ) # copy opargs since we may mutate it | |
5761 opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', [])) | |
5762 | |
5763 pushop = exchange.push( | |
5764 repo, | |
5765 other, | |
5766 opts.get(b'force'), | |
5767 revs=revs, | |
5768 newbranch=opts.get(b'new_branch'), | |
5769 bookmarks=opts.get(b'bookmark', ()), | |
5770 publish=opts.get(b'publish'), | |
5771 opargs=opargs, | |
5772 ) | |
5773 | |
5774 result = not pushop.cgresult | |
5775 | |
5776 if pushop.bkresult is not None: | |
5777 if pushop.bkresult == 2: | |
5778 result = 2 | |
5779 elif not result and pushop.bkresult: | |
5780 result = 2 | |
5781 finally: | |
5782 other.close() | |
5783 return result | 5787 return result |
5784 | 5788 |
5785 | 5789 |
5786 @command( | 5790 @command( |
5787 b'recover', | 5791 b'recover', |