[PATCH] help: support 'hg help template.somekeyword'

Matt Harbison mharbison72 at gmail.com
Sat Jul 4 23:02:48 CDT 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1436065892 14400
#      Sat Jul 04 23:11:32 2015 -0400
# Node ID c10f33a78d3f0e92771f750890acd9f53e9ac102
# Parent  16578c82dd40878df4ef02cf1f036572b7c8a190
help: support 'hg help template.somekeyword'

Previously the output was simply 'abort: help section not found'.

diff --git a/mercurial/minirst.py b/mercurial/minirst.py
--- a/mercurial/minirst.py
+++ b/mercurial/minirst.py
@@ -682,7 +682,10 @@
     secs = []
 
     def getname(b):
-        x = b['lines'][0]
+        if b['type'] == 'field':
+            x = b['key']
+        else:
+            x = b['lines'][0]
         x = x.lower().strip('"')
         if '(' in x:
             x = x.split('(')[0]
@@ -696,7 +699,7 @@
             level = nest.index(i) + 1
             nest = nest[:level]
             secs.append((getname(b), level, [b]))
-        elif b['type'] == 'definition':
+        elif b['type'] in ('definition', 'field'):
             i = ' '
             if i not in nest:
                 nest += i
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1117,6 +1117,10 @@
   abort: help section not found
   [255]
 
+  $ hg help template.files
+      files         List of strings. All files modified, added, or removed by
+                    this changeset.
+
 Test dynamic list of merge tools only shows up once
   $ hg help merge-tools
   Merge Tools


More information about the Mercurial-devel mailing list