Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 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 | ddc0323db78b |
children | ae60735e37d2 |
comparison
equal
deleted
inserted
replaced
18325:297bf69966a0 | 18326:614f769e6aa7 |
---|---|
480 | 480 |
481 return check | 481 return check |
482 | 482 |
483 def copyfile(src, dest): | 483 def copyfile(src, dest): |
484 "copy a file, preserving mode and atime/mtime" | 484 "copy a file, preserving mode and atime/mtime" |
485 if os.path.lexists(dest): | |
486 unlink(dest) | |
485 if os.path.islink(src): | 487 if os.path.islink(src): |
486 try: | |
487 os.unlink(dest) | |
488 except OSError: | |
489 pass | |
490 os.symlink(os.readlink(src), dest) | 488 os.symlink(os.readlink(src), dest) |
491 else: | 489 else: |
492 try: | 490 try: |
493 shutil.copyfile(src, dest) | 491 shutil.copyfile(src, dest) |
494 shutil.copymode(src, dest) | 492 shutil.copymode(src, dest) |