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.
--- 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):