comparison mercurial/revset.py @ 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 ac11ba7c2e56
comparison
equal deleted inserted replaced
28271:5c454ab69558 28272:760f9d04842a
1980 """Changesets that add, modify or remove the given subrepo. If no subrepo 1980 """Changesets that add, modify or remove the given subrepo. If no subrepo
1981 pattern is named, any subrepo changes are returned. 1981 pattern is named, any subrepo changes are returned.
1982 """ 1982 """
1983 # i18n: "subrepo" is a keyword 1983 # i18n: "subrepo" is a keyword
1984 args = getargs(x, 0, 1, _('subrepo takes at most one argument')) 1984 args = getargs(x, 0, 1, _('subrepo takes at most one argument'))
1985 pat = None
1985 if len(args) != 0: 1986 if len(args) != 0:
1986 pat = getstring(args[0], _("subrepo requires a pattern")) 1987 pat = getstring(args[0], _("subrepo requires a pattern"))
1987 1988
1988 m = matchmod.exact(repo.root, repo.root, ['.hgsubstate']) 1989 m = matchmod.exact(repo.root, repo.root, ['.hgsubstate'])
1989 1990
1995 1996
1996 def matches(x): 1997 def matches(x):
1997 c = repo[x] 1998 c = repo[x]
1998 s = repo.status(c.p1().node(), c.node(), match=m) 1999 s = repo.status(c.p1().node(), c.node(), match=m)
1999 2000
2000 if len(args) == 0: 2001 if pat is None:
2001 return s.added or s.modified or s.removed 2002 return s.added or s.modified or s.removed
2002 2003
2003 if s.added: 2004 if s.added:
2004 return any(submatches(c.substate.keys())) 2005 return any(submatches(c.substate.keys()))
2005 2006