comparison mercurial/commands.py @ 49769:f65656572e25

commit: move check for incompatible args earlier I think it makes sense to check the command line arguments as early as possible, so we don't have to wait for a repo lock to tell the user that they passed invalid arguments.
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 29 Nov 2022 13:31:01 -0800
parents 2aaa5d1e57e9
children f0e9dda408b3
comparison
equal deleted inserted replaced
49768:bcae90c53def 49769:f65656572e25
2080 2080
2081 - amend the current commit and set the date to now:: 2081 - amend the current commit and set the date to now::
2082 2082
2083 hg commit --amend --date now 2083 hg commit --amend --date now
2084 """ 2084 """
2085 cmdutil.check_incompatible_arguments(opts, 'subrepos', ['amend'])
2085 with repo.wlock(), repo.lock(): 2086 with repo.wlock(), repo.lock():
2086 return _docommit(ui, repo, *pats, **opts) 2087 return _docommit(ui, repo, *pats, **opts)
2087 2088
2088 2089
2089 def _docommit(ui, repo, *pats, **opts): 2090 def _docommit(ui, repo, *pats, **opts):
2095 # ret can be 0 (no changes to record) or the value returned by 2096 # ret can be 0 (no changes to record) or the value returned by
2096 # commit(), 1 if nothing changed or None on success. 2097 # commit(), 1 if nothing changed or None on success.
2097 return 1 if ret == 0 else ret 2098 return 1 if ret == 0 else ret
2098 2099
2099 if opts.get('subrepos'): 2100 if opts.get('subrepos'):
2100 cmdutil.check_incompatible_arguments(opts, 'subrepos', ['amend'])
2101 # Let --subrepos on the command line override config setting. 2101 # Let --subrepos on the command line override config setting.
2102 ui.setconfig(b'ui', b'commitsubrepos', True, b'commit') 2102 ui.setconfig(b'ui', b'commitsubrepos', True, b'commit')
2103 2103
2104 cmdutil.checkunfinished(repo, commit=True) 2104 cmdutil.checkunfinished(repo, commit=True)
2105 2105