[PATCH 4 of 4] help: inline helper function used once only

Olav Reinert seroton10 at gmail.com
Tue May 22 15:11:43 CDT 2012


# HG changeset patch
# User Olav Reinert <seroton10 at gmail.com>
# Date 1337717321 -7200
# Node ID dd659d0b1b61bca83857b8373d7a76915c3d5c34
# Parent  f7fadf491a24fef0eb225903428077b851fe0f4e
help: inline helper function used once only

diff -r f7fadf491a24 -r dd659d0b1b61 mercurial/commands.py
--- a/mercurial/commands.py	Tue May 22 22:08:41 2012 +0200
+++ b/mercurial/commands.py	Tue May 22 22:08:41 2012 +0200
@@ -3089,26 +3089,6 @@
 
     textwidth = min(ui.termwidth(), 80) - 2
 
-    def addglobalopts(optlist):
-        if ui.quiet:
-            return []
-
-        if ui.verbose:
-            optlist.append((_("global options:"), globalopts))
-            if name == 'shortlist':
-                optlist.append((_('use "hg help" for the full list '
-                                       'of commands'), ()))
-        else:
-            if name == 'shortlist':
-                msg = _('use "hg help" for the full list of commands '
-                        'or "hg -v" for details')
-            elif name and not full:
-                msg = _('use "hg help %s" to show the full help text') % name
-            else:
-                msg = _('use "hg -v help%s" to show builtin aliases and '
-                        'global options') % (name and " " + name or "")
-            optlist.append((msg, ()))
-
     def helpcmd(name):
         try:
             aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd)
@@ -3251,7 +3231,24 @@
                 ui.write(" %-*s   %s\n" % (topics_len, t, desc))
 
         optlist = []
-        addglobalopts(optlist)
+        if not ui.quiet:
+            if ui.verbose:
+                optlist.append((_("global options:"), globalopts))
+                if name == 'shortlist':
+                    optlist.append((_('use "hg help" for the full list '
+                                           'of commands'), ()))
+            else:
+                if name == 'shortlist':
+                    msg = _('use "hg help" for the full list of commands '
+                            'or "hg -v" for details')
+                elif name and not full:
+                    msg = _('use "hg help %s" to show the full help '
+                            'text') % name
+                else:
+                    msg = _('use "hg -v help%s" to show builtin aliases and '
+                            'global options') % (name and " " + name or "")
+                optlist.append((msg, ()))
+
         ui.write(help.opttext(optlist, textwidth, ui.verbose))
 
     def helptopic(name):


More information about the Mercurial-devel mailing list