[PATCH] help: exclude debug commands
timeless
timeless at mozdev.org
Fri Oct 16 18:51:29 UTC 2015
# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1444979541 14400
# Fri Oct 16 03:12:21 2015 -0400
# Node ID c90f848222a9acd1ecf6f5b9273cf7b7ef727ef7
# Parent e8f1b728591786143174515ea18089db0df4af90
help: exclude debug commands
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -105,6 +105,8 @@
results['topics'].append((names[0], header))
import commands # avoid cycle
for cmd, entry in commands.table.iteritems():
+ if not ui.verbose and cmd.startswith('debug'):
+ continue
if len(entry) == 3:
summary = entry[2]
else:
@@ -123,10 +125,14 @@
# extensions.load ignores the UI argument
mod = extensions.load(None, name, '')
name = name.split('.')[-1]
+ if not ui.verbose and name.startswith('debug'):
+ continue
if lowercontains(name) or lowercontains(docs):
# extension docs are already translated
results['extensions'].append((name, docs.splitlines()[0]))
for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
+ if not ui.verbose and cmd.startswith('debug'):
+ continue
if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
cmdname = cmd.split('|')[0].lstrip('^')
if entry[0].__doc__:
@@ -483,7 +489,19 @@
rst = []
kw = opts.get('keyword')
if kw:
+ def hasmatches(m):
+ for l in m.values():
+ if l:
+ return True
+ return False
matches = topicmatch(ui, name)
+ debughidden = False
+ if not ui.verbose and not hasmatches(matches):
+ ui.verbose = True
+ try:
+ debughidden = hasmatches(topicmatch(ui, name))
+ finally:
+ ui.verbose = False
helpareas = []
if opts.get('extension'):
helpareas += [('extensions', _('Extensions'))]
@@ -501,7 +519,12 @@
rst.append('\n')
if not rst:
msg = _('no matches')
- hint = _('try "hg help" for a list of topics')
+ if debughidden:
+ args = ['--%s' % a for a in opts.keys() if opts[a]]
+ args = ' '.join(args+[repr(name)])
+ hint = _('try "hg help -v %s"') % args
+ else:
+ hint = _('try "hg help" for a list of topics')
raise error.Abort(msg, hint=hint)
elif name and name != 'shortlist':
queries = []
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1043,6 +1043,12 @@
abort: no such help topic: commit
(try "hg help --keyword commit")
[255]
+ $ hg help -k 'find the ancestor revision' |grep debugancestor
+ abort: no matches
+ (try "hg help -v --keyword 'find the ancestor revision'")
+ [1]
+ $ hg help -v -k 'find the ancestor revision' |grep debugancestor
+ debugancestor find the ancestor revision of two revisions in a given index
Test keyword search help
More information about the Mercurial-devel
mailing list