Mercurial > hg-stable
changeset 14299:f3ba4125d9e9
gpg: use cmdutil.command decorator
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Thu, 12 May 2011 14:31:01 +0200 |
parents | 21719639276d |
children | 1b8e421d8e42 |
files | hgext/gpg.py |
diffstat | 1 files changed, 16 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/gpg.py Thu May 12 14:25:08 2011 +0200 +++ b/hgext/gpg.py Thu May 12 14:31:01 2011 +0200 @@ -6,10 +6,13 @@ '''commands to sign and verify changesets''' import os, tempfile, binascii -from mercurial import util, commands, match +from mercurial import util, commands, match, cmdutil from mercurial import node as hgnode from mercurial.i18n import _ +cmdtable = {} +command = cmdutil.command(cmdtable) + class gpg(object): def __init__(self, path, key=None): self.path = path @@ -135,6 +138,7 @@ validkeys.append((key[1], key[2], key[3])) return validkeys +@command("sigs", [], _('hg sigs')) def sigs(ui, repo): """list signed changesets""" mygpg = newgpg(ui) @@ -159,6 +163,7 @@ r = "%5d:%s" % (rev, hgnode.hex(repo.changelog.node(rev))) ui.write("%-30s %s\n" % (keystr(ui, k), r)) +@command("sigcheck", [], _('hg sigcheck REVISION')) def check(ui, repo, rev): """verify all the signatures there may be for a particular revision""" mygpg = newgpg(ui) @@ -191,6 +196,16 @@ else: return user +@command("sign", + [('l', 'local', None, _('make the signature local')), + ('f', 'force', None, _('sign even if the sigfile is modified')), + ('', 'no-commit', None, _('do not commit the sigfile after signing')), + ('k', 'key', '', + _('the key id to sign with'), _('ID')), + ('m', 'message', '', + _('commit message'), _('TEXT')), + ] + commands.commitopts2, + _('hg sign [OPTION]... [REVISION]...')) def sign(ui, repo, *revs, **opts): """add a signature for the current or given revision @@ -272,19 +287,3 @@ else: raise util.Abort(_("unknown signature version")) -cmdtable = { - "sign": - (sign, - [('l', 'local', None, _('make the signature local')), - ('f', 'force', None, _('sign even if the sigfile is modified')), - ('', 'no-commit', None, _('do not commit the sigfile after signing')), - ('k', 'key', '', - _('the key id to sign with'), _('ID')), - ('m', 'message', '', - _('commit message'), _('TEXT')), - ] + commands.commitopts2, - _('hg sign [OPTION]... [REVISION]...')), - "sigcheck": (check, [], _('hg sigcheck REVISION')), - "sigs": (sigs, [], _('hg sigs')), -} -