util: copyfile: remove dest before copying
authorMads Kiilerich <mads@kiilerich.com>
Thu, 10 Jan 2013 00:44:23 +0100
changeset 18326 614f769e6aa7
parent 18325 297bf69966a0
child 18327 4aecdb91443c
util: copyfile: remove dest before copying This prevents spurious problems writing to locked files on Windows.
mercurial/util.py
--- a/mercurial/util.py	Tue Jan 15 01:05:11 2013 +0100
+++ b/mercurial/util.py	Thu Jan 10 00:44:23 2013 +0100
@@ -482,11 +482,9 @@
 
 def copyfile(src, dest):
     "copy a file, preserving mode and atime/mtime"
+    if os.path.lexists(dest):
+        unlink(dest)
     if os.path.islink(src):
-        try:
-            os.unlink(dest)
-        except OSError:
-            pass
         os.symlink(os.readlink(src), dest)
     else:
         try: