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

timeless timeless at mozdev.org
Sun Jan 10 12:51:20 CST 2016


# HG changeset patch
# User timeless <timeless at 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)

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'


More information about the Mercurial-devel mailing list