Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 3629:4cfb72bcb978
util: add copyfile function
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 13 Nov 2006 13:26:57 -0600 |
parents | 23f7d9621783 |
children | 48768b1ab23c |
comparison
equal
deleted
inserted
replaced
3628:dc3504af7722 | 3629:4cfb72bcb978 |
---|---|
458 try: | 458 try: |
459 os.removedirs(os.path.dirname(f)) | 459 os.removedirs(os.path.dirname(f)) |
460 except OSError: | 460 except OSError: |
461 pass | 461 pass |
462 | 462 |
463 def copyfile(src, dest): | |
464 "copy a file, preserving mode" | |
465 try: | |
466 shutil.copyfile(src, dest) | |
467 shutil.copymode(src, dest) | |
468 except shutil.Error, inst: | |
469 raise util.Abort(str(inst)) | |
470 | |
463 def copyfiles(src, dst, hardlink=None): | 471 def copyfiles(src, dst, hardlink=None): |
464 """Copy a directory tree using hardlinks if possible""" | 472 """Copy a directory tree using hardlinks if possible""" |
465 | 473 |
466 if hardlink is None: | 474 if hardlink is None: |
467 hardlink = (os.stat(src).st_dev == | 475 hardlink = (os.stat(src).st_dev == |