changeset 21985:7e871e771300

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.
author Siddharth Agarwal <sid0@fb.com>
date Fri, 01 Aug 2014 22:07:29 -0700
parents 977a0b9af5ac
children 48166e46f111
files mercurial/context.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Fri Aug 01 22:05:16 2014 -0700
+++ b/mercurial/context.py	Fri Aug 01 22:07:29 2014 -0700
@@ -598,6 +598,9 @@
                 continue
             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]):