Patchwork [2,of,3,V3] gpg: add shortkey() to convert from long id to short

login
register
mail settings
Submitter elson.wei@gmail.com
Date July 10, 2013, 5:04 a.m.
Message ID <f4f121d7fce92354ed72.1373432655@ElsonWei-NB.PrimeVOLT>
Download mbox | patch
Permalink /patch/1826/
State Superseded, archived
Headers show

Comments

elson.wei@gmail.com - July 10, 2013, 5:04 a.m.
# HG changeset patch
# User Wei, Elson <elson.wei@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

Patch

# HG changeset patch
# User Wei, Elson <elson.wei@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"))
+
 def node2txt(repo, node, ver):
     """map a manifest into some text"""
     if ver == "0":