changeset 47141:5ffc6c18fb96

rename: add hint about --at-rev if source file doesn't exist It's quite common that users want to record copy (rename) information after committing the working copy changes (i.e. an added and a deleted file). When they try `hg mv [--after] <src> <dst>`, that just fails because the source file doesn't exist. It seems helpful if we can point them to `--at-rev=.` in this case. Differential Revision: https://phab.mercurial-scm.org/D10697
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 07 May 2021 08:38:17 -0700
parents ecfe0819ada5
children bea4717415c0
files mercurial/cmdutil.py tests/test-copy.t tests/test-remotefilelog-prefetch.t
diffstat 3 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Apr 30 20:21:56 2021 +0200
+++ b/mercurial/cmdutil.py	Fri May 07 08:38:17 2021 -0700
@@ -1851,7 +1851,10 @@
             continue
         copylist.append((tfn(pat, dest, srcs), srcs))
     if not copylist:
-        raise error.InputError(_(b'no files to copy'))
+        hint = None
+        if rename:
+            hint = _(b'maybe you meant to use --after --at-rev=.')
+        raise error.InputError(_(b'no files to copy'), hint=hint)
 
     errors = 0
     for targetpath, srcs in copylist:
--- a/tests/test-copy.t	Fri Apr 30 20:21:56 2021 +0200
+++ b/tests/test-copy.t	Fri May 07 08:38:17 2021 -0700
@@ -115,6 +115,7 @@
   $ hg mv foo bar
   foo: not copying - file is not managed
   abort: no files to copy
+  (maybe you meant to use --after --at-rev=.)
   [10]
   $ hg st -A
   ? foo
@@ -124,14 +125,17 @@
   $ hg mv ../foo ../bar
   ../foo: not copying - file is not managed
   abort: no files to copy
+  (maybe you meant to use --after --at-rev=.)
   [10]
   $ hg mv ../foo ../bar --config ui.relative-paths=yes
   ../foo: not copying - file is not managed
   abort: no files to copy
+  (maybe you meant to use --after --at-rev=.)
   [10]
   $ hg mv ../foo ../bar --config ui.relative-paths=no
   foo: not copying - file is not managed
   abort: no files to copy
+  (maybe you meant to use --after --at-rev=.)
   [10]
   $ cd ..
   $ rmdir dir
--- a/tests/test-remotefilelog-prefetch.t	Fri Apr 30 20:21:56 2021 +0200
+++ b/tests/test-remotefilelog-prefetch.t	Fri May 07 08:38:17 2021 -0700
@@ -237,6 +237,7 @@
   $ hg mv z2 z3
   z2: not copying - file is not managed
   abort: no files to copy
+  (maybe you meant to use --after --at-rev=.)
   [10]
   $ find $CACHEDIR -type f | sort
 .. The following output line about files fetches is globed because it is