Mercurial > public > mercurial-scm > hg-stable
diff mercurial/util.py @ 27391:4eeef1b2d689
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 16 Dec 2015 17:40:01 -0600 |
parents | 45d996a566d7 c48ecc0b5bc9 |
children | 6cd3044985c2 |
line wrap: on
line diff
--- a/mercurial/util.py Tue Dec 15 07:57:04 2015 +0000 +++ b/mercurial/util.py Wed Dec 16 17:40:01 2015 -0600 @@ -990,8 +990,9 @@ return check -def copyfile(src, dest, hardlink=False): - "copy a file, preserving mode and atime/mtime" +def copyfile(src, dest, hardlink=False, copystat=False): + '''copy a file, preserving mode and optionally other stat info like + atime/mtime''' if os.path.lexists(dest): unlink(dest) # hardlinks are problematic on CIFS, quietly ignore this flag @@ -1004,10 +1005,16 @@ pass # fall back to normal copy if os.path.islink(src): os.symlink(os.readlink(src), dest) + # copytime is ignored for symlinks, but in general copytime isn't needed + # for them anyway else: try: shutil.copyfile(src, dest) - shutil.copymode(src, dest) + if copystat: + # copystat also copies mode + shutil.copystat(src, dest) + else: + shutil.copymode(src, dest) except shutil.Error as inst: raise Abort(str(inst))