changeset 18326:614f769e6aa7

util: copyfile: remove dest before copying This prevents spurious problems writing to locked files on Windows.
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 10 Jan 2013 00:44:23 +0100
parents 297bf69966a0
children 4aecdb91443c
files mercurial/util.py
diffstat 1 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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: