Mercurial > hg
changeset 39698:f44187605315
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
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 12 Sep 2018 15:07:27 -0700 |
parents | 98ca9078807a |
children | 6f26417b71bb |
files | mercurial/localrepo.py mercurial/statichttprepo.py mercurial/store.py tests/test-fncache.t |
diffstat | 4 files changed, 16 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Wed Sep 12 15:05:51 2018 -0700 +++ b/mercurial/localrepo.py Wed Sep 12 15:07:27 2018 -0700 @@ -479,8 +479,8 @@ # The store has changed over time and the exact layout is dictated by # requirements. The store interface abstracts differences across all # of them. - store = storemod.store(requirements, storebasepath, - lambda base: vfsmod.vfs(base, cacheaudited=True)) + store = makestore(requirements, storebasepath, + lambda base: vfsmod.vfs(base, cacheaudited=True)) hgvfs.createmode = store.createmode @@ -567,6 +567,17 @@ b'sparse is not enabled; enable the ' b'"sparse" extensions to access')) +def makestore(requirements, path, vfstype): + """Construct a storage object for a repository.""" + if b'store' in requirements: + if b'fncache' in requirements: + return storemod.fncachestore(path, vfstype, + b'dotencode' in requirements) + + return storemod.encodedstore(path, vfstype) + + return storemod.basicstore(path, vfstype) + @interfaceutil.implementer(repository.completelocalrepository) class localrepository(object):
--- a/mercurial/statichttprepo.py Wed Sep 12 15:05:51 2018 -0700 +++ b/mercurial/statichttprepo.py Wed Sep 12 15:07:27 2018 -0700 @@ -19,7 +19,6 @@ manifest, namespaces, pathutil, - store, url, util, vfs as vfsmod, @@ -179,7 +178,7 @@ localrepo.ensurerequirementscompatible(ui, requirements) # setup store - self.store = store.store(requirements, self.path, vfsclass) + self.store = localrepo.makestore(requirements, self.path, vfsclass) self.spath = self.store.path self.svfs = self.store.opener self.sjoin = self.store.join
--- a/mercurial/store.py Wed Sep 12 15:05:51 2018 -0700 +++ b/mercurial/store.py Wed Sep 12 15:07:27 2018 -0700 @@ -585,10 +585,3 @@ if e.startswith(path) and self._exists(e): return True return False - -def store(requirements, path, vfstype): - if 'store' in requirements: - if 'fncache' in requirements: - return fncachestore(path, vfstype, 'dotencode' in requirements) - return encodedstore(path, vfstype) - return basicstore(path, vfstype)
--- a/tests/test-fncache.t Wed Sep 12 15:05:51 2018 -0700 +++ b/tests/test-fncache.t Wed Sep 12 15:07:27 2018 -0700 @@ -448,7 +448,7 @@ $ cat > fncacheloadwarn.py << EOF > from __future__ import absolute_import - > from mercurial import extensions, store + > from mercurial import extensions, localrepo > > def extsetup(ui): > def wrapstore(orig, requirements, *args): @@ -456,7 +456,7 @@ > if 'store' in requirements and 'fncache' in requirements: > instrumentfncachestore(store, ui) > return store - > extensions.wrapfunction(store, 'store', wrapstore) + > extensions.wrapfunction(localrepo, 'makestore', wrapstore) > > def instrumentfncachestore(fncachestore, ui): > class instrumentedfncache(type(fncachestore.fncache)):