revset: narrow scope of the variable referred only in specific code path
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 17 Jan 2014 23:42:12 +0900
changeset 20285 189fe1b3d16a
parent 20284 e1e6ddaef299
child 20286 760151697a4f
revset: narrow scope of the variable referred only in specific code path This patch narrows scope of the variable "m" in the function for revset predicate "contains()", because it is referred only in "else" code path of "if not matchmod.patkind(pat)" examination.
mercurial/revset.py
--- a/mercurial/revset.py	Fri Jan 17 12:46:29 2014 +0100
+++ b/mercurial/revset.py	Fri Jan 17 23:42:12 2014 +0900
@@ -528,13 +528,13 @@
     """
     # i18n: "contains" is a keyword
     pat = getstring(x, _("contains requires a pattern"))
-    m = None
     s = []
     if not matchmod.patkind(pat):
         for r in subset:
             if pat in repo[r]:
                 s.append(r)
     else:
+        m = None
         for r in subset:
             c = repo[r]
             if not m or matchmod.patkind(pat) == 'set':