mercurial/localrepo.py
changeset 49306 2e726c934fcd
parent 49284 d44e3c45f0e4
child 49313 5c01ca5f9f1e
--- a/mercurial/localrepo.py	Tue May 31 21:16:17 2022 +0200
+++ b/mercurial/localrepo.py	Tue May 31 22:50:01 2022 +0200
@@ -7,7 +7,6 @@
 # GNU General Public License version 2 or any later version.
 
 
-import errno
 import functools
 import os
 import random
@@ -517,7 +516,7 @@
     """reads the require file present at root of this vfs
     and return a set of requirements
 
-    If allowmissing is True, we suppress ENOENT if raised"""
+    If allowmissing is True, we suppress FileNotFoundError if raised"""
     # requires file contains a newline-delimited list of
     # features/capabilities the opener (us) must have in order to use
     # the repository. This file was introduced in Mercurial 0.9.2,
@@ -525,8 +524,8 @@
     # a missing file translates to no requirements.
     try:
         requirements = set(vfs.read(b'requires').splitlines())
-    except IOError as e:
-        if not (allowmissing and e.errno == errno.ENOENT):
+    except FileNotFoundError:
+        if not allowmissing:
             raise
         requirements = set()
     return requirements
@@ -583,9 +582,8 @@
     if not hgvfs.isdir():
         try:
             hgvfs.stat()
-        except OSError as e:
-            if e.errno != errno.ENOENT:
-                raise
+        except FileNotFoundError:
+            pass
         except ValueError as e:
             # Can be raised on Python 3.8 when path is invalid.
             raise error.Abort(
@@ -3503,9 +3501,8 @@
             vfs.tryunlink(dest)
             try:
                 vfs.rename(src, dest)
-            except OSError as exc:  # journal file does not yet exist
-                if exc.errno != errno.ENOENT:
-                    raise
+            except FileNotFoundError:  # journal file does not yet exist
+                pass
 
     return a