Mercurial > public > mercurial-scm > hg-stable
diff mercurial/upgrade_utils/engine.py @ 49314:2e726c934fcd
py3: catch FileNotFoundError instead of checking errno == ENOENT
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Tue, 31 May 2022 22:50:01 +0200 |
parents | 6000f5b25c9b |
children | 1994842955db |
line wrap: on
line diff
--- a/mercurial/upgrade_utils/engine.py Tue May 31 21:16:17 2022 +0200 +++ b/mercurial/upgrade_utils/engine.py Tue May 31 22:50:01 2022 +0200 @@ -6,7 +6,6 @@ # GNU General Public License version 2 or any later version. -import errno import stat from ..i18n import _ @@ -646,11 +645,10 @@ util.copyfile( srcrepo.vfs.join(b'dirstate'), backupvfs.join(b'dirstate') ) - except (IOError, OSError) as e: + except FileNotFoundError: # The dirstate does not exist on an empty repo or a repo with no # revision checked out - if e.errno != errno.ENOENT: - raise + pass assert srcrepo.dirstate._use_dirstate_v2 == (old == b'v2') srcrepo.dirstate._map.preload() @@ -659,11 +657,10 @@ srcrepo.dirstate._dirty = True try: srcrepo.vfs.unlink(b'dirstate') - except (IOError, OSError) as e: + except FileNotFoundError: # The dirstate does not exist on an empty repo or a repo with no # revision checked out - if e.errno != errno.ENOENT: - raise + pass srcrepo.dirstate.write(None)