[PATCH 2 of 3 V3] gpg: add shortkey() to convert from long id to short
Kevin Bullock
kbullock+mercurial at ringworld.org
Thu Jul 11 14:19:17 CDT 2013
On 10 Jul 2013, at 12:04 AM, elson.wei at gmail.com wrote:
> # HG changeset patch
> # User Wei, Elson <elson.wei at gmail.com>
> # Date 1373432623 -28800
> # Wed Jul 10 13:03:43 2013 +0800
> # Node ID f4f121d7fce92354ed72782a7432ed0648ca5743
> # Parent 578a4d336d183f41239f9568919333ef0561c1b7
> gpg: add shortkey() to convert from long id to short
>
> diff --git a/hgext/gpg.py b/hgext/gpg.py
> --- a/hgext/gpg.py
> +++ b/hgext/gpg.py
> @@ -276,6 +276,13 @@
> except ValueError, inst:
> raise util.Abort(str(inst))
>
> +
> +def shortkey(key):
> + if len(key) == 16:
> + return key[-8:]
> + else:
> + raise util.Abort(_("key ID format error"))
An abort seems wrong here. The key ID comes back to us from gnupg. I'd lean towards just returning `key` if it fails the check.
Also, the else: label and extra indentation are totally unneeded here.
pacem in terris / мир / शान्ति / سَلاَم / 平和
Kevin R. Bullock
More information about the Mercurial-devel
mailing list