[PATCH 1 of 3] gpg: extend repo with signs property

elson.wei at gmail.com elson.wei at gmail.com
Wed Aug 7 20:41:21 CDT 2013


# HG changeset patch
# User Wei, Elson <elson.wei at gmail.com>
# Date 1375841212 -28800
#      Wed Aug 07 10:06:52 2013 +0800
# Node ID a835e923601daaa2106c28f81c8cbe8618965128
# Parent  7a67f75deafc8880b539d3da42a719dab00d7cd6
gpg: extend repo with signs property

repo.signs[n] will return the (data, context) list for node n.

diff --git a/hgext/gpg.py b/hgext/gpg.py
--- a/hgext/gpg.py
+++ b/hgext/gpg.py
@@ -6,7 +6,7 @@
 '''commands to sign and verify changesets'''
 
 import os, tempfile, binascii
-from mercurial import util, commands, match, cmdutil
+from mercurial import util, commands, match, cmdutil, localrepo
 from mercurial import node as hgnode
 from mercurial.i18n import _
 
@@ -293,3 +293,23 @@
         return "%s\n" % hgnode.hex(node)
     else:
         raise util.Abort(_("unknown signature version"))
+
+def reposetup(ui, repo):
+    class gpgrepo(repo.__class__):
+        @localrepo.unfilteredpropertycache
+        def signs(self):
+            sigs = {}
+            for data, context in sigwalk(repo):
+                node, version, sig = data
+                fn, ln = context
+                try:
+                    n = repo.lookup(node)
+                except KeyError:
+                    ui.warn(_("%s:%d node does not exist\n") % (fn, ln))
+                    continue
+                sigs.setdefault(n, [])
+                sigs[n].extend([(data, context)])
+            return sigs
+
+    if repo.local():
+        repo.__class__ = gpgrepo


More information about the Mercurial-devel mailing list