Mercurial > public > mercurial-scm > hg-stable
diff hgext/gpg.py @ 40293:c303d65d2e34
help: assigning categories to existing commands
I'm separating this into its own commit so people can bikeshed over the actual
categorization (vs the support for categories). These categories are based on
the help implementation we've been using internally at Google, and have had
zero complaints.
Differential Revision: https://phab.mercurial-scm.org/D5067
author | rdamazio@google.com |
---|---|
date | Sat, 13 Oct 2018 02:17:41 -0700 |
parents | aac4be30e250 |
children | 0531dff73d0b |
line wrap: on
line diff
--- a/hgext/gpg.py Fri Oct 12 17:57:36 2018 +0200 +++ b/hgext/gpg.py Sat Oct 13 02:17:41 2018 -0700 @@ -14,6 +14,7 @@ from mercurial import ( cmdutil, error, + help, match, node as hgnode, pycompat, @@ -46,6 +47,9 @@ generic=True, ) +# Custom help category +_HELP_CATEGORY = 'gpg' + class gpg(object): def __init__(self, path, key=None): self.path = path @@ -169,7 +173,7 @@ validkeys.append((key[1], key[2], key[3])) return validkeys -@command("sigs", [], _('hg sigs')) +@command("sigs", [], _('hg sigs'), helpcategory=_HELP_CATEGORY) def sigs(ui, repo): """list signed changesets""" mygpg = newgpg(ui) @@ -194,7 +198,7 @@ r = "%5d:%s" % (rev, hgnode.hex(repo.changelog.node(rev))) ui.write("%-30s %s\n" % (keystr(ui, k), r)) -@command("sigcheck", [], _('hg sigcheck REV')) +@command("sigcheck", [], _('hg sigcheck REV'), helpcategory=_HELP_CATEGORY) def sigcheck(ui, repo, rev): """verify all the signatures there may be for a particular revision""" mygpg = newgpg(ui) @@ -237,7 +241,8 @@ _('use text as commit message'), _('TEXT')), ('e', 'edit', False, _('invoke editor on commit messages')), ] + cmdutil.commitopts2, - _('hg sign [OPTION]... [REV]...')) + _('hg sign [OPTION]... [REV]...'), + helpcategory=_HELP_CATEGORY) def sign(ui, repo, *revs, **opts): """add a signature for the current or given revision @@ -327,3 +332,10 @@ return "%s\n" % hgnode.hex(node) else: raise error.Abort(_("unknown signature version")) + +def extsetup(ui): + # Add our category before "Repository maintenance". + help.CATEGORY_ORDER.insert( + help.CATEGORY_ORDER.index(command.CATEGORY_MAINTENANCE), + _HELP_CATEGORY) + help.CATEGORY_NAMES[_HELP_CATEGORY] = 'GPG signing'