util: add allowhardlinks module variable
authorDurham Goode <durham@fb.com>
Thu, 02 Mar 2017 10:12:40 -0800
changeset 31141 b4cd912d7704
parent 31140 dc8996f855d9
child 31142 408dcf7475a7
util: add allowhardlinks module variable To enable extensions to enable hardlinks for certain environments, let's move the 'if False' to be an 'if allowhardlinks' and let extensions modify the allowhardlinks variable. Tests on linux ext4 pass with it set to True and to False.
mercurial/util.py
--- a/mercurial/util.py	Thu Mar 02 20:30:56 2017 -0500
+++ b/mercurial/util.py	Thu Mar 02 10:12:40 2017 -0800
@@ -1056,6 +1056,11 @@
 
     return check
 
+# Hardlinks are problematic on CIFS, do not allow hardlinks
+# until we find a way to work around it cleanly (issue4546).
+# This is a variable so extensions can opt-in to using them.
+allowhardlinks = False
+
 def copyfile(src, dest, hardlink=False, copystat=False, checkambig=False):
     '''copy a file, preserving mode and optionally other stat info like
     atime/mtime
@@ -1072,9 +1077,7 @@
         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:
+    if allowhardlinks and hardlink:
         try:
             oslink(src, dest)
             return