comparison mercurial/cmdutil.py @ 37088:08890706366e

copyfile: preserve stat info (mtime, etc.) when doing copies/renames Differential Revision: https://phab.mercurial-scm.org/D2729
author Kyle Lippincott <spectral@google.com>
date Thu, 08 Mar 2018 11:44:03 -0800
parents f0b6fbea00cf
children be3f33f5e232
comparison
equal deleted inserted replaced
37087:e4640ec346ac 37088:08890706366e
1190 if samefile: 1190 if samefile:
1191 tmp = target + "~hgrename" 1191 tmp = target + "~hgrename"
1192 os.rename(src, tmp) 1192 os.rename(src, tmp)
1193 os.rename(tmp, target) 1193 os.rename(tmp, target)
1194 else: 1194 else:
1195 util.copyfile(src, target) 1195 # Preserve stat info on renames, not on copies; this matches
1196 # Linux CLI behavior.
1197 util.copyfile(src, target, copystat=rename)
1196 srcexists = True 1198 srcexists = True
1197 except IOError as inst: 1199 except IOError as inst:
1198 if inst.errno == errno.ENOENT: 1200 if inst.errno == errno.ENOENT:
1199 ui.warn(_('%s: deleted in working directory\n') % relsrc) 1201 ui.warn(_('%s: deleted in working directory\n') % relsrc)
1200 srcexists = False 1202 srcexists = False