comparison mercurial/txnutil.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
comparison
equal deleted inserted replaced
49313:53e9422a9b45 49314:2e726c934fcd
3 # Copyright FUJIWARA Katsunori <foozy@lares.dti.ne.jp> and others 3 # Copyright FUJIWARA Katsunori <foozy@lares.dti.ne.jp> and others
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
9 import errno
10 8
11 from . import encoding 9 from . import encoding
12 10
13 11
14 def mayhavepending(root): 12 def mayhavepending(root):
27 This returns '(fp, is_pending_opened)' tuple. 25 This returns '(fp, is_pending_opened)' tuple.
28 """ 26 """
29 if mayhavepending(root): 27 if mayhavepending(root):
30 try: 28 try:
31 return (vfs(b'%s.pending' % filename, **kwargs), True) 29 return (vfs(b'%s.pending' % filename, **kwargs), True)
32 except IOError as inst: 30 except FileNotFoundError:
33 if inst.errno != errno.ENOENT: 31 pass
34 raise
35 return (vfs(filename, **kwargs), False) 32 return (vfs(filename, **kwargs), False)