comparison mercurial/localrepo.py @ 49493:4367c46a89ee

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.
author Jason R. Coombs <jaraco@jaraco.com>
date Wed, 07 Sep 2022 14:56:45 -0400
parents f59e49f6bee4
children bc2ecf08ae04 8fa3f7c3a9ad
comparison
equal deleted inserted replaced
49491:c6a1beba27e9 49493:4367c46a89ee
520 # requires file contains a newline-delimited list of 520 # requires file contains a newline-delimited list of
521 # features/capabilities the opener (us) must have in order to use 521 # features/capabilities the opener (us) must have in order to use
522 # the repository. This file was introduced in Mercurial 0.9.2, 522 # the repository. This file was introduced in Mercurial 0.9.2,
523 # which means very old repositories may not have one. We assume 523 # which means very old repositories may not have one. We assume
524 # a missing file translates to no requirements. 524 # a missing file translates to no requirements.
525 try: 525 read = vfs.tryread if allowmissing else vfs.read
526 return set(vfs.read(b'requires').splitlines()) 526 return set(read(b'requires').splitlines())
527 except FileNotFoundError:
528 if not allowmissing:
529 raise
530 return set()
531 527
532 528
533 def makelocalrepository(baseui, path, intents=None): 529 def makelocalrepository(baseui, path, intents=None):
534 """Create a local repository object. 530 """Create a local repository object.
535 531