Mercurial > hg > mercurial-crew-with-dirclash
diff mercurial/util.py @ 3632:4cfb72bcb978
util: add copyfile function
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 13 Nov 2006 13:26:57 -0600 |
parents | 23f7d9621783 |
children | 48768b1ab23c |
line wrap: on
line diff
--- a/mercurial/util.py +++ b/mercurial/util.py @@ -460,6 +460,14 @@ def unlink(f): except OSError: pass +def copyfile(src, dest): + "copy a file, preserving mode" + try: + shutil.copyfile(src, dest) + shutil.copymode(src, dest) + except shutil.Error, inst: + raise util.Abort(str(inst)) + def copyfiles(src, dst, hardlink=None): """Copy a directory tree using hardlinks if possible"""