comparison mercurial/util.py @ 31720:dea2a17cbfd0

hardlink: check directory's st_dev when copying files Previously, when copying a file, copyfiles will compare src's st_dev with dirname(dst)'s st_dev, to decide whether to enable hardlink or not. That could have issues on Linux's overlayfs, where stating directories could result in different st_dev from st_dev of stating files, even if both the directories and the files exist in the overlay's upperdir. This patch fixes it by checking dirname(src) instead. It's more consistent because we are checking directories for both src and dest. That fixes test-hardlinks.t running on common Docker setups.
author Jun Wu <quark@fb.com>
date Wed, 29 Mar 2017 12:37:03 -0700
parents 456efd1b51fd
children fe9b33bcec6a
comparison
equal deleted inserted replaced
31719:456efd1b51fd 31720:dea2a17cbfd0
1142 return progress(t, pos + num) 1142 return progress(t, pos + num)
1143 hardlink, n = copyfiles(srcname, dstname, hardlink, progress=nprog) 1143 hardlink, n = copyfiles(srcname, dstname, hardlink, progress=nprog)
1144 num += n 1144 num += n
1145 else: 1145 else:
1146 if hardlink is None: 1146 if hardlink is None:
1147 hardlink = (os.stat(src).st_dev == 1147 hardlink = (os.stat(os.path.dirname(src)).st_dev ==
1148 os.stat(os.path.dirname(dst)).st_dev) 1148 os.stat(os.path.dirname(dst)).st_dev)
1149 topic = gettopic() 1149 topic = gettopic()
1150 1150
1151 if hardlink: 1151 if hardlink:
1152 try: 1152 try: