Mercurial > hg
comparison mercurial/util.py @ 4271:1eaa8d90c689
fix util.copyfile to deal with symlinks
author | Eric St-Jean <esj@wwd.ca> |
---|---|
date | Wed, 21 Mar 2007 23:20:56 -0400 |
parents | fe0fe0b4d73b |
children | 81402b2b294d |
comparison
equal
deleted
inserted
replaced
4270:29eb88bd5c8d | 4271:1eaa8d90c689 |
---|---|
612 except OSError: | 612 except OSError: |
613 pass | 613 pass |
614 | 614 |
615 def copyfile(src, dest): | 615 def copyfile(src, dest): |
616 "copy a file, preserving mode" | 616 "copy a file, preserving mode" |
617 try: | 617 if os.path.islink(src): |
618 shutil.copyfile(src, dest) | 618 try: |
619 shutil.copymode(src, dest) | 619 os.unlink(dest) |
620 except shutil.Error, inst: | 620 except: |
621 raise Abort(str(inst)) | 621 pass |
622 os.symlink(os.readlink(src), dest) | |
623 else: | |
624 try: | |
625 shutil.copyfile(src, dest) | |
626 shutil.copymode(src, dest) | |
627 except shutil.Error, inst: | |
628 raise Abort(str(inst)) | |
622 | 629 |
623 def copyfiles(src, dst, hardlink=None): | 630 def copyfiles(src, dst, hardlink=None): |
624 """Copy a directory tree using hardlinks if possible""" | 631 """Copy a directory tree using hardlinks if possible""" |
625 | 632 |
626 if hardlink is None: | 633 if hardlink is None: |