Patchwork D8496: copy: give better error message when no source paths found with --at-rev

login
register
mail settings
Submitter phabricator
Date May 6, 2020, 7:02 p.m.
Message ID <differential-rev-PHID-DREV-nm4szkqeq7vhumhbinrm-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46262/
State Superseded
Headers show

Comments

phabricator - May 6, 2020, 7:02 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The new error message matches what we show when marking copies in the
  working copy.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-rename-rev.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-rename-rev.t b/tests/test-rename-rev.t
--- a/tests/test-rename-rev.t
+++ b/tests/test-rename-rev.t
@@ -25,10 +25,9 @@ 
   abort: --at-rev requires --after
   [255]
 # Errors out with non-existent source
-BROKEN: this should have a better error message
   $ hg cp -A --at-rev . d1/non-existent d1/d
   d1/non-existent: no such file in rev 55d1fd85ef0a
-  abort: --at-rev requires a single source
+  abort: no files to copy
   [255]
 # Errors out with non-existent destination
   $ hg cp -A --at-rev . d1/b d1/non-existent
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1552,6 +1552,8 @@ 
             for abs, rel, exact in srcs:
                 copylist.append(abs)
 
+        if not copylist:
+            raise error.Abort(_(b'no files to copy'))
         # TODO: Add support for `hg cp --at-rev . foo bar dir` and
         # `hg cp --at-rev . dir1 dir2`, preferably unifying the code with the
         # existing functions below.