From patchwork Tue Jul 2 02:55:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [V2] gpg: show "Unknow KEYID xxx" when the status is ERRSIG From: elson.wei@gmail.com X-Patchwork-Id: 1783 Message-Id: To: mercurial-devel@selenic.com Date: Tue, 02 Jul 2013 10:55:15 +0800 # HG changeset patch # User Wei, Elson # 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 # HG changeset patch # User Wei, Elson # 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