Patchwork [2,of,3] context: add a method to efficiently filter by match if possible

mail settings
Submitter Siddharth Agarwal
Date Aug. 2, 2014, 5:19 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/5223/
State Accepted
Headers show


Siddharth Agarwal - Aug. 2, 2014, 5:19 a.m.
# HG changeset patch
# User Siddharth Agarwal <>
# Date 1406956049 25200
#      Fri Aug 01 22:07:29 2014 -0700
# Node ID 5e4d9c7cfc107374e85f8ca69746801257e322fa
# Parent  9c198be44e46807eda6e0ca749e05e881045de65
context: add a method to efficiently filter by match if possible

For non-working contexts, walk and matches do the same thing. For working
contexts, walk stats all the files and looks for unknown files, while matches
just filters the dirstate by match.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -598,6 +598,9 @@ 
             match.bad(fn, _('no such file in rev %s') % self)
+    def matches(self, match):
+        return self.walk(match)
 class basefilectx(object):
     """A filecontext object represents the common logic for its children:
     filectx: read-only access to a filerevision that is already present
@@ -1144,6 +1147,9 @@ 
         return sorted(self._repo.dirstate.walk(match, sorted(self.substate),
                                                True, False))
+    def matches(self, match):
+        return sorted(self._repo.dirstate.matches(match))
     def ancestors(self):
         for a in self._repo.changelog.ancestors(
             [p.rev() for p in self._parents]):