help: fold header selection into helplist
authorMatt Mackall <mpm@selenic.com>
Sat, 17 Sep 2011 14:46:13 -0500
changeset 15127 2c80862728cb
parent 15126 d3ad0e9d4be2
child 15128 aaf666bd2942
help: fold header selection into helplist
mercurial/commands.py
--- a/mercurial/commands.py	Sat Sep 17 14:46:00 2011 -0500
+++ b/mercurial/commands.py	Sat Sep 17 14:46:13 2011 -0500
@@ -2747,7 +2747,7 @@
             # except block, nor can be used inside a lambda. python issue4617
             prefix = inst.args[0]
             select = lambda c: c.lstrip('^').startswith(prefix)
-            helplist(_('list of commands:\n\n'), select)
+            helplist(select)
             return
 
         # check if it's an invalid alias and display its error if it is
@@ -2805,7 +2805,13 @@
         except KeyError:
             pass
 
-    def helplist(header, select=None):
+    def helplist(select=None):
+        # list of commands
+        if name == "shortlist":
+            header = _('basic commands:\n\n')
+        else:
+            header = _('list of commands:\n\n')
+
         h = {}
         cmds = {}
         for c, e in table.iteritems():
@@ -2908,7 +2914,7 @@
             except AttributeError:
                 ct = {}
             modcmds = set([c.split('|', 1)[0] for c in ct])
-            helplist(_('list of commands:\n\n'), modcmds.__contains__)
+            helplist(modcmds.__contains__)
         else:
             ui.write(_('use "hg help extensions" for information on enabling '
                        'extensions\n'))
@@ -2943,19 +2949,11 @@
                 i = inst
         if i:
             raise i
-
     else:
         # program name
         ui.status(_("Mercurial Distributed SCM\n"))
         ui.status('\n')
-
-        # list of commands
-        if name == "shortlist":
-            header = _('basic commands:\n\n')
-        else:
-            header = _('list of commands:\n\n')
-
-        helplist(header)
+        helplist()
 
     ui.write(opttext(optlist, textwidth))