Commit c2e2466e authored by Rodrigo Damazio Bovendorp's avatar Rodrigo Damazio Bovendorp
Browse files

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
parent 9c6473d2038b
......@@ -993,7 +993,8 @@ def absorb(ui, repo, stack=None, targetctx=None, pats=None, opts=None):
_('edit what lines belong to which changesets before commit '
'(EXPERIMENTAL)')),
] + commands.dryrunopts + commands.templateopts + commands.walkopts,
_('hg absorb [OPTION] [FILE]...'))
_('hg absorb [OPTION] [FILE]...'),
helpcategory=command.CATEGORY_COMMITTING)
def absorbcmd(ui, repo, *pats, **opts):
"""incorporate corrections into the stack of draft changesets
......
......@@ -38,6 +38,7 @@ command = registrar.command(cmdtable)
('n', 'note', '', _('store a note on the amend')),
] + cmdutil.walkopts + cmdutil.commitopts + cmdutil.commitopts2,
_('[OPTION]... [FILE]...'),
helpcategory=command.CATEGORY_COMMITTING,
inferrepo=True)
def amend(ui, repo, *pats, **opts):
"""amend the working copy parent with all or specified outstanding changes
......
......@@ -229,7 +229,8 @@ def reposetup(ui, repo):
@command('^blackbox',
[('l', 'limit', 10, _('the number of events to show')),
],
_('hg blackbox [OPTION]...'))
_('hg blackbox [OPTION]...'),
helpcategory=command.CATEGORY_MAINTENANCE)
def blackbox(ui, repo, *revs, **opts):
'''view the recent repository events
'''
......
......@@ -47,7 +47,8 @@ testedwith = 'ships-with-hg-core'
@command('censor',
[('r', 'rev', '', _('censor file from specified revision'), _('REV')),
('t', 'tombstone', '', _('replacement tombstone data'), _('TEXT'))],
_('-r REV [-t TEXT] [FILE]'))
_('-r REV [-t TEXT] [FILE]'),
helpcategory=command.CATEGORY_MAINTENANCE)
def censor(ui, repo, path, rev='', tombstone='', **opts):
with repo.wlock(), repo.lock():
return _docensor(ui, repo, path, rev, tombstone, **opts)
......
......@@ -40,6 +40,7 @@ testedwith = 'ships-with-hg-core'
_('show children of the specified revision'), _('REV')),
] + templateopts,
_('hg children [-r REV] [FILE]'),
helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
inferrepo=True)
def children(ui, repo, file_=None, **opts):
"""show the children of the given or working directory revision
......
......@@ -116,6 +116,7 @@ def countrate(ui, repo, amap, *pats, **opts):
('', 'aliases', '', _('file with email aliases'), _('FILE')),
] + cmdutil.walkopts,
_("hg churn [-d DATE] [-r REV] [--aliases FILE] [FILE]"),
helpcategory=command.CATEGORY_MAINTENANCE,
inferrepo=True)
def churn(ui, repo, *pats, **opts):
'''histogram of changes to the repository
......
......@@ -32,7 +32,9 @@ commitopts3 = [('r', 'rev', [],
_('revision to check'), _('REV'))]
@command('close-head|close-heads', commitopts + commitopts2 + commitopts3,
_('[OPTION]... [REV]...'), inferrepo=True)
_('[OPTION]... [REV]...'),
helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
inferrepo=True)
def close_branch(ui, repo, *revs, **opts):
"""close the given head revisions
......
......@@ -338,6 +338,7 @@ extdiffopts = [
[('p', 'program', '', _('comparison program to run'), _('CMD')),
] + extdiffopts,
_('hg extdiff [OPT]... [FILE]...'),
helpcategory=command.CATEGORY_FILE_CONTENTS,
inferrepo=True)
def extdiff(ui, repo, *pats, **opts):
'''use external program to diff repository (or selected files)
......
......@@ -41,7 +41,8 @@ testedwith = 'ships-with-hg-core'
('', 'force-editor', None, _('edit commit message (DEPRECATED)')),
('', 'switch-parent', None, _('switch parents when merging')),
] + cmdutil.commitopts + cmdutil.commitopts2 + cmdutil.remoteopts,
_('hg fetch [SOURCE]'))
_('hg fetch [SOURCE]'),
helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT)
def fetch(ui, repo, source='default', **opts):
'''pull changes from a remote repository, merge new changes if needed.
......
......@@ -109,7 +109,8 @@ wdiropt = ('w', 'working-dir', False, _('fix the working directory'))
wholeopt = ('', 'whole', False, _('always fix every line of a file'))
usage = _('[OPTION]... [FILE]...')
@command('fix', [allopt, baseopt, revopt, wdiropt, wholeopt], usage)
@command('fix', [allopt, baseopt, revopt, wdiropt, wholeopt], usage,
helpcategory=command.CATEGORY_FILE_CONTENTS)
def fix(ui, repo, *pats, **opts):
"""rewrite file content in changesets or working directory
......
......@@ -51,7 +51,8 @@ def convert(s):
return s
@command('^githelp|git', [
], _('hg githelp'))
], _('hg githelp'),
helpcategory=command.CATEGORY_HELP)
def githelp(ui, repo, *args, **kwargs):
'''suggests the Mercurial equivalent of the given git command
......
......@@ -14,6 +14,7 @@ from mercurial.i18n import _
from mercurial import (
cmdutil,
error,
help,
match,
node as hgnode,
pycompat,
......@@ -46,6 +47,9 @@ configitem('gpg', '.*',
generic=True,
)
# Custom help category
_HELP_CATEGORY = 'gpg'
class gpg(object):
def __init__(self, path, key=None):
self.path = path
......@@ -169,7 +173,7 @@ def getkeys(ui, repo, mygpg, sigdata, context):
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 @@ def sigs(ui, repo):
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 @@ def keystr(ui, key):
_('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 @@ def node2txt(repo, node, ver):
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'
......@@ -54,6 +54,7 @@ testedwith = 'ships-with-hg-core'
_('do not display revision or any of its ancestors'), _('REV')),
] + cmdutil.logopts + cmdutil.walkopts,
_('[OPTION]... [FILE]'),
helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
inferrepo=True)
def glog(ui, repo, *pats, **opts):
"""show revision history alongside an ASCII revision graph
......
......@@ -345,7 +345,8 @@ def revlist(ui, repo, *revs, **opts):
@command('view',
[('l', 'limit', '',
_('limit number of changes displayed'), _('NUM'))],
_('[-l LIMIT] [REVRANGE]'))
_('[-l LIMIT] [REVRANGE]'),
helpcategory=command.CATEGORY_CHANGE_NAVIGATION)
def view(ui, repo, *etc, **opts):
"start interactive history viewer"
opts = pycompat.byteskwargs(opts)
......
......@@ -929,7 +929,8 @@ def findoutgoing(ui, repo, remote=None, force=False, opts=None):
_('force outgoing even for unrelated repositories')),
('r', 'rev', [], _('first revision to be edited'), _('REV'))] +
cmdutil.formatteropts,
_("[OPTIONS] ([ANCESTOR] | --outgoing [URL])"))
_("[OPTIONS] ([ANCESTOR] | --outgoing [URL])"),
helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
def histedit(ui, repo, *freeargs, **opts):
"""interactively edit changeset history
......
......@@ -440,7 +440,8 @@ _ignoreopts = ('no-merges', 'graph')
('', 'all', None, 'show history for all names'),
('c', 'commits', None, 'show commit metadata'),
] + [opt for opt in cmdutil.logopts if opt[1] not in _ignoreopts],
'[OPTION]... [BOOKMARKNAME]')
'[OPTION]... [BOOKMARKNAME]',
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def journal(ui, repo, *args, **opts):
"""show the previous position of bookmarks and the working copy
......
......@@ -2266,7 +2266,8 @@ def fixkeepchangesopts(ui, opts):
[('k', 'keep', None, _('keep patch file')),
('r', 'rev', [],
_('stop managing a revision (DEPRECATED)'), _('REV'))],
_('hg qdelete [-k] [PATCH]...'))
_('hg qdelete [-k] [PATCH]...'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def delete(ui, repo, *patches, **opts):
"""remove patches from queue
......@@ -2284,7 +2285,8 @@ def delete(ui, repo, *patches, **opts):
@command("qapplied",
[('1', 'last', None, _('show only the preceding applied patch'))
] + seriesopts,
_('hg qapplied [-1] [-s] [PATCH]'))
_('hg qapplied [-1] [-s] [PATCH]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def applied(ui, repo, patch=None, **opts):
"""print the patches already applied
......@@ -2318,7 +2320,8 @@ def applied(ui, repo, patch=None, **opts):
@command("qunapplied",
[('1', 'first', None, _('show only the first patch'))] + seriesopts,
_('hg qunapplied [-1] [-s] [PATCH]'))
_('hg qunapplied [-1] [-s] [PATCH]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def unapplied(ui, repo, patch=None, **opts):
"""print the patches not yet applied
......@@ -2353,7 +2356,8 @@ def unapplied(ui, repo, patch=None, **opts):
_('place existing revisions under mq control'), _('REV')),
('g', 'git', None, _('use git extended diff format')),
('P', 'push', None, _('qpush after importing'))],
_('hg qimport [-e] [-n NAME] [-f] [-g] [-P] [-r REV]... [FILE]...'))
_('hg qimport [-e] [-n NAME] [-f] [-g] [-P] [-r REV]... [FILE]...'),
helpcategory=command.CATEGORY_IMPORT_EXPORT)
def qimport(ui, repo, *filename, **opts):
"""import a patch or existing changeset
......@@ -2431,7 +2435,8 @@ def qinit(ui, repo, create):
@command("^qinit",
[('c', 'create-repo', None, _('create queue repository'))],
_('hg qinit [-c]'))
_('hg qinit [-c]'),
helpcategory=command.CATEGORY_REPO_CREATION)
def init(ui, repo, **opts):
"""init a new queue repository (DEPRECATED)
......@@ -2455,6 +2460,7 @@ def init(ui, repo, **opts):
_('location of source patch repository'), _('REPO')),
] + cmdutil.remoteopts,
_('hg qclone [OPTION]... SOURCE [DEST]'),
helpcategory=command.CATEGORY_REPO_CREATION,
norepo=True)
def clone(ui, source, dest=None, **opts):
'''clone main and patch repository at same time
......@@ -2536,6 +2542,7 @@ def clone(ui, source, dest=None, **opts):
@command("qcommit|qci",
commands.table["^commit|ci"][1],
_('hg qcommit [OPTION]... [FILE]...'),
helpcategory=command.CATEGORY_COMMITTING,
inferrepo=True)
def commit(ui, repo, *pats, **opts):
"""commit changes in the queue repository (DEPRECATED)
......@@ -2550,7 +2557,8 @@ def commit(ui, repo, *pats, **opts):
@command("qseries",
[('m', 'missing', None, _('print patches not in series')),
] + seriesopts,
_('hg qseries [-ms]'))
_('hg qseries [-ms]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def series(ui, repo, **opts):
"""print the entire series file
......@@ -2559,7 +2567,8 @@ def series(ui, repo, **opts):
summary=opts.get(r'summary'))
return 0
@command("qtop", seriesopts, _('hg qtop [-s]'))
@command("qtop", seriesopts, _('hg qtop [-s]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def top(ui, repo, **opts):
"""print the name of the current patch
......@@ -2577,7 +2586,8 @@ def top(ui, repo, **opts):
ui.write(_("no patches applied\n"))
return 1
@command("qnext", seriesopts, _('hg qnext [-s]'))
@command("qnext", seriesopts, _('hg qnext [-s]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def next(ui, repo, **opts):
"""print the name of the next pushable patch
......@@ -2589,7 +2599,8 @@ def next(ui, repo, **opts):
return 1
q.qseries(repo, start=end, length=1, summary=opts.get(r'summary'))
@command("qprev", seriesopts, _('hg qprev [-s]'))
@command("qprev", seriesopts, _('hg qprev [-s]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def prev(ui, repo, **opts):
"""print the name of the preceding applied patch
......@@ -2624,6 +2635,7 @@ def setupheaderopts(ui, opts):
_('add "Date: <DATE>" to patch'), _('DATE'))
] + cmdutil.walkopts + cmdutil.commitopts,
_('hg qnew [-e] [-m TEXT] [-l FILE] PATCH [FILE]...'),
helpcategory=command.CATEGORY_COMMITTING,
inferrepo=True)
def new(ui, repo, patch, *args, **opts):
"""create a new patch
......@@ -2674,6 +2686,7 @@ def new(ui, repo, patch, *args, **opts):
_('add/update date field in patch with given date'), _('DATE'))
] + cmdutil.walkopts + cmdutil.commitopts,
_('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...'),
helpcategory=command.CATEGORY_COMMITTING,
inferrepo=True)
def refresh(ui, repo, *pats, **opts):
"""update the current patch
......@@ -2708,6 +2721,7 @@ def refresh(ui, repo, *pats, **opts):
@command("^qdiff",
cmdutil.diffopts + cmdutil.diffopts2 + cmdutil.walkopts,
_('hg qdiff [OPTION]... [FILE]...'),
helpcategory=command.CATEGORY_FILE_CONTENTS,
inferrepo=True)
def diff(ui, repo, *pats, **opts):
"""diff of the current patch and subsequent modifications
......@@ -2732,7 +2746,8 @@ def diff(ui, repo, *pats, **opts):
[('e', 'edit', None, _('invoke editor on commit messages')),
('k', 'keep', None, _('keep folded patch files')),
] + cmdutil.commitopts,
_('hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...'))
_('hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...'),
helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
def fold(ui, repo, *files, **opts):
"""fold the named patches into the current patch
......@@ -2801,7 +2816,8 @@ def fold(ui, repo, *files, **opts):
_('tolerate non-conflicting local changes')),
('f', 'force', None, _('overwrite any local changes')),
('', 'no-backup', None, _('do not save backup copies of files'))],
_('hg qgoto [OPTION]... PATCH'))
_('hg qgoto [OPTION]... PATCH'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def goto(ui, repo, patch, **opts):
'''push or pop patches until named patch is at top of stack
......@@ -2824,7 +2840,8 @@ def goto(ui, repo, patch, **opts):
@command("qguard",
[('l', 'list', None, _('list all patches and guards')),
('n', 'none', None, _('drop all guards'))],
_('hg qguard [-l] [-n] [PATCH] [-- [+GUARD]... [-GUARD]...]'))
_('hg qguard [-l] [-n] [PATCH] [-- [+GUARD]... [-GUARD]...]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def guard(ui, repo, *args, **opts):
'''set or print guards for a patch
......@@ -2896,7 +2913,8 @@ def guard(ui, repo, *args, **opts):
else:
status(q.series.index(q.lookup(patch)))
@command("qheader", [], _('hg qheader [PATCH]'))
@command("qheader", [], _('hg qheader [PATCH]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def header(ui, repo, patch=None):
"""print the header of the topmost or specified patch
......@@ -2952,7 +2970,8 @@ def savename(path):
('', 'move', None,
_('reorder patch series and apply only the patch')),
('', 'no-backup', None, _('do not save backup copies of files'))],
_('hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]'))
_('hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def push(ui, repo, patch=None, **opts):
"""push the next patch onto the stack
......@@ -2992,7 +3011,8 @@ def push(ui, repo, patch=None, **opts):
_('tolerate non-conflicting local changes')),
('f', 'force', None, _('forget any local changes to patched files')),
('', 'no-backup', None, _('do not save backup copies of files'))],
_('hg qpop [-a] [-f] [PATCH | INDEX]'))
_('hg qpop [-a] [-f] [PATCH | INDEX]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def pop(ui, repo, patch=None, **opts):
"""pop the current patch off the stack
......@@ -3022,7 +3042,8 @@ def pop(ui, repo, patch=None, **opts):
q.savedirty()
return ret
@command("qrename|qmv", [], _('hg qrename PATCH1 [PATCH2]'))
@command("qrename|qmv", [], _('hg qrename PATCH1 [PATCH2]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def rename(ui, repo, patch, name=None, **opts):
"""rename a patch
......@@ -3080,7 +3101,8 @@ def rename(ui, repo, patch, name=None, **opts):
@command("qrestore",
[('d', 'delete', None, _('delete save entry')),
('u', 'update', None, _('update queue working directory'))],
_('hg qrestore [-d] [-u] REV'))
_('hg qrestore [-d] [-u] REV'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def restore(ui, repo, rev, **opts):
"""restore the queue state saved by a revision (DEPRECATED)
......@@ -3098,7 +3120,8 @@ def restore(ui, repo, rev, **opts):
_('copy directory name'), _('NAME')),
('e', 'empty', None, _('clear queue status file')),
('f', 'force', None, _('force copy'))] + cmdutil.commitopts,
_('hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'))
_('hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def save(ui, repo, **opts):
"""save current queue state (DEPRECATED)
......@@ -3137,7 +3160,8 @@ def save(ui, repo, **opts):
('s', 'series', None, _('list all guards in series file')),
('', 'pop', None, _('pop to before first guarded applied patch')),
('', 'reapply', None, _('pop, then reapply patches'))],
_('hg qselect [OPTION]... [GUARD]...'))
_('hg qselect [OPTION]... [GUARD]...'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def select(ui, repo, *args, **opts):
'''set or print guarded patches to push
......@@ -3246,7 +3270,8 @@ def select(ui, repo, *args, **opts):
@command("qfinish",
[('a', 'applied', None, _('finish all applied changesets'))],
_('hg qfinish [-a] [REV]...'))
_('hg qfinish [-a] [REV]...'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def finish(ui, repo, *revrange, **opts):
"""move applied patches into repository history
......@@ -3294,7 +3319,8 @@ def finish(ui, repo, *revrange, **opts):
('', 'delete', False, _('delete reference to queue')),
('', 'purge', False, _('delete queue, and remove patch dir')),
],
_('[OPTION] [QUEUE]'))
_('[OPTION] [QUEUE]'),
helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
def qqueue(ui, repo, name=None, **opts):
'''manage multiple patch queues
......
......@@ -509,7 +509,8 @@ emailopts = [
'(with -b/--bundle)'), _('REV')),
('', 'intro', None, _('send an introduction email for a single patch')),
] + emailopts + cmdutil.remoteopts,
_('hg email [OPTION]... [DEST]...'))
_('hg email [OPTION]... [DEST]...'),
helpcategory=command.CATEGORY_IMPORT_EXPORT)
def email(ui, repo, *revs, **opts):
'''send changesets by email
......
......@@ -51,7 +51,8 @@ testedwith = 'ships-with-hg-core'
('0', 'print0', None, _('end filenames with NUL, for use with xargs'
' (implies -p/--print)')),
] + cmdutil.walkopts,
_('hg purge [OPTION]... [DIR]...'))
_('hg purge [OPTION]... [DIR]...'),
helpcategory=command.CATEGORY_MAINTENANCE)
def purge(ui, repo, *dirs, **opts):
'''removes files not tracked by Mercurial
......
......@@ -679,7 +679,8 @@ class rebaseruntime(object):
('', 'auto-orphans', '', _('automatically rebase orphan revisions '
'in the specified revset (EXPERIMENTAL)')),
] + cmdutil.dryrunopts + cmdutil.formatteropts + cmdutil.confirmopts,
_('[-s REV | -b REV] [-d REV] [OPTION]'))
_('[-s REV | -b REV] [-d REV] [OPTION]'),
helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
def rebase(ui, repo, **opts):
"""move changeset (and descendants) to a different branch
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment