diff hgext/narrow/narrowrepo.py @ 36466:a8b4d7673d8e

narrow: move checking for narrow requirement into _narrowmatch() 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(). Differential Revision: https://phab.mercurial-scm.org/D2489
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 28 Feb 2018 10:22:54 -0800
parents 3f0af89e008d
children d851951b421c
line wrap: on
line diff
--- a/hgext/narrow/narrowrepo.py	Wed Feb 28 10:55:21 2018 -0800
+++ b/hgext/narrow/narrowrepo.py	Wed Feb 28 10:22:54 2018 -0800
@@ -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?