[PATCH 1 of 6] revset: narrow scope of the variable referred only in specific code path

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Jan 17 08:57:03 CST 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1389969732 -32400
#      Fri Jan 17 23:42:12 2014 +0900
# Node ID d601202366e79f2ede928d66b75055e01a105e29
# Parent  6545770bd37991b4ff0400479455a6e3ffa5976b
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.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -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':


More information about the Mercurial-devel mailing list