D4896: localrepo: allow narrowmatch() to accept matcher to intersect with

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sat Oct 6 01:08:35 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4fd0fac48922: localrepo: allow narrowmatch() to accept matcher to intersect with (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4896?vs=11720&id=11734

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/commands.py
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1200,8 +1200,14 @@
         include, exclude = self.narrowpats
         return narrowspec.match(self.root, include=include, exclude=exclude)
 
-    # TODO(martinvonz): make this property-like instead?
-    def narrowmatch(self):
+    def narrowmatch(self, match=None):
+        """matcher corresponding the the repo's narrowspec
+
+        If `match` is given, then that will be intersected with the narrow
+        matcher.
+        """
+        if match:
+            return matchmod.intersectmatchers(match, self._narrowmatch)
         return self._narrowmatch
 
     def setnarrowpats(self, newincludes, newexcludes):
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -44,7 +44,6 @@
     help,
     hg,
     logcmdutil,
-    match as matchmod,
     merge as mergemod,
     narrowspec,
     obsolete,
@@ -1970,7 +1969,7 @@
 
     diffopts = patch.diffallopts(ui, opts)
     m = scmutil.match(ctx2, pats, opts)
-    m = matchmod.intersectmatchers(m, repo.narrowmatch())
+    m = repo.narrowmatch(m)
     ui.pager('diff')
     logcmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
                               listsubrepos=opts.get('subrepos'),
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -1271,8 +1271,7 @@
 
     # Requested files could include files not in the local store. So
     # filter those out.
-    filematcher = matchmod.intersectmatchers(repo.narrowmatch(),
-                                             filematcher)
+    filematcher = repo.narrowmatch(filematcher)
 
     fn = _packermap[version][0]
     return fn(repo, filematcher, bundlecaps, ellipses=ellipses,



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


More information about the Mercurial-devel mailing list