comparison mercurial/localrepo.py @ 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
comparison
equal deleted inserted replaced
39697:98ca9078807a 39698:f44187605315
477 cachepath = hgvfs.join(b'cache') 477 cachepath = hgvfs.join(b'cache')
478 478
479 # The store has changed over time and the exact layout is dictated by 479 # The store has changed over time and the exact layout is dictated by
480 # requirements. The store interface abstracts differences across all 480 # requirements. The store interface abstracts differences across all
481 # of them. 481 # of them.
482 store = storemod.store(requirements, storebasepath, 482 store = makestore(requirements, storebasepath,
483 lambda base: vfsmod.vfs(base, cacheaudited=True)) 483 lambda base: vfsmod.vfs(base, cacheaudited=True))
484 484
485 hgvfs.createmode = store.createmode 485 hgvfs.createmode = store.createmode
486 486
487 # The cache vfs is used to manage cache files. 487 # The cache vfs is used to manage cache files.
488 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True) 488 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
564 """ 564 """
565 if b'exp-sparse' in requirements and not sparse.enabled: 565 if b'exp-sparse' in requirements and not sparse.enabled:
566 raise error.RepoError(_(b'repository is using sparse feature but ' 566 raise error.RepoError(_(b'repository is using sparse feature but '
567 b'sparse is not enabled; enable the ' 567 b'sparse is not enabled; enable the '
568 b'"sparse" extensions to access')) 568 b'"sparse" extensions to access'))
569
570 def makestore(requirements, path, vfstype):
571 """Construct a storage object for a repository."""
572 if b'store' in requirements:
573 if b'fncache' in requirements:
574 return storemod.fncachestore(path, vfstype,
575 b'dotencode' in requirements)
576
577 return storemod.encodedstore(path, vfstype)
578
579 return storemod.basicstore(path, vfstype)
569 580
570 @interfaceutil.implementer(repository.completelocalrepository) 581 @interfaceutil.implementer(repository.completelocalrepository)
571 class localrepository(object): 582 class localrepository(object):
572 583
573 # obsolete experimental requirements: 584 # obsolete experimental requirements: