mercurial/util.py
changeset 23899 4e451d1359de
parent 23864 6c44cef5baa2
child 23917 3cbb5bf4035d
equal deleted inserted replaced
23898:b21c2e0ee8a3 23899:4e451d1359de
   714                 raise error.SignatureError
   714                 raise error.SignatureError
   715             raise
   715             raise
   716 
   716 
   717     return check
   717     return check
   718 
   718 
   719 def copyfile(src, dest):
   719 def copyfile(src, dest, hardlink=False):
   720     "copy a file, preserving mode and atime/mtime"
   720     "copy a file, preserving mode and atime/mtime"
   721     if os.path.lexists(dest):
   721     if os.path.lexists(dest):
   722         unlink(dest)
   722         unlink(dest)
       
   723     if hardlink:
       
   724         try:
       
   725             oslink(src, dest)
       
   726             return
       
   727         except (IOError, OSError):
       
   728             pass # fall back to normal copy
   723     if os.path.islink(src):
   729     if os.path.islink(src):
   724         os.symlink(os.readlink(src), dest)
   730         os.symlink(os.readlink(src), dest)
   725     else:
   731     else:
   726         try:
   732         try:
   727             shutil.copyfile(src, dest)
   733             shutil.copyfile(src, dest)