Make copy --after work for files that have been hg added.
authorBrendan Cully <brendan@kublai.com>
Tue, 24 Apr 2007 18:43:18 -0700
changeset 4374 de612b5f8d59
parent 4373 109077e7048d
child 4376 4759da3e4dc8
child 4379 f4af7960d578
Make copy --after work for files that have been hg added.
mercurial/commands.py
tests/test-copy2
tests/test-copy2.out
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -503,7 +503,7 @@ def docopy(ui, repo, pats, opts, wlock):
                      util.localpath(prevsrc)))
             return
         if (not opts['after'] and os.path.exists(reltarget) or
-            opts['after'] and repo.dirstate.state(abstarget) not in '?r'):
+            opts['after'] and repo.dirstate.state(abstarget) not in '?ar'):
             if not opts['force']:
                 ui.warn(_('%s: not overwriting - file exists\n') %
                         reltarget)
--- a/tests/test-copy2
+++ b/tests/test-copy2
@@ -38,4 +38,10 @@ hg debugrename bar
 echo "# should show no copies"
 hg debugstate|grep '^copy'
 
+echo "# copy --after on an added file"
+cp bar baz
+hg add baz
+hg cp -A bar baz
+hg st -C
+
 exit 0
--- a/tests/test-copy2.out
+++ b/tests/test-copy2.out
@@ -20,3 +20,6 @@ copy: foo -> bar
      1         5       7      1       2 dd12c926cf16 2ed2a3912a0b 000000000000
 bar renamed from foo:dd12c926cf165e3eb4cf87b084955cb617221c17
 # should show no copies
+# copy --after on an added file
+A baz
+  bar