[PATCH 2 of 2] help: show all nested subsections of a section with `hg help foo.section`
Jordi Gutiérrez Hermoso
jordigh at octave.org
Mon Oct 6 09:56:13 CDT 2014
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh at octave.org>
# Date 1412595353 14400
# Mon Oct 06 07:35:53 2014 -0400
# Node ID 8b09e0c3c0f8e80ed1351d8c251960ada71df36d
# Parent 3fa01b749ab5a44a214bc0936223bd280bb24b79
help: show all nested subsections of a section with `hg help foo.section`
Used to be that `hg help hgrc.paths` would show
"paths"
-------
Assigns symbolic names to repositories. The left side is the symbolic
name, and the right gives the directory or URL that is the location of the
repository. Default paths can be declared by setting the following
entries.
and stop there. Obviously the result seems better as shown in the
attached test.
diff --git a/mercurial/minirst.py b/mercurial/minirst.py
--- a/mercurial/minirst.py
+++ b/mercurial/minirst.py
@@ -654,9 +654,18 @@ def format(text, width=80, indent=0, kee
if section:
sections = getsections(blocks)
blocks = []
- for name, nest, b in sections:
+ i = 0
+ while i < len(sections):
+ name, nest, b = sections[i]
if name == section:
- blocks = b
+ blocks.extend(b)
+
+ ## Also show all subnested sections
+ while i+1 < len(sections) and sections[i+1][1] > nest:
+ i += 1
+ blocks.extend(sections[i][2])
+ i += 1
+
if style == 'html':
text = formathtml(blocks)
else:
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1061,6 +1061,35 @@ Test section lookup
graphical tools such as "hg log --graph". In Mercurial, the DAG is
limited by the requirement for children to have at most two parents.
+
+ $ hg help hgrc.paths
+ "paths"
+ -------
+
+ Assigns symbolic names to repositories. The left side is the symbolic
+ name, and the right gives the directory or URL that is the location of the
+ repository. Default paths can be declared by setting the following
+ entries.
+
+ "default"
+ Directory or URL to use when pulling if no source is specified.
+ Default is set to repository from which the current repository was
+ cloned.
+
+ "default-push"
+ Optional. Directory or URL to use when pushing if no destination is
+ specified.
+
+ Custom paths can be defined by assigning the path to a name that later can
+ be used from the command line. Example:
+
+ [paths]
+ my_path = http://example.com/path
+
+ To push to the path defined in "my_path" run the command:
+
+ hg push my_path
+
$ hg help glossary.mcguffin
abort: help section not found
[255]
More information about the Mercurial-devel
mailing list