From patchwork Tue Apr 3 20:16:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D3045: narrow: move manifestrevlog overrides to core From: phabricator X-Patchwork-Id: 30209 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Tue, 3 Apr 2018 20:16:34 +0000 martinvonz created this revision. Herald added a reviewer: durin42. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3045 AFFECTED FILES hgext/narrow/narrowrepo.py hgext/narrow/narrowrevlog.py mercurial/manifest.py CHANGE DETAILS To: martinvonz, durin42, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -1279,6 +1279,7 @@ self._treeinmem = usetreemanifest self._revlog = repo._constructmanifest() + self._narrowmatch = repo.narrowmatch() # A cache of the manifestctx or treemanifestctx for each directory self._dirmancache = {} @@ -1477,6 +1478,10 @@ #self.linkrev = revlog.linkrev(rev) 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) def read(self): diff --git a/hgext/narrow/narrowrevlog.py b/hgext/narrow/narrowrevlog.py --- a/hgext/narrow/narrowrevlog.py +++ b/hgext/narrow/narrowrevlog.py @@ -30,24 +30,6 @@ # load time. 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): class narrowmanifestlog(mfl.__class__): def get(self, dir, node, verify=True): diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py --- a/hgext/narrow/narrowrepo.py +++ b/hgext/narrow/narrowrepo.py @@ -50,11 +50,6 @@ class narrowrepository(repo.__class__): - def _constructmanifest(self): - manifest = super(narrowrepository, self)._constructmanifest() - narrowrevlog.makenarrowmanifestrevlog(manifest, repo) - return manifest - @cacheprop('00manifest.i') def manifestlog(self): mfl = super(narrowrepository, self).manifestlog