[PATCH 2 of 7] revset: define "pat" variable unconditionally in subrepo()
Yuya Nishihara
yuya at tcha.org
Sat Feb 27 09:38:16 EST 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1455362025 -32400
# Sat Feb 13 20:13:45 2016 +0900
# Node ID fe9925d9c774eec6d1ccaeddc05dc287b572ef6e
# Parent 4c869f64c013866cdf49278ffcff981e9074201d
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 --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1982,6 +1982,7 @@ def subrepo(repo, subset, x):
"""
# 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 @@ def subrepo(repo, subset, x):
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:
More information about the Mercurial-devel
mailing list