mercurial/cmdutil.py
changeset 14518 a67e866f46f9
parent 14442 5b48ad1e7f1a
child 14635 217b7d83afc3
--- a/mercurial/cmdutil.py	Thu Jun 02 19:43:17 2011 +0200
+++ b/mercurial/cmdutil.py	Thu Jun 02 00:33:33 2011 +0200
@@ -281,9 +281,11 @@
                 if not os.path.isdir(targetdir):
                     os.makedirs(targetdir)
                 util.copyfile(src, target)
+                srcexists = True
             except IOError, inst:
                 if inst.errno == errno.ENOENT:
                     ui.warn(_('%s: deleted in working copy\n') % relsrc)
+                    srcexists = False
                 else:
                     ui.warn(_('%s: cannot copy - %s\n') %
                             (relsrc, inst.strerror))
@@ -301,7 +303,9 @@
         scmutil.dirstatecopy(ui, repo, wctx, abssrc, abstarget,
                              dryrun=dryrun, cwd=cwd)
         if rename and not dryrun:
-            wctx.remove([abssrc], not after)
+            if not after and srcexists:
+                util.unlinkpath(repo.wjoin(abssrc))
+            wctx.forget([abssrc])
 
     # pat: ossep
     # dest ossep