Patchwork [6,of,6] help: add --system flag to get help for various platform(s)

login
register
mail settings
Submitter timeless@mozdev.org
Date Jan. 10, 2016, 6:51 p.m.
Message ID <455d6ad112037108cbd5.1452451880@waste.org>
Download mbox | patch
Permalink /patch/12629/
State Accepted
Headers show

Comments

timeless@mozdev.org - Jan. 10, 2016, 6:51 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1452413038 0
#      Sun Jan 10 08:03:58 2016 +0000
# Node ID 455d6ad112037108cbd5627867c8765825f63948
# Parent  94715a3cae5a338231c71d5516dcc66af740802d
help: add --system flag to get help for various platform(s)
Sean Farley - Jan. 10, 2016, 9:25 p.m.
timeless <timeless@mozdev.org> writes:

> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1452413038 0
> #      Sun Jan 10 08:03:58 2016 +0000
> # Node ID 455d6ad112037108cbd5627867c8765825f63948
> # Parent  94715a3cae5a338231c71d5516dcc66af740802d
> help: add --system flag to get help for various platform(s)

Seems like a good improvement to me.
Bryan O'Sullivan - Jan. 14, 2016, 6:08 p.m.
On Sun, Jan 10, 2016 at 10:51 AM, timeless <timeless@mozdev.org> wrote:

> help: add --system flag to get help for various platform(s)
>

Series pushed to the clowncopter.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4377,8 +4377,9 @@ 
     [('e', 'extension', None, _('show only help for extensions')),
      ('c', 'command', None, _('show only help for commands')),
      ('k', 'keyword', None, _('show topics matching keyword')),
+     ('s', 'system', [], _('show help for specific platform(s)')),
      ],
-    _('[-eck] [TOPIC]'),
+    _('[-ecks] [TOPIC]'),
     norepo=True)
 def help_(ui, name=None, **opts):
     """show help for a given topic or a help overview
@@ -4393,18 +4394,19 @@ 
 
     textwidth = min(ui.termwidth(), 80) - 2
 
-    keep = []
+    keep = opts.get('system') or []
+    if len(keep) == 0:
+        if sys.platform.startswith('win'):
+            keep.append('windows')
+        elif sys.platform == 'OpenVMS':
+            keep.append('vms')
+        elif sys.platform == 'plan9':
+            keep.append('plan9')
+        else:
+            keep.append('unix')
+            keep.append(sys.platform.lower())
     if ui.verbose:
         keep.append('verbose')
-    if sys.platform.startswith('win'):
-        keep.append('windows')
-    elif sys.platform == 'OpenVMS':
-        keep.append('vms')
-    elif sys.platform == 'plan9':
-        keep.append('plan9')
-    else:
-        keep.append('unix')
-        keep.append(sys.platform.lower())
 
     section = None
     subtopic = None
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -278,7 +278,7 @@ 
   graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
   grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
   heads: rev, topo, active, closed, style, template
-  help: extension, command, keyword
+  help: extension, command, keyword, system
   identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
   import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
   incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1251,6 +1251,15 @@ 
   $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
   [1]
 
+Test -s / --system
+
+  $ hg help config.files -s windows |grep 'etc/mercurial' | \
+  > wc -l | sed -e 's/ //g'
+  0
+  $ hg help config.files --system unix | grep 'USER' | \
+  > wc -l | sed -e 's/ //g'
+  0
+
 Test -e / -c / -k combinations
 
   $ hg help -c|egrep '^[A-Z].*:|^ debug'