Merge lp:~jelmer/brz/move-testament into lp:brz

Proposed by Jelmer Vernooij on 2018-11-30
Status: Merged
Approved by: Jelmer Vernooij on 2019-01-01
Approved revision: 7219
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/move-testament
Merge into: lp:brz
Prerequisite: lp:~jelmer/brz/python3.7
Diff against target: 352 lines (+59/-41)
19 files modified
breezy/builtins.py (+1/-1)
breezy/bundle/bundle_data.py (+1/-1)
breezy/bundle/serializer/v08.py (+1/-1)
breezy/bundle/serializer/v09.py (+2/-1)
breezy/bzr/remote.py (+1/-1)
breezy/bzr/testament.py (+3/-3)
breezy/bzr/vf_repository.py (+34/-1)
breezy/git/fetch.py (+1/-1)
breezy/git/object_store.py (+1/-1)
breezy/merge_directive.py (+3/-1)
breezy/repository.py (+3/-21)
breezy/tests/blackbox/test_merge.py (+1/-1)
breezy/tests/blackbox/test_pull.py (+1/-1)
breezy/tests/blackbox/test_re_sign.py (+1/-1)
breezy/tests/per_repository/test_signatures.py (+1/-1)
breezy/tests/test_bundle.py (+1/-1)
breezy/tests/test_commit.py (+1/-1)
breezy/tests/test_smart.py (+1/-1)
breezy/tests/test_testament.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/move-testament
Reviewer Review Type Date Requested Status
Martin Packman 2018-11-30 Approve on 2018-12-31
Review via email: mp+359939@code.launchpad.net

Commit message

Move the testament module to breezy.bzr.

Description of the change

Move the testament module to breezy.bzr.

To post a comment you must log in.
Martin Packman (gz) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/builtins.py'
2--- breezy/builtins.py 2018-11-21 03:20:30 +0000
3+++ breezy/builtins.py 2018-11-30 17:12:07 +0000
4@@ -5210,7 +5210,7 @@
5
6 @display_command
7 def run(self, branch=u'.', revision=None, long=False, strict=False):
8- from .testament import Testament, StrictTestament
9+ from .bzr.testament import Testament, StrictTestament
10 if strict is True:
11 testament_class = StrictTestament
12 else:
13
14=== modified file 'breezy/bundle/bundle_data.py'
15--- breezy/bundle/bundle_data.py 2018-11-22 03:51:03 +0000
16+++ breezy/bundle/bundle_data.py 2018-11-30 17:12:07 +0000
17@@ -44,7 +44,7 @@
18 from ..sixish import (
19 viewitems,
20 )
21-from ..testament import StrictTestament
22+from ..bzr.testament import StrictTestament
23 from ..trace import mutter, warning
24 from ..tree import Tree
25 from ..bzr.xml5 import serializer_v5
26
27=== modified file 'breezy/bundle/serializer/v08.py'
28--- breezy/bundle/serializer/v08.py 2018-11-16 18:40:46 +0000
29+++ breezy/bundle/serializer/v08.py 2018-11-30 17:12:07 +0000
30@@ -35,7 +35,7 @@
31 from breezy.diff import internal_diff
32 from breezy.revision import NULL_REVISION
33 from breezy.sixish import text_type
34-from breezy.testament import StrictTestament
35+from breezy.bzr.testament import StrictTestament
36 from breezy.timestamp import (
37 format_highres_date,
38 )
39
40=== modified file 'breezy/bundle/serializer/v09.py'
41--- breezy/bundle/serializer/v09.py 2018-06-17 20:17:39 +0000
42+++ breezy/bundle/serializer/v09.py 2018-11-30 17:12:07 +0000
43@@ -18,9 +18,10 @@
44
45 from breezy.bundle.serializer import _get_bundle_header
46 from breezy.bundle.serializer.v08 import BundleSerializerV08, BundleReader
47-from breezy.testament import StrictTestament3
48 from breezy.bundle.bundle_data import BundleInfo
49
50+from breezy.bzr.testament import StrictTestament3
51+
52
53 """Serializer for bundle format 0.9"""
54
55
56=== modified file 'breezy/bzr/remote.py'
57--- breezy/bzr/remote.py 2018-11-18 00:25:19 +0000
58+++ breezy/bzr/remote.py 2018-11-30 17:12:07 +0000
59@@ -37,13 +37,13 @@
60 registry,
61 repository as _mod_repository,
62 revision as _mod_revision,
63- testament as _mod_testament,
64 urlutils,
65 )
66 from . import (
67 branch as bzrbranch,
68 bzrdir as _mod_bzrdir,
69 inventory_delta,
70+ testament as _mod_testament,
71 vf_repository,
72 vf_search,
73 )
74
75=== renamed file 'breezy/testament.py' => 'breezy/bzr/testament.py'
76--- breezy/testament.py 2018-11-21 03:20:30 +0000
77+++ breezy/bzr/testament.py 2018-11-30 17:12:07 +0000
78@@ -73,13 +73,13 @@
79
80 from copy import copy
81
82-from .osutils import (
83+from ..osutils import (
84 contains_whitespace,
85 contains_linebreaks,
86 sha_strings,
87 )
88-from .sixish import text_type
89-from .tree import Tree
90+from ..sixish import text_type
91+from ..tree import Tree
92
93
94 class Testament(object):
95
96=== modified file 'breezy/bzr/vf_repository.py'
97--- breezy/bzr/vf_repository.py 2018-11-16 18:40:46 +0000
98+++ breezy/bzr/vf_repository.py 2018-11-30 17:12:07 +0000
99@@ -46,8 +46,8 @@
100 )
101
102 from breezy.recordcounter import RecordCounter
103-from breezy.testament import Testament
104 from breezy.i18n import gettext
105+from breezy.bzr.testament import Testament
106 """)
107
108 from .. import (
109@@ -1121,6 +1121,39 @@
110 self.signatures.add_lines((revision_id,), (),
111 osutils.split_lines(signature))
112
113+ def sign_revision(self, revision_id, gpg_strategy):
114+ with self.lock_write():
115+ testament = Testament.from_revision(
116+ self, revision_id)
117+ plaintext = testament.as_short_text()
118+ self.store_revision_signature(gpg_strategy, plaintext, revision_id)
119+
120+ def store_revision_signature(self, gpg_strategy, plaintext, revision_id):
121+ with self.lock_write():
122+ signature = gpg_strategy.sign(plaintext, gpg.MODE_CLEAR)
123+ self.add_signature_text(revision_id, signature)
124+
125+ def verify_revision_signature(self, revision_id, gpg_strategy):
126+ """Verify the signature on a revision.
127+
128+ :param revision_id: the revision to verify
129+ :gpg_strategy: the GPGStrategy object to used
130+
131+ :return: gpg.SIGNATURE_VALID or a failed SIGNATURE_ value
132+ """
133+ with self.lock_read():
134+ if not self.has_signature_for_revision_id(revision_id):
135+ return gpg.SIGNATURE_NOT_SIGNED, None
136+ signature = self.get_signature_text(revision_id)
137+
138+ testament = Testament.from_revision(
139+ self, revision_id)
140+
141+ (status, key, signed_plaintext) = gpg_strategy.verify(signature)
142+ if testament.as_short_text() != signed_plaintext:
143+ return gpg.SIGNATURE_NOT_VALID, None
144+ return (status, key)
145+
146 def find_text_key_references(self):
147 """Find the text key references within the repository.
148
149
150=== modified file 'breezy/git/fetch.py'
151--- breezy/git/fetch.py 2018-11-17 16:53:10 +0000
152+++ breezy/git/fetch.py 2018-11-30 17:12:07 +0000
153@@ -52,7 +52,7 @@
154 )
155 from ..bzr.inventorytree import InventoryRevisionTree
156 from ..sixish import text_type
157-from ..testament import (
158+from ..bzr.testament import (
159 StrictTestament3,
160 )
161 from ..tsort import (
162
163=== modified file 'breezy/git/object_store.py'
164--- breezy/git/object_store.py 2018-11-18 00:25:19 +0000
165+++ breezy/git/object_store.py 2018-11-30 17:12:07 +0000
166@@ -47,7 +47,7 @@
167 NULL_REVISION,
168 )
169 from ..sixish import viewitems
170-from ..testament import (
171+from ..bzr.testament import (
172 StrictTestament3,
173 )
174
175
176=== modified file 'breezy/merge_directive.py'
177--- breezy/merge_directive.py 2018-11-12 01:41:38 +0000
178+++ breezy/merge_directive.py 2018-11-30 17:12:07 +0000
179@@ -31,10 +31,12 @@
180 registry,
181 revision as _mod_revision,
182 rio,
183- testament,
184 timestamp,
185 trace,
186 )
187+from breezy.bzr import (
188+ testament,
189+ )
190 from breezy.bundle import (
191 serializer as bundle_serializer,
192 )
193
194=== modified file 'breezy/repository.py'
195--- breezy/repository.py 2018-11-18 19:48:57 +0000
196+++ breezy/repository.py 2018-11-30 17:12:07 +0000
197@@ -28,7 +28,6 @@
198 graph,
199 osutils,
200 revision as _mod_revision,
201- testament as _mod_testament,
202 gpg,
203 )
204 from breezy.bundle import serializer
205@@ -887,9 +886,7 @@
206 [r], specific_fileids=specific_fileids))[0]
207
208 def store_revision_signature(self, gpg_strategy, plaintext, revision_id):
209- with self.lock_write():
210- signature = gpg_strategy.sign(plaintext, gpg.MODE_CLEAR)
211- self.add_signature_text(revision_id, signature)
212+ raise NotImplementedError(self.store_revision_signature)
213
214 def add_signature_text(self, revision_id, signature):
215 """Store a signature text for a revision.
216@@ -1087,11 +1084,7 @@
217 raise NotImplementedError(self.make_working_trees)
218
219 def sign_revision(self, revision_id, gpg_strategy):
220- with self.lock_write():
221- testament = _mod_testament.Testament.from_revision(
222- self, revision_id)
223- plaintext = testament.as_short_text()
224- self.store_revision_signature(gpg_strategy, plaintext, revision_id)
225+ raise NotImplementedError(self.sign_revision)
226
227 def verify_revision_signature(self, revision_id, gpg_strategy):
228 """Verify the signature on a revision.
229@@ -1101,18 +1094,7 @@
230
231 :return: gpg.SIGNATURE_VALID or a failed SIGNATURE_ value
232 """
233- with self.lock_read():
234- if not self.has_signature_for_revision_id(revision_id):
235- return gpg.SIGNATURE_NOT_SIGNED, None
236- signature = self.get_signature_text(revision_id)
237-
238- testament = _mod_testament.Testament.from_revision(
239- self, revision_id)
240-
241- (status, key, signed_plaintext) = gpg_strategy.verify(signature)
242- if testament.as_short_text() != signed_plaintext:
243- return gpg.SIGNATURE_NOT_VALID, None
244- return (status, key)
245+ raise NotImplementedError(self.verify_revision_signature)
246
247 def verify_revision_signatures(self, revision_ids, gpg_strategy):
248 """Verify revision signatures for a number of revisions.
249
250=== modified file 'breezy/tests/blackbox/test_merge.py'
251--- breezy/tests/blackbox/test_merge.py 2018-11-11 04:08:32 +0000
252+++ breezy/tests/blackbox/test_merge.py 2018-11-30 17:12:07 +0000
253@@ -308,7 +308,7 @@
254 tree_b.commit('merge branch_c')
255
256 def test_merge_bundle(self):
257- from breezy.testament import Testament
258+ from breezy.bzr.testament import Testament
259 tree_a = self.make_branch_and_tree('branch_a')
260 self.build_tree_contents([('branch_a/a', b'hello')])
261 tree_a.add('a')
262
263=== modified file 'breezy/tests/blackbox/test_pull.py'
264--- breezy/tests/blackbox/test_pull.py 2018-11-11 04:08:32 +0000
265+++ breezy/tests/blackbox/test_pull.py 2018-11-30 17:12:07 +0000
266@@ -274,7 +274,7 @@
267 branch_b.get_parent())
268
269 def test_pull_bundle(self):
270- from breezy.testament import Testament
271+ from breezy.bzr.testament import Testament
272 # Build up 2 trees and prepare for a pull
273 tree_a = self.make_branch_and_tree('branch_a')
274 with open('branch_a/a', 'wb') as f:
275
276=== modified file 'breezy/tests/blackbox/test_re_sign.py'
277--- breezy/tests/blackbox/test_re_sign.py 2018-11-11 04:08:32 +0000
278+++ breezy/tests/blackbox/test_re_sign.py 2018-11-30 17:12:07 +0000
279@@ -24,7 +24,7 @@
280 tests,
281 )
282 from breezy.controldir import ControlDir
283-from breezy.testament import Testament
284+from breezy.bzr.testament import Testament
285
286
287 class ReSign(tests.TestCaseInTempDir):
288
289=== modified file 'breezy/tests/per_repository/test_signatures.py'
290--- breezy/tests/per_repository/test_signatures.py 2018-11-12 01:41:38 +0000
291+++ breezy/tests/per_repository/test_signatures.py 2018-11-30 17:12:07 +0000
292@@ -23,7 +23,7 @@
293 urlutils,
294 )
295
296-from breezy.testament import Testament
297+from breezy.bzr.testament import Testament
298 from breezy.tests import per_repository
299
300
301
302=== modified file 'breezy/tests/test_bundle.py'
303--- breezy/tests/test_bundle.py 2018-11-21 03:20:30 +0000
304+++ breezy/tests/test_bundle.py 2018-11-30 17:12:07 +0000
305@@ -1447,7 +1447,7 @@
306 tree_a.commit("base", allow_pointless=True, rev_id=b'A')
307 self.assertFalse(branch.repository.has_signature_for_revision_id(b'A'))
308 try:
309- from ..testament import Testament
310+ from ..bzr.testament import Testament
311 # monkey patch gpg signing mechanism
312 breezy.gpg.GPGStrategy = breezy.gpg.LoopbackGPGStrategy
313 new_config = test_commit.MustSignConfig()
314
315=== modified file 'breezy/tests/test_commit.py'
316--- breezy/tests/test_commit.py 2018-11-11 04:08:32 +0000
317+++ breezy/tests/test_commit.py 2018-11-30 17:12:07 +0000
318@@ -444,7 +444,7 @@
319 wt.commit("base", allow_pointless=True, rev_id=b'A')
320 self.assertFalse(branch.repository.has_signature_for_revision_id(b'A'))
321 try:
322- from ..testament import Testament
323+ from ..bzr.testament import Testament
324 # monkey patch gpg signing mechanism
325 breezy.gpg.GPGStrategy = breezy.gpg.LoopbackGPGStrategy
326 conf = config.MemoryStack(b'''
327
328=== modified file 'breezy/tests/test_smart.py'
329--- breezy/tests/test_smart.py 2018-11-12 01:41:38 +0000
330+++ breezy/tests/test_smart.py 2018-11-30 17:12:07 +0000
331@@ -53,7 +53,7 @@
332 server,
333 vfs,
334 )
335-from breezy.testament import Testament
336+from breezy.bzr.testament import Testament
337 from breezy.tests import test_server
338 from breezy.transport import (
339 chroot,
340
341=== modified file 'breezy/tests/test_testament.py'
342--- breezy/tests/test_testament.py 2018-11-11 04:08:32 +0000
343+++ breezy/tests/test_testament.py 2018-11-30 17:12:07 +0000
344@@ -22,7 +22,7 @@
345
346 from breezy import osutils
347 from breezy.tests import TestCaseWithTransport
348-from breezy.testament import (
349+from breezy.bzr.testament import (
350 Testament,
351 StrictTestament,
352 StrictTestament3,

Subscribers

People subscribed via source and target branches