Details
Details
- Reviewers
durin42 indygreg - Group Reviewers
hg-reviewers - Commits
- rHGc50078fc32f3: narrow: move manifestrevlog overrides to core
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
durin42 | |
indygreg |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/narrow/narrowrepo.py (5 lines) | |||
M | hgext/narrow/narrowrevlog.py (18 lines) | |||
M | mercurial/manifest.py (5 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
# We have to use a different caching property decorator for | # We have to use a different caching property decorator for | ||||
# bundlerepo because storecache blows up in strange ways on a | # bundlerepo because storecache blows up in strange ways on a | ||||
# bundlerepo. Fortunately, there's no risk of data changing in | # bundlerepo. Fortunately, there's no risk of data changing in | ||||
# a bundlerepo. | # a bundlerepo. | ||||
cacheprop = lambda name: localrepo.unfilteredpropertycache | cacheprop = lambda name: localrepo.unfilteredpropertycache | ||||
class narrowrepository(repo.__class__): | class narrowrepository(repo.__class__): | ||||
def _constructmanifest(self): | |||||
manifest = super(narrowrepository, self)._constructmanifest() | |||||
narrowrevlog.makenarrowmanifestrevlog(manifest, repo) | |||||
return manifest | |||||
@cacheprop('00manifest.i') | @cacheprop('00manifest.i') | ||||
def manifestlog(self): | def manifestlog(self): | ||||
mfl = super(narrowrepository, self).manifestlog | mfl = super(narrowrepository, self).manifestlog | ||||
narrowrevlog.makenarrowmanifestlog(mfl, self) | narrowrevlog.makenarrowmanifestlog(mfl, self) | ||||
return mfl | return mfl | ||||
def file(self, f): | def file(self, f): | ||||
fl = super(narrowrepository, self).file(f) | fl = super(narrowrepository, self).file(f) |
revlog.addflagprocessor(revlog.REVIDX_ELLIPSIS, | revlog.addflagprocessor(revlog.REVIDX_ELLIPSIS, | ||||
(readtransform, writetransform, rawtransform)) | (readtransform, writetransform, rawtransform)) | ||||
def setup(): | def setup(): | ||||
# We just wanted to add the flag processor, which is done at module | # We just wanted to add the flag processor, which is done at module | ||||
# load time. | # load time. | ||||
pass | pass | ||||
def makenarrowmanifestrevlog(mfrevlog, repo): | |||||
if util.safehasattr(mfrevlog, '_narrowed'): | |||||
return | |||||
class narrowmanifestrevlog(mfrevlog.__class__): | |||||
# This function is called via debug{revlog,index,data}, but also during | |||||
# at least some push operations. This will be used to wrap/exclude the | |||||
# child directories when using treemanifests. | |||||
def dirlog(self, d): | |||||
if not repo.narrowmatch().visitdir(d[:-1] or '.'): | |||||
return manifest.excludedmanifestrevlog(d) | |||||
result = super(narrowmanifestrevlog, self).dirlog(d) | |||||
makenarrowmanifestrevlog(result, repo) | |||||
return result | |||||
mfrevlog.__class__ = narrowmanifestrevlog | |||||
mfrevlog._narrowed = True | |||||
def makenarrowmanifestlog(mfl, repo): | def makenarrowmanifestlog(mfl, repo): | ||||
class narrowmanifestlog(mfl.__class__): | class narrowmanifestlog(mfl.__class__): | ||||
def get(self, dir, node, verify=True): | def get(self, dir, node, verify=True): | ||||
if not repo.narrowmatch().visitdir(dir[:-1] or '.'): | if not repo.narrowmatch().visitdir(dir[:-1] or '.'): | ||||
return manifest.excludeddirmanifestctx(dir, node) | return manifest.excludeddirmanifestctx(dir, node) | ||||
return super(narrowmanifestlog, self).get(dir, node, verify=verify) | return super(narrowmanifestlog, self).get(dir, node, verify=verify) | ||||
mfl.__class__ = narrowmanifestlog | mfl.__class__ = narrowmanifestlog | ||||
opts = getattr(opener, 'options', None) | opts = getattr(opener, 'options', None) | ||||
if opts is not None: | if opts is not None: | ||||
usetreemanifest = opts.get('treemanifest', usetreemanifest) | usetreemanifest = opts.get('treemanifest', usetreemanifest) | ||||
cachesize = opts.get('manifestcachesize', cachesize) | cachesize = opts.get('manifestcachesize', cachesize) | ||||
self._treeinmem = usetreemanifest | self._treeinmem = usetreemanifest | ||||
self._revlog = repo._constructmanifest() | self._revlog = repo._constructmanifest() | ||||
self._narrowmatch = repo.narrowmatch() | |||||
# A cache of the manifestctx or treemanifestctx for each directory | # A cache of the manifestctx or treemanifestctx for each directory | ||||
self._dirmancache = {} | self._dirmancache = {} | ||||
self._dirmancache[''] = util.lrucachedict(cachesize) | self._dirmancache[''] = util.lrucachedict(cachesize) | ||||
self.cachesize = cachesize | self.cachesize = cachesize | ||||
def __getitem__(self, node): | def __getitem__(self, node): | ||||
# TODO: Load p1/p2/linkrev lazily. They need to be lazily loaded so that | # TODO: Load p1/p2/linkrev lazily. They need to be lazily loaded so that | ||||
# we can instantiate treemanifestctx objects for directories we don't | # we can instantiate treemanifestctx objects for directories we don't | ||||
# have on disk. | # have on disk. | ||||
#self.p1, self.p2 = revlog.parents(node) | #self.p1, self.p2 = revlog.parents(node) | ||||
#rev = revlog.rev(node) | #rev = revlog.rev(node) | ||||
#self.linkrev = revlog.linkrev(rev) | #self.linkrev = revlog.linkrev(rev) | ||||
def _revlog(self): | def _revlog(self): | ||||
narrowmatch = self._manifestlog._narrowmatch | |||||
if not narrowmatch.always(): | |||||
if not narrowmatch.visitdir(self._dir[:-1] or '.'): | |||||
return excludedmanifestrevlog(self._dir) | |||||
return self._manifestlog._revlog.dirlog(self._dir) | return self._manifestlog._revlog.dirlog(self._dir) | ||||
def read(self): | def read(self): | ||||
if self._data is None: | if self._data is None: | ||||
rl = self._revlog() | rl = self._revlog() | ||||
if self._node == revlog.nullid: | if self._node == revlog.nullid: | ||||
self._data = treemanifest() | self._data = treemanifest() | ||||
elif rl._treeondisk: | elif rl._treeondisk: |