Patchwork util: add allowhardlinks module variable

login
register
mail settings
Submitter Durham Goode
Date March 2, 2017, 6:12 p.m.
Message ID <d52b0a72423f65b4f774.1488478351@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/18873/
State Superseded
Headers show

Comments

Durham Goode - March 2, 2017, 6:12 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1488476378 28800
#      Thu Mar 02 09:39:38 2017 -0800
# Node ID d52b0a72423f65b4f774d5b646474cdafd4a5cc0
# Parent  a8458fe51a9d155f1daeaffdcf503e674d4d4588
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.
Durham Goode - March 2, 2017, 6:14 p.m.
On 3/2/17 10:12 AM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1488476378 28800
> #      Thu Mar 02 09:39:38 2017 -0800
> # Node ID d52b0a72423f65b4f774d5b646474cdafd4a5cc0
> # Parent  a8458fe51a9d155f1daeaffdcf503e674d4d4588
> 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.

Sorry for the immediate V2.  I had uncommited working copy changes that 
I had forgotten to amend, so I had to send V2.

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1056,6 +1056,10 @@  def checksignature(func):
 
     return check
 
+# hardlinks are problematic on CIFS, quietly ignore this flag
+# until we find a way to work around it cleanly (issue4546)
+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 +1076,7 @@  def copyfile(src, dest, hardlink=False, 
         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