Mercurial > hg
annotate hgext/gpg.py @ 12240:206859808904
i18n-ro: ongoing translation
author | Daniel Dumitriu <daniel.dumitriu@gmail.com> |
---|---|
date | Thu, 19 Aug 2010 23:27:09 +0200 |
parents | 40c06bbf58be |
children | a4fbbe0fbc38 |
rev | line source |
---|---|
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
1 # 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
|
2 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8210
diff
changeset
|
3 # This software may be used and distributed according to the terms of the |
10263 | 4 # GNU General Public License version 2 or any later version. |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
5 |
8934
9dda4c73fc3b
extensions: change descriptions for extensions providing a few commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8894
diff
changeset
|
6 '''commands to sign and verify changesets''' |
8873
e872ef2e6758
help: add/fix docstrings for a bunch of extensions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8808
diff
changeset
|
7 |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
8 import os, tempfile, binascii |
10532
e4a8ae4659d3
gpg: make 13448eab08ca work when not on repo root
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10517
diff
changeset
|
9 from mercurial import util, commands, match |
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 |
8778
c5f36402daad
use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8706
diff
changeset
|
13 class gpg(object): |
1592
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: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
41 if f: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
42 os.unlink(f) |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
43 except: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
44 pass |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
45 keys = [] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
46 key, fingerprint = None, None |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
47 err = "" |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
48 for l in ret.splitlines(): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
49 # see DETAILS in the gnupg documentation |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
50 # filter the logger output |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
51 if not l.startswith("[GNUPG:]"): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
52 continue |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
53 l = l[9:] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
54 if l.startswith("ERRSIG"): |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
55 err = _("error while verifying signature") |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
56 break |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
57 elif l.startswith("VALIDSIG"): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
58 # fingerprint of the primary key |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
59 fingerprint = l.split()[10] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
60 elif (l.startswith("GOODSIG") or |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
61 l.startswith("EXPSIG") or |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
62 l.startswith("EXPKEYSIG") or |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
63 l.startswith("BADSIG")): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
64 if key is not None: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
65 keys.append(key + [fingerprint]) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
66 key = l.split(" ", 2) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
67 fingerprint = None |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
68 if err: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
69 return err, [] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
70 if key is not None: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
71 keys.append(key + [fingerprint]) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
72 return err, keys |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
73 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
74 def newgpg(ui, **opts): |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
75 """create a new gpg instance""" |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
76 gpgpath = ui.config("gpg", "cmd", "gpg") |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
77 gpgkey = opts.get('key') |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
78 if not gpgkey: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
79 gpgkey = ui.config("gpg", "key", None) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
80 return gpg(gpgpath, gpgkey) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
81 |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
82 def sigwalk(repo): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
83 """ |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
84 walk over every sigs, yields a couple |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
85 ((node, version, sig), (filename, linenumber)) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
86 """ |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
87 def parsefile(fileiter, context): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
88 ln = 1 |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
89 for l in fileiter: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
90 if not l: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
91 continue |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
92 yield (l.split(" ", 2), (context, ln)) |
10394
4612cded5176
fix coding style (reported by pylint)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
93 ln += 1 |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
94 |
8210
344751cd8cb8
replace various uses of list.reverse()
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
95 # read the heads |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
96 fl = repo.file(".hgsigs") |
8210
344751cd8cb8
replace various uses of list.reverse()
Matt Mackall <mpm@selenic.com>
parents:
6760
diff
changeset
|
97 for r in reversed(fl.heads()): |
1681
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) |
8303
db52cc4f2f97
gpg: use reverse kwarg to sort sigs in reversed order
Martin Geisler <mg@lazybytes.net>
parents:
8301
diff
changeset
|
157 for rev in sorted(revs, reverse=True): |
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
|
158 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
|
159 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
|
160 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
|
161 |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
162 def check(ui, repo, rev): |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
163 """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
|
164 mygpg = newgpg(ui) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
165 rev = repo.lookup(rev) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
166 hexrev = hgnode.hex(rev) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
167 keys = [] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
168 |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
169 for data, context in sigwalk(repo): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
170 node, version, sig = data |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
171 if node == hexrev: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
172 k = getkeys(ui, repo, mygpg, data, context) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
173 if k: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
174 keys.extend(k) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
175 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
176 if not keys: |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
177 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
|
178 return |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
179 |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
180 # print summary |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
181 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
|
182 for key in keys: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
183 ui.write(" %s\n" % keystr(ui, key)) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
184 |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
185 def keystr(ui, key): |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
186 """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
|
187 keyid, user, fingerprint = key |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
188 comment = ui.config("gpg", fingerprint, None) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
189 if comment: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
190 return "%s (%s)" % (user, comment) |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
191 else: |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
192 return user |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
193 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
194 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
|
195 """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
|
196 |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
197 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
|
198 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
|
199 |
11193
687c7d395f20
Use our custom hg reStructuredText role some more
Martin Geisler <mg@aragost.com>
parents:
10532
diff
changeset
|
200 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
|
201 """ |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
202 |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
203 mygpg = newgpg(ui, **opts) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
204 sigver = "0" |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
205 sigmessage = "" |
6139
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5475
diff
changeset
|
206 |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5475
diff
changeset
|
207 date = opts.get('date') |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5475
diff
changeset
|
208 if date: |
989467e8e3a9
Fix bad behaviour when specifying an invalid date (issue700)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5475
diff
changeset
|
209 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
|
210 |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
211 if revs: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
212 nodes = [repo.lookup(n) for n in revs] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
213 else: |
3916
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
214 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
|
215 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
|
216 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
|
217 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
|
218 'specific revision')) |
b1806b211910
Make 'hg sign' behave like other commands: Default to current parent.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2875
diff
changeset
|
219 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
|
220 nodes = [repo.changelog.tip()] |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
221 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
222 for n in nodes: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
223 hexnode = hgnode.hex(n) |
10510
f77f3383c666
i18n: mark more strings for translation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10394
diff
changeset
|
224 ui.write(_("Signing %d:%s\n") % (repo.changelog.rev(n), |
f77f3383c666
i18n: mark more strings for translation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10394
diff
changeset
|
225 hgnode.short(n))) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
226 # build data |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
227 data = node2txt(repo, n, sigver) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
228 sig = mygpg.sign(data) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
229 if not sig: |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
230 raise util.Abort(_("Error while signing")) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
231 sig = binascii.b2a_base64(sig) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
232 sig = sig.replace("\n", "") |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
233 sigmessage += "%s %s %s\n" % (hexnode, sigver, sig) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
234 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
235 # write it |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
236 if opts['local']: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
237 repo.opener("localsigs", "ab").write(sigmessage) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
238 return |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
239 |
10532
e4a8ae4659d3
gpg: make 13448eab08ca work when not on repo root
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10517
diff
changeset
|
240 msigs = match.exact(repo.root, '', ['.hgsigs']) |
10517
13448eab08ca
gpg: do not call status on the whole repository, only on '.hgsigs'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10510
diff
changeset
|
241 s = repo.status(match=msigs, unknown=True, ignored=True)[:6] |
13448eab08ca
gpg: do not call status on the whole repository, only on '.hgsigs'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10510
diff
changeset
|
242 if util.any(s) and not opts["force"]: |
13448eab08ca
gpg: do not call status on the whole repository, only on '.hgsigs'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10510
diff
changeset
|
243 raise util.Abort(_("working copy of .hgsigs is changed " |
13448eab08ca
gpg: do not call status on the whole repository, only on '.hgsigs'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10510
diff
changeset
|
244 "(please commit .hgsigs manually " |
13448eab08ca
gpg: do not call status on the whole repository, only on '.hgsigs'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10510
diff
changeset
|
245 "or use --force)")) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
246 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
247 repo.wfile(".hgsigs", "ab").write(sigmessage) |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
248 |
4906
30847b8af7ca
dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents:
4730
diff
changeset
|
249 if '.hgsigs' not in repo.dirstate: |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11193
diff
changeset
|
250 repo[None].add([".hgsigs"]) |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
251 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
252 if opts["no_commit"]: |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
253 return |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
254 |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
255 message = opts['message'] |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
256 if not message: |
9183
d0225fa2f6c4
do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents:
8934
diff
changeset
|
257 # we don't translate commit messages |
d0225fa2f6c4
do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents:
8934
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: |
10517
13448eab08ca
gpg: do not call status on the whole repository, only on '.hgsigs'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10510
diff
changeset
|
262 repo.commit(message, opts['user'], opts['date'], match=msigs) |
1592
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')), |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11303
diff
changeset
|
279 ('k', 'key', '', |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11303
diff
changeset
|
280 _('the key id to sign with'), _('ID')), |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11303
diff
changeset
|
281 ('m', 'message', '', |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11303
diff
changeset
|
282 _('commit message'), _('TEXT')), |
5147
c80af96943aa
refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4906
diff
changeset
|
283 ] + commands.commitopts2, |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3920
diff
changeset
|
284 _('hg sign [OPTION]... [REVISION]...')), |
1681
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
285 "sigcheck": (check, [], _('hg sigcheck REVISION')), |
98eef041f9c7
fixes for gpg.py extension
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1676
diff
changeset
|
286 "sigs": (sigs, [], _('hg sigs')), |
1592
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
287 } |
347c44611348
gpg signing extension for hg
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
288 |