[PATCH with hgweb] help: use the first topic name from helptable, not the longest alias

Mads Kiilerich mads at kiilerich.com
Wed Aug 1 08:01:16 CDT 2012


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1343825955 -7200
# Branch stable
# Node ID d56a889d60412b940b35cbdb14e7b9c1ee1af62b
# Parent  91b336ff14b6d6f9b000f8cf60fc88b757822b49
help: use the first topic name from helptable, not the longest alias

This makes the 'additional help topics' list consistent with the output from
keyword search (for instance subrepo/subrepos).

The sorting by longest name was introduced in 3f6a4f1de43f. There might have
been a good reason for it back then, but now it seems like a better idea to
place the preferred name first in the list in helptable.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3297,7 +3297,7 @@
             rst.append(_("\nadditional help topics:\n\n"))
             topics = []
             for names, header, doc in help.helptable:
-                topics.append((sorted(names, key=len, reverse=True)[0], header))
+                topics.append((names[0], header))
             for t, desc in topics:
                 rst.append(" :%s: %s\n" % (t, desc))
 
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -143,19 +143,19 @@
     (["patterns"], _("File Name Patterns"), loaddoc('patterns')),
     (['environment', 'env'], _('Environment Variables'),
      loaddoc('environment')),
-    (['revs', 'revisions'], _('Specifying Single Revisions'),
+    (['revisions', 'revs'], _('Specifying Single Revisions'),
      loaddoc('revisions')),
-    (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'),
+    (['multirevs', 'mrevs'], _('Specifying Multiple Revisions'),
      loaddoc('multirevs')),
-    (['revset', 'revsets'], _("Specifying Revision Sets"), loaddoc('revsets')),
-    (['fileset', 'filesets'], _("Specifying File Sets"), loaddoc('filesets')),
+    (['revsets', 'revset'], _("Specifying Revision Sets"), loaddoc('revsets')),
+    (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets')),
     (['diffs'], _('Diff Formats'), loaddoc('diffs')),
     (['merge-tools'], _('Merge Tools'), loaddoc('merge-tools')),
     (['templating', 'templates', 'template', 'style'], _('Template Usage'),
      loaddoc('templates')),
     (['urls'], _('URL Paths'), loaddoc('urls')),
     (["extensions"], _("Using Additional Features"), extshelp),
-    (["subrepo", "subrepos"], _("Subrepositories"), loaddoc('subrepos')),
+    (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos')),
     (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')),
     (["glossary"], _("Glossary"), loaddoc('glossary')),
     (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"),
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -932,8 +932,7 @@
     if not topicname:
         def topics(**map):
             for entries, summary, _ in helpmod.helptable:
-                entries = sorted(entries, key=len)
-                yield {'topic': entries[-1], 'summary': summary}
+                yield {'topic': entries[0], 'summary': summary}
 
         early, other = [], []
         primary = lambda s: s.split('|')[0]
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -785,7 +785,7 @@
    extensions Using Additional Features
    glossary   Glossary
    phases     Working with Phases
-   subrepo    Subrepositories
+   subrepos   Subrepositories
    urls       URL Paths
   
   Commands:


More information about the Mercurial-devel mailing list