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

login
register
mail settings
Submitter elson.wei@gmail.com
Date July 14, 2013, 1:52 p.m.
Message ID <446ad1284333c9ffee4c.1373809934@ElsonWei-NB>
Download mbox | patch
Permalink /patch/1890/
State Accepted
Commit 2a7fd31ac5483cb5f282286f5c91ad464510834f
Headers show

Comments

elson.wei@gmail.com - July 14, 2013, 1:52 p.m.
# HG changeset patch
# User Wei, Elson <elson.wei@gmail.com>
# Date 1373809845 -28800
#      Sun Jul 14 21:50:45 2013 +0800
# Node ID 446ad1284333c9ffee4c96d9b7e887a869314d7a
# Parent  750bda4b332c3eb913750f26f496b988042da25f
gpg: add shortkey() to convert from long id to short

Patch

# HG changeset patch
# User Wei, Elson <elson.wei@gmail.com>
# Date 1373809845 -28800
#      Sun Jul 14 21:50:45 2013 +0800
# Node ID 446ad1284333c9ffee4c96d9b7e887a869314d7a
# Parent  750bda4b332c3eb913750f26f496b988042da25f
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(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":