# HG changeset patch # User Durham Goode # Date 1488478360 28800 # Node ID b4cd912d7704cd976e1bee3a3c927e0e578ec88f # Parent dc8996f855d99c718e06957de0ccae006767ef81 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. diff -r dc8996f855d9 -r b4cd912d7704 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