diff mercurial/commands.py @ 1513:5c3b93b244aa

copy & rename don't overwrite unless --force is specified
author Robin Farine <robin.farine@terminus.org>
date Tue, 08 Nov 2005 10:35:09 -0800
parents 53ad6ee6ede4
children faf46d810a85
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Nov 08 10:35:05 2005 -0800
+++ b/mercurial/commands.py	Tue Nov 08 10:35:09 2005 -0800
@@ -803,10 +803,13 @@
     def copy(abssrc, relsrc, target, exact):
         abstarget = util.canonpath(repo.root, cwd, target)
         reltarget = util.pathto(cwd, abstarget)
-        if not opts['force'] and repo.dirstate.state(abstarget) not in 'a?':
-            ui.warn(_('%s: not overwriting - file already managed\n') %
-                    reltarget)
-            return
+        if os.path.exists(reltarget):
+            if opts['force']:
+                os.unlink(reltarget)
+            else:
+                ui.warn(_('%s: not overwriting - file exists\n') %
+                        reltarget)
+                return
         if ui.verbose or not exact:
             ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
         if not opts['after']: