Patchwork gpg: show "Unknow KEYID xxx" when the status is ERRSIG

login
register
mail settings
Submitter elson.wei@gmail.com
Date July 10, 2013, 12:51 a.m.
Message ID <f56f76c8d5f52460985d.1373417508@ElsonWei-NB.PrimeVOLT>
Download mbox | patch
Permalink /patch/1824/
State Superseded, archived
Headers show

Comments

elson.wei@gmail.com - July 10, 2013, 12:51 a.m.
# HG changeset patch
# User Wei, Elson <elson_wei@primevolt.com>
# Date 1372733547 -28800
#      Tue Jul 02 10:52:27 2013 +0800
# Node ID f56f76c8d5f52460985d2087737b447e3f3555ec
# Parent  648d1974b3f328947ee6cf2d00c66815a33cd208
gpg: show "Unknow KEYID xxx" when the status is ERRSIG

Patch

# HG changeset patch
# User Wei, Elson <elson_wei@primevolt.com>
# Date 1372733547 -28800
#      Tue Jul 02 10:52:27 2013 +0800
# Node ID f56f76c8d5f52460985d2087737b447e3f3555ec
# Parent  648d1974b3f328947ee6cf2d00c66815a33cd208
gpg: show "Unknow KEYID xxx" when the status is ERRSIG

diff --git a/hgext/gpg.py b/hgext/gpg.py
--- a/hgext/gpg.py
+++ b/hgext/gpg.py
@@ -48,19 +48,19 @@ 
                     pass
         keys = []
         key, fingerprint = None, None
-        err = ""
         for l in ret.splitlines():
             # see DETAILS in the gnupg documentation
             # filter the logger output
             if not l.startswith("[GNUPG:]"):
                 continue
             l = l[9:]
-            if l.startswith("ERRSIG"):
-                err = _("error while verifying signature")
-                break
-            elif l.startswith("VALIDSIG"):
+            if l.startswith("VALIDSIG"):
                 # fingerprint of the primary key
                 fingerprint = l.split()[10]
+            elif l.startswith("ERRSIG"):
+                key = l.split(" ", 3)[:2]
+                key.append("")
+                fingerprint = None
             elif (l.startswith("GOODSIG") or
                   l.startswith("EXPSIG") or
                   l.startswith("EXPKEYSIG") or
@@ -69,11 +69,9 @@ 
                     keys.append(key + [fingerprint])
                 key = l.split(" ", 2)
                 fingerprint = None
-        if err:
-            return err, []
         if key is not None:
             keys.append(key + [fingerprint])
-        return err, keys
+        return keys
 
 def newgpg(ui, **opts):
     """create a new gpg instance"""
@@ -119,14 +117,14 @@ 
 
     data = node2txt(repo, node, version)
     sig = binascii.a2b_base64(sig)
-    err, keys = mygpg.verify(data, sig)
-    if err:
-        ui.warn("%s:%d %s\n" % (fn, ln , err))
-        return None
+    keys = mygpg.verify(data, sig)
 
     validkeys = []
     # warn for expired key and/or sigs
     for key in keys:
+        if key[0] == "ERRSIG":
+            ui.write(_("%s Unknown KEYID \"%s\"\n") % (prefix, key[1]))
+            continue
         if key[0] == "BADSIG":
             ui.write(_("%s Bad signature from \"%s\"\n") % (prefix, key[2]))
             continue