changeset 45389:5178dd2233d0

rename: add support for --at-rev, which marks as copy and removes the source I had previously only added support for `--at-rev` to `hg cp`, but not to `hg mv`. This patch adds that support. Just like for `hg cp`, it marks the destination as copied from the source, and doesn't care if the source file still exists (because it only supports the `-A` mode, aka "don't touch files" mode). It works whether or not the source file still exists. This matches the behavior of `hg mv -A` in the working copy. Differential Revision: https://phab.mercurial-scm.org/D8840
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 28 Jul 2020 09:58:28 -0700
parents d71693f799a0
children 15d35f2ba474
files mercurial/commands.py relnotes/next tests/test-completion.t tests/test-rename-rev.t
diffstat 4 files changed, 44 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Jul 24 15:03:14 2020 -0700
+++ b/mercurial/commands.py	Tue Jul 28 09:58:28 2020 -0700
@@ -5781,6 +5781,13 @@
     [
         (b'A', b'after', None, _(b'record a rename that has already occurred')),
         (
+            b'',
+            b'at-rev',
+            b'',
+            _(b'(un)mark renames in the given revision (EXPERIMENTAL)'),
+            _(b'REV'),
+        ),
+        (
             b'f',
             b'force',
             None,
--- a/relnotes/next	Fri Jul 24 15:03:14 2020 -0700
+++ b/relnotes/next	Tue Jul 28 09:58:28 2020 -0700
@@ -1,5 +1,9 @@
 == New Features ==
 
+ * `hg mv -A` can now be used with `--at-rev`. It behaves just like
+   `hg cp -A --at-rev`, i.e. it marks the destination as a copy of the
+   source whether or not the source still exists (but the source must
+   exist in the parent revision).
 
 
 == New Experimental Features ==
--- a/tests/test-completion.t	Fri Jul 24 15:03:14 2020 -0700
+++ b/tests/test-completion.t	Tue Jul 28 09:58:28 2020 -0700
@@ -353,7 +353,7 @@
   push: force, rev, bookmark, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
   recover: verify
   remove: after, force, subrepos, include, exclude, dry-run
-  rename: after, force, include, exclude, dry-run
+  rename: after, at-rev, force, include, exclude, dry-run
   resolve: all, list, mark, unmark, no-status, re-merge, tool, include, exclude, template
   revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
   rollback: dry-run, force
--- a/tests/test-rename-rev.t	Fri Jul 24 15:03:14 2020 -0700
+++ b/tests/test-rename-rev.t	Tue Jul 28 09:58:28 2020 -0700
@@ -43,7 +43,7 @@
   A d1/d
     d1/b
 
-Test moved file (not copied)
+Test moved file (not copied) using 'hg cp' command
 
   $ hg co 0
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
@@ -59,10 +59,40 @@
     d1/b
   R d1/b
 
+Test moved file (not copied) using 'hg mv' command
+
+  $ hg co 0
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mv d1/b d1/d
+  $ hg rm -A d1/b
+  $ hg add d1/d
+  $ hg ci -m 'move d1/b to d1/d'
+  created new head
+  $ hg mv -A --at-rev . d1/b d1/d
+  saved backup bundle to $TESTTMP/.hg/strip-backup/519850c3ea27-153c8fbb-copy.hg
+  $ hg st -C --change .
+  A d1/d
+    d1/b
+  R d1/b
+
+Test moved file (not copied) for which source still exists
+
+  $ hg co 0
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ cp d1/b d1/d
+  $ hg add d1/d
+  $ hg ci -m 'copy d1/b to d1/d'
+  created new head
+  $ hg mv -A --at-rev . d1/b d1/d
+  saved backup bundle to $TESTTMP/.hg/strip-backup/c8d0f6bcf7ca-1c9bb53e-copy.hg
+  $ hg st -C --change .
+  A d1/d
+    d1/b
+
 Test using directory as destination
 
   $ hg co 0
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ cp -R d1 d3
   $ hg add d3
   adding d3/a