Mercurial > public > mercurial-scm > hg
comparison mercurial/upgrade_utils/engine.py @ 49306: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 |
comparison
equal
deleted
inserted
replaced
49305:53e9422a9b45 | 49306:2e726c934fcd |
---|---|
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 | 8 |
9 import errno | |
10 import stat | 9 import stat |
11 | 10 |
12 from ..i18n import _ | 11 from ..i18n import _ |
13 from ..pycompat import getattr | 12 from ..pycompat import getattr |
14 from .. import ( | 13 from .. import ( |
644 ) | 643 ) |
645 try: | 644 try: |
646 util.copyfile( | 645 util.copyfile( |
647 srcrepo.vfs.join(b'dirstate'), backupvfs.join(b'dirstate') | 646 srcrepo.vfs.join(b'dirstate'), backupvfs.join(b'dirstate') |
648 ) | 647 ) |
649 except (IOError, OSError) as e: | 648 except FileNotFoundError: |
650 # The dirstate does not exist on an empty repo or a repo with no | 649 # The dirstate does not exist on an empty repo or a repo with no |
651 # revision checked out | 650 # revision checked out |
652 if e.errno != errno.ENOENT: | 651 pass |
653 raise | |
654 | 652 |
655 assert srcrepo.dirstate._use_dirstate_v2 == (old == b'v2') | 653 assert srcrepo.dirstate._use_dirstate_v2 == (old == b'v2') |
656 srcrepo.dirstate._map.preload() | 654 srcrepo.dirstate._map.preload() |
657 srcrepo.dirstate._use_dirstate_v2 = new == b'v2' | 655 srcrepo.dirstate._use_dirstate_v2 = new == b'v2' |
658 srcrepo.dirstate._map._use_dirstate_v2 = srcrepo.dirstate._use_dirstate_v2 | 656 srcrepo.dirstate._map._use_dirstate_v2 = srcrepo.dirstate._use_dirstate_v2 |
659 srcrepo.dirstate._dirty = True | 657 srcrepo.dirstate._dirty = True |
660 try: | 658 try: |
661 srcrepo.vfs.unlink(b'dirstate') | 659 srcrepo.vfs.unlink(b'dirstate') |
662 except (IOError, OSError) as e: | 660 except FileNotFoundError: |
663 # The dirstate does not exist on an empty repo or a repo with no | 661 # The dirstate does not exist on an empty repo or a repo with no |
664 # revision checked out | 662 # revision checked out |
665 if e.errno != errno.ENOENT: | 663 pass |
666 raise | |
667 | 664 |
668 srcrepo.dirstate.write(None) | 665 srcrepo.dirstate.write(None) |
669 | 666 |
670 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) | 667 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) |
671 | 668 |