[PATCH V2] util: add allowhardlinks module variable

Ryan McElroy rm at fb.com
Sun Mar 12 01:37:58 EST 2017



On 3/2/17 5:31 PM, Augie Fackler wrote:
> On Thu, Mar 02, 2017 at 10:12:51AM -0800, Durham Goode wrote:
>> # HG changeset patch
>> # User Durham Goode <durham at fb.com>
>> # Date 1488478360 28800
>> #      Thu Mar 02 10:12:40 2017 -0800
>> # Node ID 32c17aa5fc546a112b355e734fb71b740172cf09
>> # Parent  a8458fe51a9d155f1daeaffdcf503e674d4d4588
>> util: add allowhardlinks module variable
> Queued, thanks.

Late to the party here, but why not do this as a config option so one 
doesn't need an extension to override this?

>
>> 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.
>>
>> diff --git a/mercurial/util.py b/mercurial/util.py
>> --- a/mercurial/util.py
>> +++ b/mercurial/util.py
>> @@ -1056,6 +1056,11 @@ def checksignature(func):
>>
>>       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 @@ 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
>>



More information about the Mercurial-devel mailing list