Mercurial > hg
changeset 47417:9ea525216edb
copyfiles: deal with existing file when hardlinking
If the hardlinking fails, we fallback to `shutil.copy`, but do not consider
future hardlinking doomed.
This is a slight improvement from the current situation, we still avoid
hardliking in a case we might be able to do it. However this does not have an
impact of the rest of the operation.
(This is an opportunity improvement while looking at something next to that.)
Differential Revision: https://phab.mercurial-scm.org/D10841
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 07 Jun 2021 21:09:31 +0200 |
parents | 1c7f3d911d0f |
children | 22e21deed474 |
files | mercurial/util.py |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Tue Jun 08 03:40:36 2021 +0200 +++ b/mercurial/util.py Mon Jun 07 21:09:31 2021 +0200 @@ -2009,8 +2009,10 @@ if hardlink: try: oslink(src, dst) - except (IOError, OSError): - hardlink = False + except (IOError, OSError) as exc: + if exc.errno != errno.EEXIST: + hardlink = False + # XXX maybe try to relink if the file exist ? shutil.copy(src, dst) else: shutil.copy(src, dst)