Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 47452:09ff5d532a25
copyfiles: add a way to relax the file system checking for hardlink
This is critical for transaction file, less for hardlink/copy clone as we are
about to do. Since `pure` build does not have a `getfstype` implementation this
would disable hardlink clone for all pure build. So we add a parameter to
control that extra check.
Differential Revision: https://phab.mercurial-scm.org/D10854
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 09 Jun 2021 15:33:58 +0200 |
parents | d756fc11cfb9 |
children | bb917eea1605 |
comparison
equal
deleted
inserted
replaced
47451:d756fc11cfb9 | 47452:09ff5d532a25 |
---|---|
1915 hardlink=False, | 1915 hardlink=False, |
1916 copystat=False, | 1916 copystat=False, |
1917 checkambig=False, | 1917 checkambig=False, |
1918 nb_bytes=None, | 1918 nb_bytes=None, |
1919 no_hardlink_cb=None, | 1919 no_hardlink_cb=None, |
1920 check_fs_hardlink=True, | |
1920 ): | 1921 ): |
1921 """copy a file, preserving mode and optionally other stat info like | 1922 """copy a file, preserving mode and optionally other stat info like |
1922 atime/mtime | 1923 atime/mtime |
1923 | 1924 |
1924 checkambig argument is used with filestat, and is useful only if | 1925 checkambig argument is used with filestat, and is useful only if |
1933 oldstat = None | 1934 oldstat = None |
1934 if os.path.lexists(dest): | 1935 if os.path.lexists(dest): |
1935 if checkambig: | 1936 if checkambig: |
1936 oldstat = checkambig and filestat.frompath(dest) | 1937 oldstat = checkambig and filestat.frompath(dest) |
1937 unlink(dest) | 1938 unlink(dest) |
1938 if hardlink: | 1939 if hardlink and check_fs_hardlink: |
1939 # Hardlinks are problematic on CIFS (issue4546), do not allow hardlinks | 1940 # Hardlinks are problematic on CIFS (issue4546), do not allow hardlinks |
1940 # unless we are confident that dest is on a whitelisted filesystem. | 1941 # unless we are confident that dest is on a whitelisted filesystem. |
1941 try: | 1942 try: |
1942 fstype = getfstype(os.path.dirname(dest)) | 1943 fstype = getfstype(os.path.dirname(dest)) |
1943 except OSError: | 1944 except OSError: |