# HG changeset patch # User Pierre-Yves David # Date 1675120133 -3600 # Node ID 5c9462adc4b997cc1338b7de0daf53aeb866ce9a # Parent 7e71d878c708dbd02b6e6c8c6295dd398ffaa1fc dirstate: use `dirstate.change_files` to scope the change in `copy` This is the way, unless we are not actually touching the working copy. In such cases we don't need to do something. diff -r 7e71d878c708 -r 5c9462adc4b9 mercurial/commands.py --- a/mercurial/commands.py Tue Dec 13 16:29:30 2022 +0100 +++ b/mercurial/commands.py Tue Jan 31 00:08:53 2023 +0100 @@ -2497,7 +2497,19 @@ 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)