# HG changeset patch # User Matt Mackall # Date 1316289355 18000 # Node ID 9b904d6798507885f8168ae5827c184a27871ee3 # Parent aaf666bd29420ba4a6041a7585a5c68c4e54b8d2 help: make optlist local to subfunctions diff -r aaf666bd2942 -r 9b904d679850 mercurial/commands.py --- a/mercurial/commands.py Sat Sep 17 14:50:42 2011 -0500 +++ b/mercurial/commands.py Sat Sep 17 14:55:55 2011 -0500 @@ -2661,7 +2661,6 @@ Returns 0 if successful. """ - optlist = [] textwidth = min(ui.termwidth(), 80) - 2 # list all option lists @@ -2720,7 +2719,10 @@ return text - def addglobalopts(aliases): + def addglobalopts(optlist, aliases): + if ui.quiet: + return [] + if ui.verbose: optlist.append((_("global options:"), globalopts)) if name == 'shortlist': @@ -2740,6 +2742,7 @@ optlist.append((msg, ())) def helpcmd(name): + optlist = [] try: aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd) except error.AmbiguousCommand, inst: @@ -2791,8 +2794,6 @@ if entry[1]: optlist.append((_("options:\n"), entry[1])) - addglobalopts(False) - # check if this command shadows a non-trivial (multi-line) # extension help text try: @@ -2805,6 +2806,7 @@ except KeyError: pass + addglobalopts(optlist, False) ui.write(opttext(optlist, textwidth)) def helplist(select=None): @@ -2853,9 +2855,6 @@ initindent=' %-*s ' % (m, f), hangindent=' ' * (m + 4)))) - if not ui.quiet: - addglobalopts(True) - if not name: text = help.listexts(_('enabled extensions:'), extensions.enabled()) if text: @@ -2869,6 +2868,8 @@ for t, desc in topics: ui.write(" %-*s %s\n" % (topics_len, t, desc)) + optlist = [] + addglobalopts(optlist, True) ui.write(opttext(optlist, textwidth)) def helptopic(name):