# HG changeset patch # User Jun Wu # Date 2017-03-29 19:37:03 # Node ID dea2a17cbfd00bf08ee87b3e44b1c71499189f89 # Parent 456efd1b51fd3fa1ea36a3defb536577fb1cb05e 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. diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1144,7 +1144,7 @@ def copyfiles(src, dst, hardlink=None, p num += n else: if hardlink is None: - hardlink = (os.stat(src).st_dev == + hardlink = (os.stat(os.path.dirname(src)).st_dev == os.stat(os.path.dirname(dst)).st_dev) topic = gettopic()