diff hgext/share.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 7a50e1720f6d
line wrap: on
line diff
--- a/hgext/share.py	Tue May 31 21:16:17 2022 +0200
+++ b/hgext/share.py	Tue May 31 22:50:01 2022 +0200
@@ -66,7 +66,6 @@
 '''
 
 
-import errno
 from mercurial.i18n import _
 from mercurial import (
     bookmarks,
@@ -177,9 +176,7 @@
         return False
     try:
         shared = repo.vfs.read(b'shared').splitlines()
-    except IOError as inst:
-        if inst.errno != errno.ENOENT:
-            raise
+    except FileNotFoundError:
         return False
     return hg.sharedbookmarks in shared
 
@@ -199,9 +196,8 @@
                     # is up-to-date.
                     return fp
                 fp.close()
-            except IOError as inst:
-                if inst.errno != errno.ENOENT:
-                    raise
+            except FileNotFoundError:
+                pass
 
             # otherwise, we should read bookmarks from srcrepo,
             # because .hg/bookmarks in srcrepo might be already