[PATCH 3 of 4] help: helptable is an ordered collection

Johannes Stezenbach js at sig21.net
Fri Jun 6 18:00:15 CDT 2008


3 files changed, 56 insertions(+), 57 deletions(-)
doc/gendoc.py         |    3 -
mercurial/commands.py |    6 +-
mercurial/help.py     |  104 ++++++++++++++++++++++++-------------------------


# HG changeset patch
# User Johannes Stezenbach <js at sig21.net>
# Date 1212519831 -7200
# Node ID 063a31138cde7910e79800d823a134b087017f0c
# Parent  02abce174989c944abd4f1ca2e93dfeb4d26b7a8
help: helptable is an ordered collection

The helptable is used for helptopics listed in the manual
page, so the order of topics should not be random.
Convert it from a dictionary into a tuple of tuples.
Also reorder helptable entries to keep previous manual
page order.

diff -r 02abce174989 -r 063a31138cde doc/gendoc.py
--- a/doc/gendoc.py	Tue Jun 03 20:56:54 2008 +0200
+++ b/doc/gendoc.py	Tue Jun 03 21:03:51 2008 +0200
@@ -92,11 +92,10 @@
             ui.write(_("    aliases: %s\n\n") % " ".join(d['aliases']))
 
     # print topics
-    for t in helptable:
+    for t, doc in helptable:
         l = t.split("|")
         section = l[-1]
         underlined(_(section).upper())
-        doc = helptable[t]
         if callable(doc):
             doc = doc()
         ui.write(_(doc))
diff -r 02abce174989 -r 063a31138cde mercurial/commands.py
--- a/mercurial/commands.py	Tue Jun 03 20:56:54 2008 +0200
+++ b/mercurial/commands.py	Tue Jun 03 21:03:51 2008 +0200
@@ -1320,16 +1320,16 @@
 
     def helptopic(name):
         v = None
-        for i in help.helptable:
+        for i, d in help.helptable:
             l = i.split('|')
             if name in l:
                 v = i
                 header = l[-1]
+                doc = d
         if not v:
             raise cmdutil.UnknownCommand(name)
 
         # description
-        doc = help.helptable[v]
         if not doc:
             doc = _("(No help text available)")
         if callable(doc):
@@ -1403,7 +1403,7 @@
     if ui.verbose:
         ui.write(_("\nspecial help topics:\n"))
         topics = []
-        for i in help.helptable:
+        for i, d in help.helptable:
             l = i.split('|')
             topics.append((", ".join(l[:-1]), l[-1]))
         topics_len = max([len(s[0]) for s in topics])
diff -r 02abce174989 -r 063a31138cde mercurial/help.py
--- a/mercurial/help.py	Tue Jun 03 20:56:54 2008 +0200
+++ b/mercurial/help.py	Tue Jun 03 21:03:51 2008 +0200
@@ -5,8 +5,8 @@
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
-helptable = {
-    "dates|Date Formats":
+helptable = (
+    ("dates|Date Formats",
     r'''
     Some commands allow the user to specify a date:
     backout, commit, import, tag: Specify the commit date.
@@ -43,9 +43,55 @@
     ">{date}" - on or after a given date
     "{date} to {date}" - a date range, inclusive
     "-{days}" - within a given number of days of today
-    ''',
+    '''),
 
-    'environment|env|Environment Variables':
+    ("patterns|File Name Patterns",
+    r'''
+    Mercurial accepts several notations for identifying one or more
+    files at a time.
+
+    By default, Mercurial treats filenames as shell-style extended
+    glob patterns.
+
+    Alternate pattern notations must be specified explicitly.
+
+    To use a plain path name without any pattern matching, start a
+    name with "path:".  These path names must match completely, from
+    the root of the current repository.
+
+    To use an extended glob, start a name with "glob:".  Globs are
+    rooted at the current directory; a glob such as "*.c" will match
+    files ending in ".c" in the current directory only.
+
+    The supported glob syntax extensions are "**" to match any string
+    across path separators, and "{a,b}" to mean "a or b".
+
+    To use a Perl/Python regular expression, start a name with "re:".
+    Regexp pattern matching is anchored at the root of the repository.
+
+    Plain examples:
+
+    path:foo/bar   a name bar in a directory named foo in the root of
+                   the repository
+    path:path:name a file or directory named "path:name"
+
+    Glob examples:
+
+    glob:*.c       any name ending in ".c" in the current directory
+    *.c            any name ending in ".c" in the current directory
+    **.c           any name ending in ".c" in the current directory, or
+                   any subdirectory
+    foo/*.c        any name ending in ".c" in the directory foo
+    foo/**.c       any name ending in ".c" in the directory foo, or any
+                   subdirectory
+
+    Regexp examples:
+
+    re:.*\.c$      any name ending in ".c", anywhere in the repository
+
+    '''),
+
+    ('environment|env|Environment Variables',
     r'''
 HG::
     Path to the 'hg' executable, automatically passed when running hooks,
@@ -114,51 +160,5 @@
 PYTHONPATH::
     This is used by Python to find imported modules and may need to be set
     appropriately if Mercurial is not installed system-wide.
-    ''',
-
-    "patterns|File Name Patterns": r'''
-    Mercurial accepts several notations for identifying one or more
-    files at a time.
-
-    By default, Mercurial treats filenames as shell-style extended
-    glob patterns.
-
-    Alternate pattern notations must be specified explicitly.
-
-    To use a plain path name without any pattern matching, start a
-    name with "path:".  These path names must match completely, from
-    the root of the current repository.
-
-    To use an extended glob, start a name with "glob:".  Globs are
-    rooted at the current directory; a glob such as "*.c" will match
-    files ending in ".c" in the current directory only.
-
-    The supported glob syntax extensions are "**" to match any string
-    across path separators, and "{a,b}" to mean "a or b".
-
-    To use a Perl/Python regular expression, start a name with "re:".
-    Regexp pattern matching is anchored at the root of the repository.
-
-    Plain examples:
-
-    path:foo/bar   a name bar in a directory named foo in the root of
-                   the repository
-    path:path:name a file or directory named "path:name"
-
-    Glob examples:
-
-    glob:*.c       any name ending in ".c" in the current directory
-    *.c            any name ending in ".c" in the current directory
-    **.c           any name ending in ".c" in the current directory, or
-                   any subdirectory
-    foo/*.c        any name ending in ".c" in the directory foo
-    foo/**.c       any name ending in ".c" in the directory foo, or any
-                   subdirectory
-
-    Regexp examples:
-
-    re:.*\.c$      any name ending in ".c", anywhere in the repository
-
-''',
-}
-
+    '''),
+)




More information about the Mercurial-devel mailing list