Patchwork [enhancement,1] hg help: give users free choice of help output width, adapt to any COLUMNS setting desired by user

login
register
mail settings
Submitter Roland Eggner
Date Dec. 31, 2013, 1:40 a.m.
Message ID <20131231014003.GL23913@mobil.systemanalysen.net>
Download mbox | patch
Permalink /patch/3249/
State Superseded
Headers show

Comments

Roland Eggner - Dec. 31, 2013, 1:40 a.m.
# HG changeset patch
# Parent eb31309bcc00e97c3af2f6f77fc025d0b331b8b2
# User Roland Eggner < odv@systomanalyson.not s/o/e/g >
# Date 1388262822 -3600

hg help: give users free choice of help output width, adapt to any COLUMNS setting desired by user

COLUMNS=80:   “hg help“ output unmodified
COLUMNS=96:   “hg help” output nicer, increased width of first field saves all continuation lines
COLUMNS=160:  “hg help -v” output nicer, increased width of first field saves all continuation lines

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3411,7 +3411,7 @@  def help_(ui, name=None, **opts):
     Returns 0 if successful.
     """
 
-    textwidth = min(ui.termwidth(), 80) - 2
+    textwidth = ui.termwidth() - 2
 
     keep = ui.verbose and ['verbose'] or []
     text = help.help_(ui, name, **opts)
diff --git a/mercurial/minirst.py b/mercurial/minirst.py
--- a/mercurial/minirst.py
+++ b/mercurial/minirst.py
@@ -182,8 +182,6 @@  def splitparagraphs(blocks):
         i += 1
     return blocks
 
-_fieldwidth = 14
-
 def updatefieldlists(blocks):
     """Find key for field lists."""
     i = 0
@@ -503,6 +501,9 @@  def formatblock(block, width):
         return '%s\n%s\n' % (term, util.wrap(text, width=width,
                                              initindent=defindent,
                                              hangindent=defindent))
+    # _fieldwidth + 1 = width of commands column in command table
+    # _fieldwidth + 1 = indention of continuation lines
+    _fieldwidth = min(width / 6 + 1, 26)
     subindent = indent
     if block['type'] == 'bullet':
         if block['lines'][0].startswith('| '):
diff --git a/tests/test-minirst.py.out b/tests/test-minirst.py.out
--- a/tests/test-minirst.py.out
+++ b/tests/test-minirst.py.out
@@ -414,37 +414,34 @@  marker after the option. It is treated a
 == fields ==
 60 column format:
 ----------------------------------------------------------------------
-a             First item.
-ab            Second item. Indentation and wrapping is
-              handled automatically.
+a          First item.
+ab         Second item. Indentation and wrapping is handled
+           automatically.
 
 Next list:
 
-small         The larger key below triggers full indentation
-              here.
+small      The larger key below triggers full indentation
+           here.
 much too large
-              This key is big enough to get its own line.
+           This key is big enough to get its own line.
 ----------------------------------------------------------------------
 
 30 column format:
 ----------------------------------------------------------------------
-a             First item.
-ab            Second item.
-              Indentation and
-              wrapping is
-              handled
-              automatically.
+a     First item.
+ab    Second item. Indentation
+      and wrapping is handled
+      automatically.
 
 Next list:
 
-small         The larger key
-              below triggers
-              full indentation
-              here.
+small
+      The larger key below
+      triggers full
+      indentation here.
 much too large
-              This key is big
-              enough to get
-              its own line.
+      This key is big enough
+      to get its own line.
 ----------------------------------------------------------------------
 
 html format: