--- a/mercurial/cmdutil.py Wed Feb 15 10:46:46 2023 +0100
+++ b/mercurial/cmdutil.py Sun Feb 05 15:38:23 2023 +0100
@@ -2794,8 +2794,6 @@
date = opts.get(b'date')
if date:
opts[b'date'] = dateutil.parsedate(date)
- message = logmessage(ui, opts)
- matcher = scmutil.match(repo[None], pats, opts)
dsguard = None
# extract addremove carefully -- this function can be called from a command
@@ -2803,15 +2801,29 @@
if opts.get(b'addremove'):
dsguard = dirstateguard.dirstateguard(repo, b'commit')
with dsguard or util.nullcontextmanager():
- if dsguard:
- relative = scmutil.anypats(pats, opts)
- uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=relative)
- if scmutil.addremove(repo, matcher, b"", uipathfn, opts) != 0:
- raise error.Abort(
- _(b"failed to mark all new/missing files as added/removed")
+ message = logmessage(ui, opts)
+ matcher = scmutil.match(repo[None], pats, opts)
+ if True:
+ # extract addremove carefully -- this function can be called from a
+ # command that doesn't support addremove
+ if opts.get(b'addremove'):
+ relative = scmutil.anypats(pats, opts)
+ uipathfn = scmutil.getuipathfn(
+ repo,
+ legacyrelativevalue=relative,
)
-
- return commitfunc(ui, repo, message, matcher, opts)
+ r = scmutil.addremove(
+ repo,
+ matcher,
+ b"",
+ uipathfn,
+ opts,
+ )
+ m = _(b"failed to mark all new/missing files as added/removed")
+ if r != 0:
+ raise error.Abort(m)
+
+ return commitfunc(ui, repo, message, matcher, opts)
def samefile(f, ctx1, ctx2):