mercurial/commands.py
changeset 50035 e356e8b65d70
parent 50034 5c9462adc4b9
child 50064 b54801fec664
--- a/mercurial/commands.py	Tue Jan 31 00:08:53 2023 +0100
+++ b/mercurial/commands.py	Tue Jan 31 00:05:12 2023 +0100
@@ -6014,7 +6014,18 @@
     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)