Mercurial > hg
annotate hgext/gpg.py @ 6423:fb374b1b3911
backout: reverse changeset belongs on current branch
Backing out a changeset that is before a named branch branchpoint was
making the reverse changeset the tip of the old branch, which is wrong
and very confusing. So instead, we put it on the current named branch.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 29 Mar 2008 12:39:47 -0500 |
parents | 1f733c2f0165 |
children | 4faaa0535ea7 |
rev | line source |
---|---|
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
1 # GnuPG signing extension for Mercurial |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
2 # |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
3 # Copyright 2005, 2006 Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
4 # |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
5 # This software may be used and distributed according to the terms |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
6 # of the GNU General Public License, incorporated herein by reference. |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
7 |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
8 import os, tempfile, binascii |
5147
c80af96943aa
refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4906
diff
changeset
|
9 from mercurial import util, commands |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
10 from mercurial import node as hgnode |
3891 | 11 from mercurial.i18n import _ |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
12 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
13 class gpg: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
14 def __init__(self, path, key=None): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
15 self.path = path |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
16 self.key = (key and " --local-user \"%s\"" % key) or "" |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
17 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
18 def sign(self, data): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
19 gpgcmd = "%s --sign --detach-sign%s" % (self.path, self.key) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
20 return util.filter(data, gpgcmd) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
21 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
22 def verify(self, data, sig): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
23 """ returns of the good and bad signatures""" |
2231
9a2f4b2e7cf1
gpg extension: Always remove temporary files created by 'hg sigcheck'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2165
diff
changeset
|
24 sigfile = datafile = None |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
25 try: |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
26 # create temporary files |
2165
d821918e3bee
Use better names (hg-{usage}-{random}.{suffix}) for temporary files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1685
diff
changeset
|
27 fd, sigfile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".sig") |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
28 fp = os.fdopen(fd, 'wb') |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
29 fp.write(sig) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
30 fp.close() |
2165
d821918e3bee
Use better names (hg-{usage}-{random}.{suffix}) for temporary files.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1685
diff
changeset
|
31 fd, datafile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".txt") |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
32 fp = os.fdopen(fd, 'wb') |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
33 fp.write(data) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
34 fp.close() |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
35 gpgcmd = ("%s --logger-fd 1 --status-fd 1 --verify " |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
36 "\"%s\" \"%s\"" % (self.path, sigfile, datafile)) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
37 ret = util.filter("", gpgcmd) |
2231
9a2f4b2e7cf1
gpg extension: Always remove temporary files created by 'hg sigcheck'.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2165
diff
changeset
|
38 finally: |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
39 for f in (sigfile, datafile): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
40 try: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
41 if f: os.unlink(f) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
42 except: pass |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
43 keys = [] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
44 key, fingerprint = None, None |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
45 err = "" |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
46 for l in ret.splitlines(): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
47 # see DETAILS in the gnupg documentation |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
48 # filter the logger output |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
49 if not l.startswith("[GNUPG:]"): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
50 continue |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
51 l = l[9:] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
52 if l.startswith("ERRSIG"): |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
53 err = _("error while verifying signature") |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
54 break |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
55 elif l.startswith("VALIDSIG"): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
56 # fingerprint of the primary key |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
57 fingerprint = l.split()[10] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
58 elif (l.startswith("GOODSIG") or |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
59 l.startswith("EXPSIG") or |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
60 l.startswith("EXPKEYSIG") or |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
61 l.startswith("BADSIG")): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
62 if key is not None: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
63 keys.append(key + [fingerprint]) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
64 key = l.split(" ", 2) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
65 fingerprint = None |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
66 if err: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
67 return err, [] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
68 if key is not None: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
69 keys.append(key + [fingerprint]) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
70 return err, keys |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
71 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
72 def newgpg(ui, **opts): |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
73 """create a new gpg instance""" |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
74 gpgpath = ui.config("gpg", "cmd", "gpg") |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
75 gpgkey = opts.get('key') |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
76 if not gpgkey: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
77 gpgkey = ui.config("gpg", "key", None) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
78 return gpg(gpgpath, gpgkey) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
79 |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
80 def sigwalk(repo): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
81 """ |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
82 walk over every sigs, yields a couple |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
83 ((node, version, sig), (filename, linenumber)) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
84 """ |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
85 def parsefile(fileiter, context): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
86 ln = 1 |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
87 for l in fileiter: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
88 if not l: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
89 continue |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
90 yield (l.split(" ", 2), (context, ln)) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
91 ln +=1 |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
92 |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
93 fl = repo.file(".hgsigs") |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
94 h = fl.heads() |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
95 h.reverse() |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
96 # read the heads |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
97 for r in h: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
98 fn = ".hgsigs|%s" % hgnode.short(r) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
99 for item in parsefile(fl.read(r).splitlines(), fn): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
100 yield item |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
101 try: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
102 # read local signatures |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
103 fn = "localsigs" |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
104 for item in parsefile(repo.opener(fn), fn): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
105 yield item |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
106 except IOError: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
107 pass |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
108 |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
109 def getkeys(ui, repo, mygpg, sigdata, context): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
110 """get the keys who signed a data""" |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
111 fn, ln = context |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
112 node, version, sig = sigdata |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
113 prefix = "%s:%d" % (fn, ln) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
114 node = hgnode.bin(node) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
115 |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
116 data = node2txt(repo, node, version) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
117 sig = binascii.a2b_base64(sig) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
118 err, keys = mygpg.verify(data, sig) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
119 if err: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
120 ui.warn("%s:%d %s\n" % (fn, ln , err)) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
121 return None |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
122 |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
123 validkeys = [] |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
124 # warn for expired key and/or sigs |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
125 for key in keys: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
126 if key[0] == "BADSIG": |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
127 ui.write(_("%s Bad signature from \"%s\"\n") % (prefix, key[2])) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
128 continue |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
129 if key[0] == "EXPSIG": |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
130 ui.write(_("%s Note: Signature has expired" |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
131 " (signed by: \"%s\")\n") % (prefix, key[2])) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
132 elif key[0] == "EXPKEYSIG": |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
133 ui.write(_("%s Note: This key has expired" |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
134 " (signed by: \"%s\")\n") % (prefix, key[2])) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
135 validkeys.append((key[1], key[2], key[3])) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
136 return validkeys |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
137 |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
138 def sigs(ui, repo): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
139 """list signed changesets""" |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
140 mygpg = newgpg(ui) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
141 revs = {} |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
142 |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
143 for data, context in sigwalk(repo): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
144 node, version, sig = data |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
145 fn, ln = context |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
146 try: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
147 n = repo.lookup(node) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
148 except KeyError: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
149 ui.warn(_("%s:%d node does not exist\n") % (fn, ln)) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
150 continue |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
151 r = repo.changelog.rev(n) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
152 keys = getkeys(ui, repo, mygpg, data, context) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
153 if not keys: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
154 continue |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
155 revs.setdefault(r, []) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
156 revs[r].extend(keys) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
157 nodes = list(revs) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
158 nodes.reverse() |
1682
ca1cda9220d5
fix an exception in gpg.py with multiples sigs for the same cset
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1681
diff
changeset
|
159 for rev in nodes: |
ca1cda9220d5
fix an exception in gpg.py with multiples sigs for the same cset
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1681
diff
changeset
|
160 for k in revs[rev]: |
ca1cda9220d5
fix an exception in gpg.py with multiples sigs for the same cset
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1681
diff
changeset
|
161 r = "%5d:%s" % (rev, hgnode.hex(repo.changelog.node(rev))) |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
162 ui.write("%-30s %s\n" % (keystr(ui, k), r)) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
163 |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
164 def check(ui, repo, rev): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
165 """verify all the signatures there may be for a particular revision""" |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
166 mygpg = newgpg(ui) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
167 rev = repo.lookup(rev) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
168 hexrev = hgnode.hex(rev) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
169 keys = [] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
170 |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
171 for data, context in sigwalk(repo): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
172 node, version, sig = data |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
173 if node == hexrev: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
174 k = getkeys(ui, repo, mygpg, data, context) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
175 if k: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
176 keys.extend(k) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
177 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
178 if not keys: |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
179 ui.write(_("No valid signature for %s\n") % hgnode.short(rev)) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
180 return |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
181 |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
182 # print summary |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
183 ui.write("%s is signed by:\n" % hgnode.short(rev)) |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
184 for key in keys: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
185 ui.write(" %s\n" % keystr(ui, key)) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
186 |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
187 def keystr(ui, key): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
188 """associate a string to a key (username, comment)""" |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
189 keyid, user, fingerprint = key |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
190 comment = ui.config("gpg", fingerprint, None) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
191 if comment: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
192 return "%s (%s)" % (user, comment) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
193 else: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
194 return user |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
195 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
196 def sign(ui, repo, *revs, **opts): |
3916
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
197 """add a signature for the current or given revision |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
198 |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
199 If no revision is given, the parent of the working directory is used, |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
200 or tip if no revision is checked out. |
6163
1f733c2f0165
Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6139
diff
changeset
|
201 |
1f733c2f0165
Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6139
diff
changeset
|
202 See 'hg help dates' for a list of formats valid for -d/--date. |
3916
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
203 """ |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
204 |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
205 mygpg = newgpg(ui, **opts) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
206 sigver = "0" |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
207 sigmessage = "" |
6139
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5475
diff
changeset
|
208 |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5475
diff
changeset
|
209 date = opts.get('date') |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5475
diff
changeset
|
210 if date: |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5475
diff
changeset
|
211 opts['date'] = util.parsedate(date) |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5475
diff
changeset
|
212 |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
213 if revs: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
214 nodes = [repo.lookup(n) for n in revs] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
215 else: |
3916
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
216 nodes = [node for node in repo.dirstate.parents() |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
217 if node != hgnode.nullid] |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
218 if len(nodes) > 1: |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
219 raise util.Abort(_('uncommitted merge - please provide a ' |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
220 'specific revision')) |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
221 if not nodes: |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
222 nodes = [repo.changelog.tip()] |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
223 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
224 for n in nodes: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
225 hexnode = hgnode.hex(n) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
226 ui.write("Signing %d:%s\n" % (repo.changelog.rev(n), |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
227 hgnode.short(n))) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
228 # build data |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
229 data = node2txt(repo, n, sigver) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
230 sig = mygpg.sign(data) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
231 if not sig: |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
232 raise util.Abort(_("Error while signing")) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
233 sig = binascii.b2a_base64(sig) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
234 sig = sig.replace("\n", "") |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
235 sigmessage += "%s %s %s\n" % (hexnode, sigver, sig) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
236 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
237 # write it |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
238 if opts['local']: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
239 repo.opener("localsigs", "ab").write(sigmessage) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
240 return |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
241 |
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2231
diff
changeset
|
242 for x in repo.status()[:5]: |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
243 if ".hgsigs" in x and not opts["force"]: |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
244 raise util.Abort(_("working copy of .hgsigs is changed " |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
245 "(please commit .hgsigs manually " |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
246 "or use --force)")) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
247 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
248 repo.wfile(".hgsigs", "ab").write(sigmessage) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
249 |
4906
30847b8af7ca
dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents:
4730
diff
changeset
|
250 if '.hgsigs' not in repo.dirstate: |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
251 repo.add([".hgsigs"]) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
252 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
253 if opts["no_commit"]: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
254 return |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
255 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
256 message = opts['message'] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
257 if not message: |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
258 message = "\n".join([_("Added signature for changeset %s") |
5475
3aa5c45874c6
gpg: use the same log message format as hg tag
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
5147
diff
changeset
|
259 % hgnode.short(n) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
260 for n in nodes]) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
261 try: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
262 repo.commit([".hgsigs"], message, opts['user'], opts['date']) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
263 except ValueError, inst: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
264 raise util.Abort(str(inst)) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
265 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
266 def node2txt(repo, node, ver): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
267 """map a manifest into some text""" |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
268 if ver == "0": |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
269 return "%s\n" % hgnode.hex(node) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
270 else: |
1685
60c3a55c61b8
extension gpg.py: really raise the exception in case of invalid data
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1682
diff
changeset
|
271 raise util.Abort(_("unknown signature version")) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
272 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
273 cmdtable = { |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
274 "sign": |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
275 (sign, |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3920
diff
changeset
|
276 [('l', 'local', None, _('make the signature local')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3920
diff
changeset
|
277 ('f', 'force', None, _('sign even if the sigfile is modified')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3920
diff
changeset
|
278 ('', 'no-commit', None, _('do not commit the sigfile after signing')), |
5147
c80af96943aa
refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4906
diff
changeset
|
279 ('k', 'key', '', _('the key id to sign with')), |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3920
diff
changeset
|
280 ('m', 'message', '', _('commit message')), |
5147
c80af96943aa
refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4906
diff
changeset
|
281 ] + commands.commitopts2, |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3920
diff
changeset
|
282 _('hg sign [OPTION]... [REVISION]...')), |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
283 "sigcheck": (check, [], _('hg sigcheck REVISION')), |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
284 "sigs": (sigs, [], _('hg sigs')), |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
285 } |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
286 |