[PATCH] hardlink: check directory's st_dev instead of files
Jun Wu
quark at fb.com
Sat Mar 25 20:58:33 UTC 2017
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1490475382 25200
# Sat Mar 25 13:56:22 2017 -0700
# Node ID b288a611eff957d3f03b06c419c16721f4fb5016
# Parent c60091fa1426892552dd6c0dd4b9c49e3c3da045
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r b288a611eff9
hardlink: check directory's st_dev instead of files
Previously, 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 files, even if both the directories and the
files exist in the overlay's upperdir.
This patch fixes it by checking dirname(src) instead. That fixes
test-hardlinks.t running on common Docker environment.
The "copyfiles" seems to need some extra cleanups, for example, the
"hardlink" check should only happen if it's copying a file, not a directory.
That cleanup will be done later.
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1125,5 +1125,5 @@ def copyfiles(src, dst, hardlink=None, p
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)
if hardlink:
More information about the Mercurial-devel
mailing list