requires: re-use vfs.tryread for simplicity
authorJason R. Coombs <jaraco@jaraco.com>
Wed, 07 Sep 2022 14:56:45 -0400
changeset 49493 4367c46a89ee
parent 49491 c6a1beba27e9
child 49494 c96ed4029fda
requires: re-use vfs.tryread for simplicity Avoids calling `set` twice or having to re-raise an exception and implements the routine with a single return expression.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Tue Aug 30 15:29:55 2022 -0400
+++ b/mercurial/localrepo.py	Wed Sep 07 14:56:45 2022 -0400
@@ -522,12 +522,8 @@
     # the repository. This file was introduced in Mercurial 0.9.2,
     # which means very old repositories may not have one. We assume
     # a missing file translates to no requirements.
-    try:
-        return set(vfs.read(b'requires').splitlines())
-    except FileNotFoundError:
-        if not allowmissing:
-            raise
-        return set()
+    read = vfs.tryread if allowmissing else vfs.read
+    return set(read(b'requires').splitlines())
 
 
 def makelocalrepository(baseui, path, intents=None):