[Updated] [+- ] D8764: localrepo: deduplicate code around reading requires file
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Sat Aug 1 14:38:21 UTC 2020
pulkit updated this revision to Diff 22172.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8764?vs=22069&id=22172
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8764/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8764
AFFECTED FILES
mercurial/localrepo.py
CHANGE DETAILS
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -464,6 +464,16 @@
featuresetupfuncs = set()
+def _readrequires(vfs):
+ try:
+ requirements = set(vfs.read(b'requires').splitlines())
+ except IOError as e:
+ if e.errno != errno.ENOENT:
+ raise
+ requirements = set()
+ return requirements
+
+
def makelocalrepository(baseui, path, intents=None):
"""Create a local repository object.
@@ -527,12 +537,7 @@
# 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:
- requirements = set(hgvfs.read(b'requires').splitlines())
- except IOError as e:
- if e.errno != errno.ENOENT:
- raise
- requirements = set()
+ requirements = _readrequires(hgvfs)
# if .hg/requires contains the sharesafe requirement, it means
# there exists a `.hg/store/requires` too and we should read it
@@ -545,12 +550,7 @@
storevfs = vfsmod.vfs(vfsmod.vfs(sharedpath).join(b'store'))
else:
storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
- try:
- store_requirements = set(storevfs.read(b'requires').splitlines())
- requirements |= store_requirements
- except IOError as e:
- if e.errno != errno.ENOENT:
- raise
+ requirements |= _readrequires(storevfs)
# The .hg/hgrc file may load extensions or contain config options
# that influence repository construction. Attempt to load it and
To: pulkit, #hg-reviewers, marmoute
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200801/48f4d3c5/attachment.html>
More information about the Mercurial-patches
mailing list