changeset 28272:760f9d04842a

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.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 13 Feb 2016 20:13:45 +0900
parents 5c454ab69558
children 9ac8955d8c45
files mercurial/revset.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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: