[PATCH] help: 'hg help' supports list of subtopics (issue2804)

Yun Lee yun.lee.bj at gmail.com
Mon May 23 09:56:11 CDT 2011


# HG changeset patch
# User Yun Lee <yun.lee.bj at gmail.com>
# Date 1306162477 -28800
# Branch stable
# Node ID a8ddc45c104873c84f3618895e1936d8307f6db2
# Parent  3c65cdcf3ba6cdaa75e7b9e6eb8ef0ff0d3db197
help: 'hg help' supports list of subtopics (issue2804)

diff -r 3c65cdcf3ba6 -r a8ddc45c1048 doc/gendoc.py
--- a/doc/gendoc.py	Fri May 13 19:46:36 2011 -0500
+++ b/doc/gendoc.py	Mon May 23 22:54:37 2011 +0800
@@ -86,7 +86,7 @@
     commandprinter(ui, table, subsection)
 
     # print topics
-    for names, sec, doc in helptable:
+    for names, sec, doc, subtopics in helptable:
         for name in names:
             ui.write(".. _%s:\n" % name)
         ui.write("\n")
diff -r 3c65cdcf3ba6 -r a8ddc45c1048 mercurial/commands.py
--- a/mercurial/commands.py	Fri May 13 19:46:36 2011 -0500
+++ b/mercurial/commands.py	Mon May 23 22:54:37 2011 +0800
@@ -2083,7 +2083,7 @@
             addglobalopts(True)
 
     def helptopic(name):
-        for names, header, doc in help.helptable:
+        for names, header, doc, subtopics in help.helptable:
             if name in names:
                 break
         else:
@@ -2097,6 +2097,13 @@
 
         ui.write("%s\n\n" % header)
         ui.write("%s\n" % minirst.format(doc, textwidth, indent=4))
+        
+        if subtopics:
+            ui.write("\n\nsubtopics:\n\n")
+            
+            for subtopic in subtopics:
+                ui.write('  %-16s  %s\n' % (subtopic[0], subtopic[1]))
+        
 
     def helpext(name):
         try:
@@ -2218,7 +2225,7 @@
     if not name:
         ui.write(_("\nadditional help topics:\n\n"))
         topics = []
-        for names, header, doc in help.helptable:
+        for names, header, doc, subtopics in help.helptable:
             topics.append((sorted(names, key=len, reverse=True)[0], header))
         topics_len = max([len(s[0]) for s in topics])
         for t, desc in topics:
diff -r 3c65cdcf3ba6 -r a8ddc45c1048 mercurial/help.py
--- a/mercurial/help.py	Fri May 13 19:46:36 2011 -0500
+++ b/mercurial/help.py	Mon May 23 22:54:37 2011 +0800
@@ -87,25 +87,48 @@
     return loader
 
 helptable = [
-    (["config", "hgrc"], _("Configuration Files"), loaddoc('config')),
-    (["dates"], _("Date Formats"), loaddoc('dates')),
-    (["patterns"], _("File Name Patterns"), loaddoc('patterns')),
+    (["config", "hgrc"], _("Configuration Files"), loaddoc('config'), 
+      [('alias', 'Defines command aliases'), 
+       ('auth', 'Authentication credentials for HTTP authentication'), 
+       ('decode/encode', 'Filters for transforming files on checkout/checkin'),
+       ('defaults', 'Use the [defaults] section to define command defaults'),
+       ('diff', 'Settings used when displaying diffs'),
+       ('email', 'Settings for extensions that send email messages'),
+       ('extensions', 'Extension mechanism for adding new features'),
+       ('hostfingerprints', 'Fingerprints of the certificates of known HTTPS servers'),
+       ('format', 'Configuration for repository format'),
+       ('merge-patterns', 'Merge tools to associate with particular file patterns'),
+       ('merge-tools', 'Configures external merge tools to use for file-level merges'),
+       ('hooks', 'Commands or Python functions'),
+       ('http_proxy', 'Configuration for access web-based Mercurial repositories through a HTTP proxy'),
+       ('smtp', 'Configuration for extensions that need to send email messages'),
+       ('patch', 'Settings used when applying patches'),
+       ('paths', 'Assigns symbolic names to repositories'),
+       ('profiling', 'Specifies profiling format and file output'),
+       ('server', 'Controls generic server settings'),
+       ('subpaths', 'Defines subrepositories source locations rewriting rules of the form'),
+       ('trusted', 'specifies what users and groups are trusted'),
+       ('ui', 'User interface controls'),
+       ('web', 'Web interface configuration'),
+       ]),
+    (["dates"], _("Date Formats"), loaddoc('dates'), []),
+    (["patterns"], _("File Name Patterns"), loaddoc('patterns'), []),
     (['environment', 'env'], _('Environment Variables'),
-     loaddoc('environment')),
+     loaddoc('environment'), []),
     (['revs', 'revisions'], _('Specifying Single Revisions'),
-     loaddoc('revisions')),
+     loaddoc('revisions'), []),
     (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'),
-     loaddoc('multirevs')),
-    (['revset', 'revsets'], _("Specifying Revision Sets"), loaddoc('revsets')),
-    (['diffs'], _('Diff Formats'), loaddoc('diffs')),
-    (['merge-tools'], _('Merge Tools'), loaddoc('merge-tools')),
+     loaddoc('multirevs'), []),
+    (['revset', 'revsets'], _("Specifying Revision Sets"), loaddoc('revsets'), []),
+    (['diffs'], _('Diff Formats'), loaddoc('diffs'), []),
+    (['merge-tools'], _('Merge Tools'), loaddoc('merge-tools'), []),
     (['templating', 'templates'], _('Template Usage'),
-     loaddoc('templates')),
-    (['urls'], _('URL Paths'), loaddoc('urls')),
-    (["extensions"], _("Using additional features"), extshelp),
-    (["subrepo", "subrepos"], _("Subrepositories"), loaddoc('subrepos')),
-    (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')),
-    (["glossary"], _("Glossary"), loaddoc('glossary')),
+     loaddoc('templates'), []),
+    (['urls'], _('URL Paths'), loaddoc('urls'), []),
+    (["extensions"], _("Using additional features"), extshelp, []),
+    (["subrepo", "subrepos"], _("Subrepositories"), loaddoc('subrepos'), []),
+    (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb'), []),
+    (["glossary"], _("Glossary"), loaddoc('glossary'), []),
 ]
 
 # Map topics to lists of callable taking the current topic help and
diff -r 3c65cdcf3ba6 -r a8ddc45c1048 tests/test-help.t
--- a/tests/test-help.t	Fri May 13 19:46:36 2011 -0500
+++ b/tests/test-help.t	Mon May 23 22:54:37 2011 +0800
@@ -791,3 +791,93 @@
   $ hg help revsets | grep helphook
       helphook1
       helphook2
+
+Test 'hg help config' displaying list of subtopics
+  $ hg help config
+  Configuration Files
+  
+      Mercurial reads configuration data from several files, if they exist.
+      Below we list the most specific file first.
+  
+      On Windows, these configuration files are read:
+  
+      - "<repo>\.hg\hgrc"
+      - "%USERPROFILE%\.hgrc"
+      - "%USERPROFILE%\mercurial.ini"
+      - "%HOME%\.hgrc"
+      - "%HOME%\mercurial.ini"
+      - "C:\mercurial\mercurial.ini" (unless regkey or hgrc.d\ or mercurial.ini
+        found)
+      - "HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial" (unless hgrc.d\ or mercurial.ini
+        found)
+      - "<hg.exe-dir>\hgrc.d\*.rc" (unless mercurial.ini found)
+      - "<hg.exe-dir>\mercurial.ini"
+  
+      On Unix, these files are read:
+  
+      - "<repo>/.hg/hgrc"
+      - "$HOME/.hgrc"
+      - "/etc/mercurial/hgrc"
+      - "/etc/mercurial/hgrc.d/*.rc"
+      - "<install-root>/etc/mercurial/hgrc"
+      - "<install-root>/etc/mercurial/hgrc.d/*.rc"
+  
+      These files do not exist by default and you will have to create the
+      appropriate configuration files yourself: global configuration like the
+      username setting is typically put into "%USERPROFILE%\mercurial.ini" or
+      "$HOME/.hgrc" and local configuration is put into the per-repository
+      "<repo>/.hg/hgrc" file.
+  
+      If there is a per-repository configuration file which is not owned by the
+      active user, Mercurial will warn you that the file is skipped:
+  
+        not trusting file <repo>/.hg/hgrc from untrusted user USER, group GROUP
+  
+      If this bothers you, the warning can be silenced (the file would still be
+      ignored) or trust can be established. Use one of the following settings,
+      the syntax is explained below:
+  
+      - "ui.report_untrusted = False"
+      - "trusted.users = USER"
+      - "trusted.groups = GROUP"
+  
+      The configuration files for Mercurial use a simple ini-file format. A
+      configuration file consists of sections, led by a "[section]" header and
+      followed by "name = value" entries:
+  
+        [ui]
+        username = Firstname Lastname <firstname.lastname at example.net>
+        verbose = True
+  
+      The above entries will be referred to as "ui.username" and "ui.verbose",
+      respectively. Please see the hgrc man page for a full description of the
+      possible configuration values:
+  
+      - on Unix-like systems: "man hgrc"
+      - online: http://www.selenic.com/mercurial/hgrc.5.html
+  
+  
+  subtopics:
+  
+    alias             Defines command aliases
+    auth              Authentication credentials for HTTP authentication
+    decode/encode     Filters for transforming files on checkout/checkin
+    defaults          Use the [defaults] section to define command defaults
+    diff              Settings used when displaying diffs
+    email             Settings for extensions that send email messages
+    extensions        Extension mechanism for adding new features
+    hostfingerprints  Fingerprints of the certificates of known HTTPS servers
+    format            Configuration for repository format
+    merge-patterns    Merge tools to associate with particular file patterns
+    merge-tools       Configures external merge tools to use for file-level merges
+    hooks             Commands or Python functions
+    http_proxy        Configuration for access web-based Mercurial repositories through a HTTP proxy
+    smtp              Configuration for extensions that need to send email messages
+    patch             Settings used when applying patches
+    paths             Assigns symbolic names to repositories
+    profiling         Specifies profiling format and file output
+    server            Controls generic server settings
+    subpaths          Defines subrepositories source locations rewriting rules of the form
+    trusted           specifies what users and groups are trusted
+    ui                User interface controls
+    web               Web interface configuration


More information about the Mercurial-devel mailing list