[PATCH V2] gpg: show "Unknow KEYID xxx" when the status is ERRSIG

elson.wei at gmail.com elson.wei at gmail.com
Mon Jul 1 21:55:15 CDT 2013


# HG changeset patch
# User Wei, Elson <elson_wei at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2013-07-02_10-38-08_r19371+.diff
Type: text/x-patch
Size: 2291 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130702/b16db708/attachment.bin>


More information about the Mercurial-devel mailing list