D2494: narrow: move narrowmatch-related methods to localrepo
This revision was automatically updated to reflect the committed changes. Closed by commit rHG759a79ce785e: narrow: move narrowmatch-related methods to localrepo (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2494?vs=6194=6228 REVISION DETAIL https://phab.mercurial-scm.org/D2494 AFFECTED FILES hgext/narrow/narrowrepo.py mercurial/localrepo.py CHANGE DETAILS diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -43,6 +43,7 @@ merge as mergemod, mergeutil, namespaces, +narrowspec, obsolete, pathutil, peer, @@ -736,6 +737,37 @@ " working parent %s!\n") % short(node)) return nullid +@repofilecache(narrowspec.FILENAME) +def narrowpats(self): +"""matcher patterns for this repository's narrowspec + +A tuple of (includes, excludes). +""" +source = self +if self.shared(): +from . import hg +source = hg.sharedreposource(self) +return narrowspec.load(source) + +@repofilecache(narrowspec.FILENAME) +def _narrowmatch(self): +if changegroup.NARROW_REQUIREMENT not in self.requirements: +return matchmod.always(self.root, '') +include, exclude = self.narrowpats +return narrowspec.match(self.root, include=include, exclude=exclude) + +# TODO(martinvonz): make this property-like instead? +def narrowmatch(self): +return self._narrowmatch + +def setnarrowpats(self, newincludes, newexcludes): +target = self +if self.shared(): +from . import hg +target = hg.sharedreposource(self) +narrowspec.save(target, newincludes, newexcludes) +self.invalidate(clearfilecache=True) + def __getitem__(self, changeid): if changeid is None: return context.workingctx(self) diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py --- a/hgext/narrow/narrowrepo.py +++ b/hgext/narrow/narrowrepo.py @@ -12,7 +12,6 @@ changegroup, hg, localrepo, -match as matchmod, narrowspec, scmutil, ) @@ -67,35 +66,6 @@ narrowrevlog.makenarrowfilelog(fl, self.narrowmatch()) return fl -@localrepo.repofilecache(narrowspec.FILENAME) -def narrowpats(self): -"""matcher patterns for this repository's narrowspec - -A tuple of (includes, excludes). -""" -source = self -if self.shared(): -source = hg.sharedreposource(self) -return narrowspec.load(source) - -@localrepo.repofilecache(narrowspec.FILENAME) -def _narrowmatch(self): -if changegroup.NARROW_REQUIREMENT not in self.requirements: -return matchmod.always(self.root, '') -include, exclude = self.narrowpats -return narrowspec.match(self.root, include=include, exclude=exclude) - -# TODO(martinvonz): make this property-like instead? -def narrowmatch(self): -return self._narrowmatch - -def setnarrowpats(self, newincludes, newexcludes): -target = self -if self.shared(): -target = hg.sharedreposource(self) -narrowspec.save(target, newincludes, newexcludes) -self.invalidate(clearfilecache=True) - # I'm not sure this is the right place to do this filter. # context._manifestmatches() would probably be better, or perhaps # move it to a later place, in case some of the callers do want to know To: martinvonz, durin42, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2494: narrow: move narrowmatch-related methods to localrepo
indygreg accepted this revision. indygreg added a comment. This revision is now accepted and ready to land. I know we're trying to remove methods from `localrepository` so it is smaller. `narrowpats` and `_narrowmatch` need to be there because of `@repofilecache`. And `narrowmatch` is the thing we want to add to `localrepository`. I suppose `setnarrowpats` could live outside the class. But we don't have a better place in core yet. So I'm going to call it scope bloat and something that can be deferred to a follow-up patch, if desired. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2494 To: martinvonz, durin42, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2494: narrow: move narrowmatch-related methods to localrepo
martinvonz created this revision. Herald added a reviewer: durin42. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This patch makes it so localrepo.narrowmatch() and a few more are always available, which will let us simplify the use sites a bit. narrowmatch() will return an always-matcher in non-narrow repos (just like it did when it lived in the narrow extension). REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2494 AFFECTED FILES hgext/narrow/narrowrepo.py mercurial/localrepo.py CHANGE DETAILS diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -43,6 +43,7 @@ merge as mergemod, mergeutil, namespaces, +narrowspec, obsolete, pathutil, peer, @@ -736,6 +737,37 @@ " working parent %s!\n") % short(node)) return nullid +@repofilecache(narrowspec.FILENAME) +def narrowpats(self): +"""matcher patterns for this repository's narrowspec + +A tuple of (includes, excludes). +""" +source = self +if self.shared(): +from . import hg +source = hg.sharedreposource(self) +return narrowspec.load(source) + +@repofilecache(narrowspec.FILENAME) +def _narrowmatch(self): +if changegroup.NARROW_REQUIREMENT not in self.requirements: +return matchmod.always(self.root, '') +include, exclude = self.narrowpats +return narrowspec.match(self.root, include=include, exclude=exclude) + +# TODO(martinvonz): make this property-like instead? +def narrowmatch(self): +return self._narrowmatch + +def setnarrowpats(self, newincludes, newexcludes): +target = self +if self.shared(): +from . import hg +target = hg.sharedreposource(self) +narrowspec.save(target, newincludes, newexcludes) +self.invalidate(clearfilecache=True) + def __getitem__(self, changeid): if changeid is None: return context.workingctx(self) diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py --- a/hgext/narrow/narrowrepo.py +++ b/hgext/narrow/narrowrepo.py @@ -12,7 +12,6 @@ changegroup, hg, localrepo, -match as matchmod, narrowspec, scmutil, ) @@ -67,35 +66,6 @@ narrowrevlog.makenarrowfilelog(fl, self.narrowmatch()) return fl -@localrepo.repofilecache(narrowspec.FILENAME) -def narrowpats(self): -"""matcher patterns for this repository's narrowspec - -A tuple of (includes, excludes). -""" -source = self -if self.shared(): -source = hg.sharedreposource(self) -return narrowspec.load(source) - -@localrepo.repofilecache(narrowspec.FILENAME) -def _narrowmatch(self): -if changegroup.NARROW_REQUIREMENT not in self.requirements: -return matchmod.always(self.root, '') -include, exclude = self.narrowpats -return narrowspec.match(self.root, include=include, exclude=exclude) - -# TODO(martinvonz): make this property-like instead? -def narrowmatch(self): -return self._narrowmatch - -def setnarrowpats(self, newincludes, newexcludes): -target = self -if self.shared(): -target = hg.sharedreposource(self) -narrowspec.save(target, newincludes, newexcludes) -self.invalidate(clearfilecache=True) - # I'm not sure this is the right place to do this filter. # context._manifestmatches() would probably be better, or perhaps # move it to a later place, in case some of the callers do want to know To: martinvonz, durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel