cmdutil: Warn when trying to copy/rename --after to a nonexistant file.
Currently running 'hg rename --after foo.txt bar.typo' is a silent no-op. This patch adds a warning. It also updates the copy and rename tests.
No actual functionality is changed.
fixes issue 1822
--- a/mercurial/cmdutil.py Sat May 01 15:00:21 2010 +0300
+++ b/mercurial/cmdutil.py Sat May 01 18:39:40 2010 -0400
@@ -396,6 +396,12 @@
if after:
if not exists:
+ if rename:
+ ui.warn(_('%s: not recording move - %s does not exist\n') %
+ (relsrc, reltarget))
+ else:
+ ui.warn(_('%s: not recording copy - %s does not exist\n') %
+ (relsrc, reltarget))
return
elif not dryrun:
try:
--- a/tests/test-copy2 Sat May 01 15:00:21 2010 +0300
+++ b/tests/test-copy2 Sat May 01 18:39:40 2010 -0400
@@ -19,6 +19,9 @@
hg st -A
hg commit -m1
+echo "# copy --after to a nonexistant target filename"
+hg cp -A foo dummy
+
echo "# dry-run; should show that foo is clean"
hg copy --dry-run foo bar
hg st -A
--- a/tests/test-copy2.out Sat May 01 15:00:21 2010 +0300
+++ b/tests/test-copy2.out Sat May 01 18:39:40 2010 -0400
@@ -11,6 +11,8 @@
# should print a warning that this is not a real copy; foo is added
bar has not been committed yet, so no copy data will be stored for foo.
A foo
+# copy --after to a nonexistant target filename
+foo: not recording copy - dummy does not exist
# dry-run; should show that foo is clean
C foo
# should show copy
--- a/tests/test-rename Sat May 01 15:00:21 2010 +0300
+++ b/tests/test-rename Sat May 01 18:39:40 2010 -0400
@@ -23,6 +23,9 @@
hg update -C
rm d2/c
+echo "# rename --after a single file to a nonexistant target filename"
+hg rename --after d1/a dummy
+
echo "# move a single file to an existing directory"
hg rename d1/d11/a1 d2
hg status -C
--- a/tests/test-rename.out Sat May 01 15:00:21 2010 +0300
+++ b/tests/test-rename.out Sat May 01 18:39:40 2010 -0400
@@ -8,6 +8,8 @@
d1/d11/a1
R d1/d11/a1
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+# rename --after a single file to a nonexistant target filename
+d1/a: not recording move - dummy does not exist
# move a single file to an existing directory
A d2/a1
d1/d11/a1
@@ -170,6 +172,8 @@
4 files updated, 0 files merged, 0 files removed, 0 files unresolved
# move --after some files under d1 to d2/d21 (glob)
moving d1/a to d2/d21/a
+d1/b: not recording move - d2/d21/b does not exist
+d1/ba: not recording move - d2/d21/ba does not exist
moving d1/d11/a1 to d2/d21/a1
A d2/d21/a
d1/a