comparison mercurial/util.py @ 31141:b4cd912d7704

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.
author Durham Goode <durham@fb.com>
date Thu, 02 Mar 2017 10:12:40 -0800
parents 3f8f53190d6a
children 7c877cbf30d6
comparison
equal deleted inserted replaced
31140:dc8996f855d9 31141:b4cd912d7704
1054 raise error.SignatureError 1054 raise error.SignatureError
1055 raise 1055 raise
1056 1056
1057 return check 1057 return check
1058 1058
1059 # Hardlinks are problematic on CIFS, do not allow hardlinks
1060 # until we find a way to work around it cleanly (issue4546).
1061 # This is a variable so extensions can opt-in to using them.
1062 allowhardlinks = False
1063
1059 def copyfile(src, dest, hardlink=False, copystat=False, checkambig=False): 1064 def copyfile(src, dest, hardlink=False, copystat=False, checkambig=False):
1060 '''copy a file, preserving mode and optionally other stat info like 1065 '''copy a file, preserving mode and optionally other stat info like
1061 atime/mtime 1066 atime/mtime
1062 1067
1063 checkambig argument is used with filestat, and is useful only if 1068 checkambig argument is used with filestat, and is useful only if
1070 oldstat = None 1075 oldstat = None
1071 if os.path.lexists(dest): 1076 if os.path.lexists(dest):
1072 if checkambig: 1077 if checkambig:
1073 oldstat = checkambig and filestat(dest) 1078 oldstat = checkambig and filestat(dest)
1074 unlink(dest) 1079 unlink(dest)
1075 # hardlinks are problematic on CIFS, quietly ignore this flag 1080 if allowhardlinks and hardlink:
1076 # until we find a way to work around it cleanly (issue4546)
1077 if False and hardlink:
1078 try: 1081 try:
1079 oslink(src, dest) 1082 oslink(src, dest)
1080 return 1083 return
1081 except (IOError, OSError): 1084 except (IOError, OSError):
1082 pass # fall back to normal copy 1085 pass # fall back to normal copy