Patchwork D2489: narrow: move checking for narrow requirement into _narrowmatch()

login
register
mail settings
Submitter phabricator
Date Feb. 28, 2018, 8:56 p.m.
Message ID <differential-rev-PHID-DREV-lnu3rquuowkjjgejyaul-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28488/
State Superseded
Headers show

Comments

phabricator - Feb. 28, 2018, 8:56 p.m.
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We want to move narrowmatch() and others into core, so we need to get
  rid of the dependence on the "narrow_opts" from the closure in
  narrowrepo.wraprepo(). We can simply check if the narrow requirement
  is set. I think that seems like an improvement regardless of moving
  narrowmatch().

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2489

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowcommands.py
  hgext/narrow/narrowrepo.py

CHANGE DETAILS




To: martinvonz, durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - March 1, 2018, 2:04 a.m.
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  Having the requirement imply the use of a narrow matcher seems OK to me. It is easy enough to change if we need something else.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2489

To: martinvonz, durin42, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel

Patch

diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -38,7 +38,7 @@ 
             f.write(spec)
     return orig(ui, repo, repopath)
 
-def wraprepo(repo, opts_narrow):
+def wraprepo(repo):
     """Enables narrow clone functionality on a single local repository."""
 
     cacheprop = localrepo.storecache
@@ -77,9 +77,9 @@ 
 
         @localrepo.repofilecache(narrowspec.FILENAME)
         def _narrowmatch(self):
+            if changegroup.NARROW_REQUIREMENT not in self.requirements:
+                return matchmod.always(self.root, '')
             include, exclude = self.narrowpats
-            if not opts_narrow and not include and not exclude:
-                return matchmod.always(self.root, '')
             return narrowspec.match(self.root, include=include, exclude=exclude)
 
         # TODO(martinvonz): make this property-like instead?
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -101,7 +101,7 @@ 
             '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
 
     def pullnarrow(orig, repo, *args, **kwargs):
-        narrowrepo.wraprepo(repo.unfiltered(), opts_narrow)
+        narrowrepo.wraprepo(repo.unfiltered())
         if isinstance(repo, repoview.repoview):
             repo.__class__.__bases__ = (repo.__class__.__bases__[0],
                                         repo.unfiltered().__class__)
diff --git a/hgext/narrow/__init__.py b/hgext/narrow/__init__.py
--- a/hgext/narrow/__init__.py
+++ b/hgext/narrow/__init__.py
@@ -73,7 +73,7 @@ 
         return
 
     if changegroup.NARROW_REQUIREMENT in repo.requirements:
-        narrowrepo.wraprepo(repo, True)
+        narrowrepo.wraprepo(repo)
         narrowcopies.setup(repo)
         narrowdirstate.setup(repo)
         narrowpatch.setup(repo)