[PATCH 2 of 2 STABLE] context: use 'changectx.dirs()' to examine wheter specified patterns are valid

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat Feb 18 15:15:38 UTC 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1329577967 -32400
# Branch stable
# Node ID ec33099c222a57ca1251d9a68d9754eb9cc5154e
# Parent  0df295bc57a9dbf897fde6be438711dd56797591
context: use 'changectx.dirs()' to examine wheter specified patterns are valid

diff -r 0df295bc57a9 -r ec33099c222a mercurial/context.py
--- a/mercurial/context.py	Sun Feb 19 00:12:47 2012 +0900
+++ b/mercurial/context.py	Sun Feb 19 00:12:47 2012 +0900
@@ -201,19 +201,16 @@
         return changectx(self._repo, n)
 
     def walk(self, match):
-        fset = set(match.files())
-        # for dirstate.walk, files=['.'] means "walk the whole tree".
-        # follow that here, too
-        fset.discard('.')
         for fn in self:
-            for ffn in fset:
-                # match if the file is the exact name or a directory
-                if ffn == fn or fn.startswith("%s/" % ffn):
-                    fset.remove(ffn)
-                    break
             if match(fn):
                 yield fn
-        for fn in sorted(fset):
+        # omit below entries:
+        #   - '.' meaning "walk the whole tree" for dirstate.walk
+        #   - files exactly matched to manifest
+        #   - directories related to manifest
+        files = [f for f in match.files()
+                 if not ((f == '.') or (f in self) or (f in self._dirs))]
+        for fn in sorted(files):
             if match.bad(fn, _('no such file in rev %s') % self) and match(fn):
                 yield fn
 



More information about the Mercurial-devel mailing list