[PATCH 3 of 3 STABLE V3] context: use 'changectx.dirs()' in 'walk()' for directory patterns

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Feb 22 09:09:41 CST 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1329923274 -32400
# Branch stable
# Node ID aae4c35216adddd096c5c1a19128a093e6237fa4
# Parent  1feded5e1cb7aba9310a7bad20f69a6508f27230
context: use 'changectx.dirs()' in 'walk()' for directory patterns

this patch uses 'changectx.dirs()' instead of nested loop, to examine
whether specified pattern is related to the context as a directory or not.

diff -r 1feded5e1cb7 -r aae4c35216ad mercurial/context.py
--- a/mercurial/context.py	Thu Feb 23 00:07:54 2012 +0900
+++ b/mercurial/context.py	Thu Feb 23 00:07:54 2012 +0900
@@ -206,14 +206,15 @@
         # 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 fn in fset:
+                # specified pattern is the exact name
+                fset.remove(fn)
             if match(fn):
                 yield fn
         for fn in sorted(fset):
+            if fn in self._dirs:
+                # specified pattern is a directory
+                continue
             if match.bad(fn, _('no such file in rev %s') % self) and match(fn):
                 yield fn
 


More information about the Mercurial-devel mailing list