gpg: add shortkey() to convert from long id to short
authorWei, Elson <elson.wei@gmail.com>
Sun, 14 Jul 2013 21:50:45 +0800
changeset 19443 2a7fd31ac548
parent 19442 33c72f054e16
child 19444 f9e04a4e28d0
gpg: add shortkey() to convert from long id to short
hgext/gpg.py
--- a/hgext/gpg.py	Fri Jul 12 10:10:46 2013 +0800
+++ b/hgext/gpg.py	Sun Jul 14 21:50:45 2013 +0800
@@ -276,6 +276,13 @@
     except ValueError, inst:
         raise util.Abort(str(inst))
 
+def shortkey(ui, key):
+    if len(key) != 16:
+        ui.debug("key ID \"%s\" format error\n" % key)
+        return key
+
+    return key[-8:]
+
 def node2txt(repo, node, ver):
     """map a manifest into some text"""
     if ver == "0":