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

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Feb 19 04:25:42 CST 2012


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

diff -r 59430cdb845b -r dab4c1d7f1e0 mercurial/context.py
--- a/mercurial/context.py	Sun Feb 19 19:20:46 2012 +0900
+++ b/mercurial/context.py	Sun Feb 19 19:20:46 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