# HG changeset patch # User Yuya Nishihara # Date 1455362025 -32400 # Node ID 760f9d04842aab6df2c7ed6af85a8096373ac6d7 # Parent 5c454ab695589531f5d12341d33d505faf950e85 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. diff -r 5c454ab69558 -r 760f9d04842a 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: