# HG changeset patch # User Pierre-Yves David # Date 2022-12-13 23:47:22 # Node ID 237e9d2e1c719bf392aab4dd63973ccadb98546b # Parent 1346db77e14da5783e2353c91403713542fbde55 dirstate: use `dirstate.change_files` to scope the change in `amend` This is the way. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2985,12 +2985,13 @@ def amend(ui, repo, old, extra, pats, op matcher = scmutil.match(wctx, pats, opts) relative = scmutil.anypats(pats, opts) uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=relative) - if opts.get(b'addremove') and scmutil.addremove( - repo, matcher, b"", uipathfn, opts - ): - raise error.Abort( - _(b"failed to mark all new/missing files as added/removed") - ) + if opts.get(b'addremove'): + with repo.dirstate.changing_files(repo): + if scmutil.addremove(repo, matcher, b"", uipathfn, opts) != 0: + m = _( + b"failed to mark all new/missing files as added/removed" + ) + raise error.Abort(m) # Check subrepos. This depends on in-place wctx._status update in # subrepo.precommit(). To minimize the risk of this hack, we do