# HG changeset patch # User Pierre-Yves David # Date 2023-01-30 23:05:12 # Node ID e356e8b65d703c58d90f87453c66f97f77742dd0 # Parent 5c9462adc4b997cc1338b7de0daf53aeb866ce9a dirstate: use `dirstate.change_files` to scope the change in `rename` This is the way, unless we are not actually touching the working copy. In such cases we don't need to do something. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -6014,7 +6014,18 @@ def rename(ui, repo, *pats, **opts): Returns 0 on success, 1 if errors are encountered. """ opts = pycompat.byteskwargs(opts) - with repo.wlock(): + context = repo.dirstate.changing_files + rev = opts.get(b'at_rev') + ctx = None + if rev: + ctx = logcmdutil.revsingle(repo, rev) + if ctx.rev() is not None: + + def context(repo): + return util.nullcontextmanager() + + opts[b'at_rev'] = ctx.rev() + with repo.wlock(), context(repo): return cmdutil.copy(ui, repo, pats, opts, rename=True)