Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 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 | 9b841267253c |
children | d756fc11cfb9 |
comparison
equal
deleted
inserted
replaced
47416:1c7f3d911d0f | 47417:9ea525216edb |
---|---|
2007 settopic() | 2007 settopic() |
2008 | 2008 |
2009 if hardlink: | 2009 if hardlink: |
2010 try: | 2010 try: |
2011 oslink(src, dst) | 2011 oslink(src, dst) |
2012 except (IOError, OSError): | 2012 except (IOError, OSError) as exc: |
2013 hardlink = False | 2013 if exc.errno != errno.EEXIST: |
2014 hardlink = False | |
2015 # XXX maybe try to relink if the file exist ? | |
2014 shutil.copy(src, dst) | 2016 shutil.copy(src, dst) |
2015 else: | 2017 else: |
2016 shutil.copy(src, dst) | 2018 shutil.copy(src, dst) |
2017 num += 1 | 2019 num += 1 |
2018 if progress: | 2020 if progress: |