localrepo: use boolean in opener options
Not sure why we're using an integer for a flag value here. I'm
pretty sure nothing relies on values being 1.
While we're here, convert to a dict comprehension.
Differential Revision: https://phab.mercurial-scm.org/D4575
localrepo: move store() from store module
I want logic related to requirements handling to be in the localrepo
module so it is all in one place.
I would have loved to inline this logic. Unfortunately, statichttprepo
also calls it. I didn't want to inline it twice. We could potentially
refactor statichttppeer. But meh.
Differential Revision: https://phab.mercurial-scm.org/D4574
localrepo: resolve store and cachevfs in makelocalrepository()
This is mostly a code move and refactor.
One change is that we now explicitly look for requirements indicating
a share is being used rather than blindly try to read from
.hg/sharedpath. Requirements *should* be all that is necessary to
dictate high-level behavior and I'm not sure why the previous code
was doing what it was.
The previous code has been in place since
87d1fd40f57e (authored in
2009). And the commit immediately after that (
971e38a9344b) introduced
``hg.share()`` and always wrote the ``shared`` requirement. And as far
as I can tell, every revision of ``hg.share()`` since has written
either the ``shared`` or ``relshared`` requirement. So I'm pretty
sure we don't need to maintain BC by always looking for and honoring
the ``.hg/sharedpath`` file even if a requirement isn't present.
.. bc::
A repository will no longer use shared storage if it has a
``.hg/sharedpath`` file but no entry in ``.hg/requires`` saying it
is shared.
This change should not have any end-user impact, as all shared
repos should have a ``.hg/requires`` file indicating this.
Differential Revision: https://phab.mercurial-scm.org/D4573
localrepo: document and test bug around opening shared repos
As part of refactoring this code, I realized that we don't
validate the requirements of a shared repository. This commit
documents that next to the requirements validation code and adds a
test demonstrating the buggy behavior.
I'm not sure if I'll fix this. But it is definitely a bug that
users could encounter, as LFS, narrow, and potentially other
extensions dynamically add requirements on first use. One part
of this I'm not sure about is how to handle loading the .hg/hgrc
of the shared repo. We need to do that in order to load extensions.
But we don't want that repo's hgrc to overwrite the current repo's.
Differential Revision: https://phab.mercurial-scm.org/D4572
localrepo: move requirements reasonability testing to own function
Just because we know how to handle each listed requirement doesn't
mean that set of requirements is reasonable.
This commit introduces an extension-wrappable function to validate
that a set of requirements makes sense.
We could combine this with ensurerequirementsrecognized(). But I think
having a line between basic membership testing and compatibility
checking is more powerful as it will help differentiate between
missing support and buggy behavior.
Differential Revision: https://phab.mercurial-scm.org/D4571
statichttprepo: use new functions for requirements validation
The new code in localrepo for requirements gathering and validation
is more robust than scmutil.readrequires(). Let's port statichttprepo
to it.
Since scmutil.readrequires() is no longer used, it has been removed.
It is possible extensions were monkeypatching this to supplement the
set of supported requirements. But the proper way to do that is to
register a featuresetupfuncs. I'm comfortable forcing the API break
because featuresetupfuncs is more robust and has been supported for
a while.
.. api::
``scmutil.readrequires()`` has been removed.
Use ``localrepo.featuresetupfuncs`` to register new repository
requirements.
Use ``localrepo.ensurerequirementsrecognized()`` to validate them.
Differential Revision: https://phab.mercurial-scm.org/D4570