[PATCH] transaction: enable hardlink backups for non-windows systems

Jeroen Vaelen jeroen at fb.com
Tue Feb 14 09:31:02 UTC 2017


# HG changeset patch
# User Jeroen Vaelen <jeroen at fb.com>
# Date 1487064458 28800
#      Tue Feb 14 01:27:38 2017 -0800
# Node ID c7fb7ac39a12c8683518bb7db7e1a93346e017e0
# Parent  a0e3d808690d57d1c9dff840e0b8ee099526397b
transaction: enable hardlink backups for non-windows systems

07a92bbd02e5 disabled hardlink backups entirely because they can cause trouble
with CIFS on Windows (see issue 4546). This changeset limits that restriction
to Windows systems. Ideally we check for CIFS, because e.g. NTFS does support
hardlinks. But this at least gives us cheaper transactional backups for posix,
which is a step forward.

Note: the test changes were originally introduced in 07a92bbd02e5.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1084,9 +1084,9 @@
         if checkambig:
             oldstat = checkambig and filestat(dest)
         unlink(dest)
-    # hardlinks are problematic on CIFS, quietly ignore this flag
-    # until we find a way to work around it cleanly (issue4546)
-    if False and hardlink:
+    # quietly ignore the hardlink flag on Windows due to CIFS limitations
+    # (see discussion on issue 4546)
+    if hardlink and pycompat.osname != 'nt':
         try:
             oslink(src, dest)
             return
diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t
--- a/tests/test-hardlinks.t
+++ b/tests/test-hardlinks.t
@@ -166,7 +166,7 @@
   1 r2/.hg/store/00manifest.i
   1 r2/.hg/store/data/d1/f2.i
   2 r2/.hg/store/data/f1.i
-  1 r2/.hg/store/fncache
+  2 r2/.hg/store/fncache
 
   $ hg -R r2 verify
   checking changesets
@@ -191,7 +191,7 @@
   1 r2/.hg/store/00manifest.i
   1 r2/.hg/store/data/d1/f2.i
   1 r2/.hg/store/data/f1.i
-  1 r2/.hg/store/fncache
+  2 r2/.hg/store/fncache
 
 
   $ cd r3


More information about the Mercurial-devel mailing list