Patchwork D10697: rename: add hint about --at-rev if source file doesn't exist

login
register
mail settings
Submitter phabricator
Date May 7, 2021, 3:47 p.m.
Message ID <differential-rev-PHID-DREV-l6b7elqlzlggh6q2ahcv-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49016/
State Superseded
Headers show

Comments

phabricator - May 7, 2021, 3:47 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10697

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-copy.t
  tests/test-remotefilelog-prefetch.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-remotefilelog-prefetch.t b/tests/test-remotefilelog-prefetch.t
--- a/tests/test-remotefilelog-prefetch.t
+++ b/tests/test-remotefilelog-prefetch.t
@@ -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
diff --git a/tests/test-copy.t b/tests/test-copy.t
--- a/tests/test-copy.t
+++ b/tests/test-copy.t
@@ -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
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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: