Submitter | timeless@mozdev.org |
---|---|
Date | Dec. 9, 2015, 6:15 a.m. |
Message ID | <2682bbc917733fb42a05.1449641756@waste.org> |
Download | mbox | patch |
Permalink | /patch/11948/ |
State | Superseded |
Headers | show |
Comments
Please ignore this in favor of the updated series: [PATCH 3 of 3] help: fix help -c/help -e/help -k On Wed, Dec 9, 2015 at 1:15 AM, timeless <timeless@mozdev.org> wrote: > # HG changeset patch > # User timeless <timeless@mozdev.org> > # Date 1449640614 0 > # Wed Dec 09 05:56:54 2015 +0000 > # Node ID 2682bbc917733fb42a054817dc57bc03765180ab > # Parent 42aa0e570eaa364a622bc4443b0bcb79b1100a58 > help: fix help -c/help -e/help -k > > Before, hg help -c was the same as hg help, now it only shows commands. > Before, hg help -e was the same as hg help, now it only shows extensions. > Before, hg help -k crashed, now it shows all topics. > > diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py > --- a/mercurial/dispatch.py > +++ b/mercurial/dispatch.py > @@ -854,7 +854,7 @@ > if options['version']: > return commands.version_(ui) > if options['help']: > - return commands.help_(ui, cmd, command=True) > + return commands.help_(ui, cmd, command=cmd is not None) > elif not cmd: > return commands.help_(ui, 'shortlist') > > diff --git a/mercurial/help.py b/mercurial/help.py > --- a/mercurial/help.py > +++ b/mercurial/help.py > @@ -319,7 +319,7 @@ > return rst > > > - def helplist(select=None): > + def helplist(select=None, **opts): > # list of commands > if name == "shortlist": > header = _('basic commands:\n\n') > @@ -367,7 +367,8 @@ > else: > rst.append(' :%s: %s\n' % (f, h[f])) > > - if not name: > + if not name and (opts.get('keyword') or not > + (opts.get('command') or opts.get('extension'))): > exts = listexts(_('enabled extensions:'), extensions.enabled()) > if exts: > rst.append('\n') > @@ -484,8 +485,8 @@ > > rst = [] > kw = opts.get('keyword') > - if kw: > - matches = topicmatch(ui, name) > + if kw or name is None and {(o, opts[o]) for o in opts if opts[o]}: > + matches = topicmatch(ui, name or '') > helpareas = [] > if opts.get('extension'): > helpareas += [('extensions', _('Extensions'))] > @@ -532,6 +533,6 @@ > # program name > if not ui.quiet: > rst = [_("Mercurial Distributed SCM\n"), '\n'] > - rst.extend(helplist()) > + rst.extend(helplist(None, **opts)) > > return ''.join(rst) > 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,15 @@ > > Test -e / -c / -k combinations > > + $ hg help -c|egrep '^\S' > + Commands: > + $ hg help -e|egrep '^\S' > + Extensions: > + $ hg help -k|egrep '^\S' > + Topics: > + Commands: > + Extensions: > + Extension Commands: > $ hg help -c schemes > abort: no such help topic: schemes > (try "hg help --keyword schemes") > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > https://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -854,7 +854,7 @@ if options['version']: return commands.version_(ui) if options['help']: - return commands.help_(ui, cmd, command=True) + return commands.help_(ui, cmd, command=cmd is not None) elif not cmd: return commands.help_(ui, 'shortlist') diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -319,7 +319,7 @@ return rst - def helplist(select=None): + def helplist(select=None, **opts): # list of commands if name == "shortlist": header = _('basic commands:\n\n') @@ -367,7 +367,8 @@ else: rst.append(' :%s: %s\n' % (f, h[f])) - if not name: + if not name and (opts.get('keyword') or not + (opts.get('command') or opts.get('extension'))): exts = listexts(_('enabled extensions:'), extensions.enabled()) if exts: rst.append('\n') @@ -484,8 +485,8 @@ rst = [] kw = opts.get('keyword') - if kw: - matches = topicmatch(ui, name) + if kw or name is None and {(o, opts[o]) for o in opts if opts[o]}: + matches = topicmatch(ui, name or '') helpareas = [] if opts.get('extension'): helpareas += [('extensions', _('Extensions'))] @@ -532,6 +533,6 @@ # program name if not ui.quiet: rst = [_("Mercurial Distributed SCM\n"), '\n'] - rst.extend(helplist()) + rst.extend(helplist(None, **opts)) return ''.join(rst) 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,15 @@ Test -e / -c / -k combinations + $ hg help -c|egrep '^\S' + Commands: + $ hg help -e|egrep '^\S' + Extensions: + $ hg help -k|egrep '^\S' + Topics: + Commands: + Extensions: + Extension Commands: $ hg help -c schemes abort: no such help topic: schemes (try "hg help --keyword schemes")