comparison mercurial/commands.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 ed9170ff791a
children bf66f7a1e3f8
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 os 9 import os
11 import re 10 import re
12 import sys 11 import sys
13 12
14 from .i18n import _ 13 from .i18n import _
6173 else: 6172 else:
6174 # backup pre-resolve (merge uses .orig for its own purposes) 6173 # backup pre-resolve (merge uses .orig for its own purposes)
6175 a = repo.wjoin(f) 6174 a = repo.wjoin(f)
6176 try: 6175 try:
6177 util.copyfile(a, a + b".resolve") 6176 util.copyfile(a, a + b".resolve")
6178 except (IOError, OSError) as inst: 6177 except FileNotFoundError:
6179 if inst.errno != errno.ENOENT: 6178 pass
6180 raise
6181 6179
6182 try: 6180 try:
6183 # preresolve file 6181 # preresolve file
6184 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')} 6182 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
6185 with ui.configoverride(overrides, b'resolve'): 6183 with ui.configoverride(overrides, b'resolve'):
6192 # replace filemerge's .orig file with our resolve file 6190 # replace filemerge's .orig file with our resolve file
6193 try: 6191 try:
6194 util.rename( 6192 util.rename(
6195 a + b".resolve", scmutil.backuppath(ui, repo, f) 6193 a + b".resolve", scmutil.backuppath(ui, repo, f)
6196 ) 6194 )
6197 except OSError as inst: 6195 except FileNotFoundError:
6198 if inst.errno != errno.ENOENT: 6196 pass
6199 raise
6200 6197
6201 if hasconflictmarkers: 6198 if hasconflictmarkers:
6202 ui.warn( 6199 ui.warn(
6203 _( 6200 _(
6204 b'warning: the following files still have conflict ' 6201 b'warning: the following files still have conflict '