revset: define "pat" variable unconditionally in subrepo()
authorYuya Nishihara <yuya@tcha.org>
Sat, 13 Feb 2016 20:13:45 +0900
changeset 28272 760f9d04842a
parent 28271 5c454ab69558
child 28273 9ac8955d8c45
revset: define "pat" variable unconditionally in subrepo() It's a source of UnboundLocalError to define and use local variables conditionally. As getstring() always returns a str, "pat" can be initialized to None.
mercurial/revset.py
--- a/mercurial/revset.py	Tue May 05 10:47:35 2015 +0900
+++ b/mercurial/revset.py	Sat Feb 13 20:13:45 2016 +0900
@@ -1982,6 +1982,7 @@
     """
     # i18n: "subrepo" is a keyword
     args = getargs(x, 0, 1, _('subrepo takes at most one argument'))
+    pat = None
     if len(args) != 0:
         pat = getstring(args[0], _("subrepo requires a pattern"))
 
@@ -1997,7 +1998,7 @@
         c = repo[x]
         s = repo.status(c.p1().node(), c.node(), match=m)
 
-        if len(args) == 0:
+        if pat is None:
             return s.added or s.modified or s.removed
 
         if s.added: