# HG changeset patch # User Mads Kiilerich # Date 1357775063 -3600 # Node ID 614f769e6aa71016266ffd49fc2bf8720d90d029 # Parent 297bf69966a01dfa0ddbd69e416678862584f05f util: copyfile: remove dest before copying This prevents spurious problems writing to locked files on Windows. diff -r 297bf69966a0 -r 614f769e6aa7 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: