[PATCH 4 of 4] commands: move 'see also' message display logic from addglobals to callers

Henri Wiechers hwiechers at gmail.com
Tue Jan 12 02:55:24 CST 2010


# HG changeset patch
# User Henri Wiechers <hwiechers at gmail.com>
# Date 1263286317 -7200
# Node ID ce1d0a8f0568827d3deea626ae7fa74cf263fce7
# Parent  b12f8e7bd3f71236e264f10a287177849f7e3fa4
commands: move 'see also' message display logic from addglobals to callers

diff -r b12f8e7bd3f7 -r ce1d0a8f0568 mercurial/commands.py
--- a/mercurial/commands.py	Tue Jan 12 10:51:46 2010 +0200
+++ b/mercurial/commands.py	Tue Jan 12 10:51:57 2010 +0200
@@ -1456,25 +1456,19 @@
     option_lists = []
     textwidth = util.termwidth() - 2
 
-    def addglobalopts(aliases):
+    seealiases = _('use "hg -v help%s" to show aliases and '
+                   'global options') % (name and " " + name or "")
+
+    def addglobalopts(andmsg=None, ormsg=None):
         if ui.quiet:
             return
 
         if ui.verbose:
             option_lists.append((_("global options:"), globalopts))
-            if name == 'shortlist':
-                option_lists.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 aliases:
-                msg = _('use "hg -v help%s" to show aliases and '
-                        'global options') % (name and " " + name or "")
-            else:
-                msg = _('use "hg -v help %s" to show global options') % name
-            option_lists.append((msg, ()))
+            if andmsg:
+                option_lists.append((andmsg, ()))
+        elif ormsg:
+                option_lists.append((ormsg, ()))
 
     def helpcmd(name):
         if with_version:
@@ -1489,7 +1483,7 @@
             prefix = inst.args[0]
             select = lambda c: c.lstrip('^').startswith(prefix)
             helplist(_('list of commands:\n\n'), select)
-            addglobalopts(True)
+            addglobalopts(ormsg=seealiases)
             return
 
         # check if it's an invalid alias and display its error if it is
@@ -1523,7 +1517,8 @@
             if entry[1]:
                 option_lists.append((_("options:\n"), entry[1]))
 
-            addglobalopts(False)
+            addglobalopts(ormsg=(_('use "hg -v help %s" to show global ' + 
+                                   'options') % name))
 
     def helplist(header, select=None):
         h = {}
@@ -1606,7 +1601,8 @@
             ui.status(_('no commands defined\n'))
             return
 
-        addglobalopts(True)
+        addglobalopts(ormsg=seealiases)
+
     if name and name != 'shortlist':
         i = None
         for f in (helptopic, helpcmd, helpext):
@@ -1634,8 +1630,13 @@
             header = _('list of commands:\n\n')
 
         helplist(header)
-        addglobalopts(True)
-        if name != 'shortlist':
+        if name == 'shortlist':
+            andmsg = _('use "hg help" for the full list of commands')
+            ormsg = _('use "hg help" for the full list of commands ' + 
+                      'or "hg -v" for details') 
+            addglobalopts(andmsg=andmsg, ormsg=ormsg)
+        else:
+            addglobalopts(ormsg=seealiases)
             exts, maxlength = extensions.enabled()
             text = help.listexts(_('enabled extensions:'), exts, maxlength)
             if text:


More information about the Mercurial-devel mailing list