comparison mercurial/obsolete.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 227124098e14
children 360c156e1f81
comparison
equal deleted inserted replaced
49305:53e9422a9b45 49306:2e726c934fcd
67 comment associated with each format for details. 67 comment associated with each format for details.
68 68
69 """ 69 """
70 70
71 import binascii 71 import binascii
72 import errno
73 import struct 72 import struct
74 73
75 from .i18n import _ 74 from .i18n import _
76 from .pycompat import getattr 75 from .pycompat import getattr
77 from .node import ( 76 from .node import (
580 # to just peek at the file size. 579 # to just peek at the file size.
581 return len(self._data) > 1 580 return len(self._data) > 1
582 if not self._cached('_all'): 581 if not self._cached('_all'):
583 try: 582 try:
584 return self.svfs.stat(b'obsstore').st_size > 1 583 return self.svfs.stat(b'obsstore').st_size > 1
585 except OSError as inst: 584 except FileNotFoundError:
586 if inst.errno != errno.ENOENT:
587 raise
588 # just build an empty _all list if no obsstore exists, which 585 # just build an empty _all list if no obsstore exists, which
589 # avoids further stat() syscalls 586 # avoids further stat() syscalls
587 pass
590 return bool(self._all) 588 return bool(self._all)
591 589
592 __bool__ = __nonzero__ 590 __bool__ = __nonzero__
593 591
594 @property 592 @property