Merge lp:~jr/bzr/bzr-gpgme into lp:bzr

Proposed by Jonathan Riddell
Status: Merged
Approved by: Jonathan Riddell
Approved revision: no longer in the source branch.
Merged at revision: 6006
Proposed branch: lp:~jr/bzr/bzr-gpgme
Merge into: lp:bzr
Diff against target: 167 lines (+37/-24)
1 file modified
bzrlib/gpg.py (+37/-24)
To merge this branch: bzr merge lp:~jr/bzr/bzr-gpgme
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) code Approve
Review via email: mp+66489@code.launchpad.net

Commit message

Various small improvements to GPG support
- improve LoopbackGPGStrategy doc string
- use unicode strings for UI
- add doc string to verify_signatures_available()
- add process_events_callback argument to do_verifications() to keep GUIs responsive

Description of the change

Various small improvements to GPG support
- improve LoopbackGPGStrategy doc string
- use unicode strings for UI
- add doc string to verify_signatures_available()
- add process_events_callback argument to do_verifications() to keep GUIs responsive

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

We usually keep an empty line after the one-line summary in a docstring (e.g. in LoopbackGPGStrategy's docstring)

verify_signatures_available needs a one line summary (perhaps instead of the :return:)

review: Approve (code)
Revision history for this message
Jonathan Riddell (jr) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/gpg.py'
2--- bzrlib/gpg.py 2011-06-30 14:36:05 +0000
3+++ bzrlib/gpg.py 2011-07-01 10:49:35 +0000
4@@ -76,7 +76,9 @@
5
6
7 class LoopbackGPGStrategy(object):
8- """A GPG Strategy that acts like 'cat' - data is just passed through."""
9+ """A GPG Strategy that acts like 'cat' - data is just passed through.
10+ Used in tests.
11+ """
12
13 @staticmethod
14 def verify_signatures_available():
15@@ -119,24 +121,24 @@
16 return (count, result, all_verifiable)
17
18 def valid_commits_message(self, count):
19- return i18n.gettext("{0} commits with valid signatures").format(
20+ return i18n.gettext(u"{0} commits with valid signatures").format(
21 count[SIGNATURE_VALID])
22
23 def unknown_key_message(self, count):
24- return i18n.ngettext("{0} commit with unknown key",
25- "{0} commits with unknown keys",
26+ return i18n.ngettext(u"{0} commit with unknown key",
27+ u"{0} commits with unknown keys",
28 count[SIGNATURE_KEY_MISSING]).format(
29 count[SIGNATURE_KEY_MISSING])
30
31 def commit_not_valid_message(self, count):
32- return i18n.ngettext("{0} commit not valid",
33- "{0} commits not valid",
34+ return i18n.ngettext(u"{0} commit not valid",
35+ u"{0} commits not valid",
36 count[SIGNATURE_NOT_VALID]).format(
37 count[SIGNATURE_NOT_VALID])
38
39 def commit_not_signed_message(self, count):
40- return i18n.ngettext("{0} commit not signed",
41- "{0} commits not signed",
42+ return i18n.ngettext(u"{0} commit not signed",
43+ u"{0} commits not signed",
44 count[SIGNATURE_NOT_SIGNED]).format(
45 count[SIGNATURE_NOT_SIGNED])
46
47@@ -161,6 +163,11 @@
48
49 @staticmethod
50 def verify_signatures_available():
51+ """
52+ check if this strategy can verify signatures
53+
54+ :return: boolean if this strategy can verify signatures
55+ """
56 try:
57 import gpgme
58 return True
59@@ -274,6 +281,7 @@
60 if isinstance(acceptable_keys_config, unicode):
61 acceptable_keys_config = str(acceptable_keys_config)
62 except UnicodeEncodeError:
63+ #gpg Context.keylist(pattern) does not like unicode
64 raise errors.BzrCommandError('Only ASCII permitted in option names')
65
66 if acceptable_keys_config is not None:
67@@ -296,11 +304,14 @@
68 "No GnuPG key results for pattern: {}"
69 ).format(pattern))
70
71- def do_verifications(self, revisions, repository):
72+ def do_verifications(self, revisions, repository,
73+ process_events_callback=None):
74 """do verifications on a set of revisions
75
76 :param revisions: list of revision ids to verify
77 :param repository: repository object
78+ :param process_events_callback: method to call for GUI frontends that
79+ want to keep their UI refreshed
80
81 :return: count dictionary of results of each type,
82 result list for each revision,
83@@ -319,6 +330,8 @@
84 count[verification_result] += 1
85 if verification_result != SIGNATURE_VALID:
86 all_verifiable = False
87+ if process_events_callback is not None:
88+ process_events_callback()
89 return (count, result, all_verifiable)
90
91 def verbose_valid_message(self, result):
92@@ -330,8 +343,8 @@
93 signers[uid] += 1
94 result = []
95 for uid, number in signers.items():
96- result.append( i18n.ngettext("{0} signed {1} commit",
97- "{0} signed {1} commits",
98+ result.append( i18n.ngettext(u"{0} signed {1} commit",
99+ u"{0} signed {1} commits",
100 number).format(uid, number) )
101 return result
102
103@@ -347,8 +360,8 @@
104 signers[authors] += 1
105 result = []
106 for authors, number in signers.items():
107- result.append( i18n.ngettext("{0} commit by author {1}",
108- "{0} commits by author {1}",
109+ result.append( i18n.ngettext(u"{0} commit by author {1}",
110+ u"{0} commits by author {1}",
111 number).format(number, authors) )
112 return result
113
114@@ -363,8 +376,8 @@
115 signers[authors] += 1
116 result = []
117 for authors, number in signers.items():
118- result.append( i18n.ngettext("{0} commit by author {1}",
119- "{0} commits by author {1}",
120+ result.append( i18n.ngettext(u"{0} commit by author {1}",
121+ u"{0} commits by author {1}",
122 number).format(number, authors) )
123 return result
124
125@@ -377,33 +390,33 @@
126 signers[fingerprint] += 1
127 result = []
128 for fingerprint, number in signers.items():
129- result.append( i18n.ngettext("Unknown key {0} signed {1} commit",
130- "Unknown key {0} signed {1} commits",
131+ result.append( i18n.ngettext(u"Unknown key {0} signed {1} commit",
132+ u"Unknown key {0} signed {1} commits",
133 number).format(fingerprint, number) )
134 return result
135
136 def valid_commits_message(self, count):
137 """returns message for number of commits"""
138- return i18n.gettext("{0} commits with valid signatures").format(
139+ return i18n.gettext(u"{0} commits with valid signatures").format(
140 count[SIGNATURE_VALID])
141
142 def unknown_key_message(self, count):
143 """returns message for number of commits"""
144- return i18n.ngettext("{0} commit with unknown key",
145- "{0} commits with unknown keys",
146+ return i18n.ngettext(u"{0} commit with unknown key",
147+ u"{0} commits with unknown keys",
148 count[SIGNATURE_KEY_MISSING]).format(
149 count[SIGNATURE_KEY_MISSING])
150
151 def commit_not_valid_message(self, count):
152 """returns message for number of commits"""
153- return i18n.ngettext("{0} commit not valid",
154- "{0} commits not valid",
155+ return i18n.ngettext(u"{0} commit not valid",
156+ u"{0} commits not valid",
157 count[SIGNATURE_NOT_VALID]).format(
158 count[SIGNATURE_NOT_VALID])
159
160 def commit_not_signed_message(self, count):
161 """returns message for number of commits"""
162- return i18n.ngettext("{0} commit not signed",
163- "{0} commits not signed",
164+ return i18n.ngettext(u"{0} commit not signed",
165+ u"{0} commits not signed",
166 count[SIGNATURE_NOT_SIGNED]).format(
167 count[SIGNATURE_NOT_SIGNED])