Merge lp:~jelmer/bzr/add-revision-doesnt-sign into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Martin Packman
Approved revision: no longer in the source branch.
Merged at revision: 6424
Proposed branch: lp:~jelmer/bzr/add-revision-doesnt-sign
Merge into: lp:bzr
Diff against target: 102 lines (+17/-27)
3 files modified
bzrlib/remote.py (+6/-12)
bzrlib/vf_repository.py (+8/-15)
doc/en/release-notes/bzr-2.5.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/bzr/add-revision-doesnt-sign
Reviewer Review Type Date Requested Status
Martin Packman (community) Approve
Review via email: mp+87496@code.launchpad.net

Commit message

Remove config argument from VersionedFileRepository.add_revision()

Description of the change

Some refactoring of VersionedFileRepository.add_revision:

 * Move revision signing to the CommitBuilder. Revision signing was only done
   if the 'config' argument was specified, and that was only done by the
   commit builder anyway.

 * The commit builder now uses the private _add_revision method which skips
   some checks on the revision object that the commit builder
   already guarantees

These changes are prerequisites for my next branch, which should make reduce
the number of roundtrips for HPSS commits to < 30.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Looks sensible. If the current tests don't mind where the signing happens that's a good sign. No pun intended.

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) 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/remote.py'
2--- bzrlib/remote.py 2012-01-03 17:08:29 +0000
3+++ bzrlib/remote.py 2012-01-04 16:12:24 +0000
4@@ -1844,17 +1844,8 @@
5 delta, new_revision_id, parents, basis_inv=basis_inv,
6 propagate_caches=propagate_caches)
7
8- def add_revision(self, revision_id, rev, inv=None, config=None):
9+ def add_revision(self, revision_id, rev, inv=None):
10 _mod_revision.check_not_reserved_id(revision_id)
11- if (config is not None and
12- config.get('create_signatures') == _mod_config.SIGN_ALWAYS):
13- if inv is None:
14- inv = self.get_inventory(revision_id)
15- tree = InventoryRevisionTree(self, inv, revision_id)
16- testament = _mod_testament.Testament(rev, tree)
17- plaintext = testament.as_short_text()
18- self.store_revision_signature(
19- gpg.GPGStrategy(config), plaintext, revision_id)
20 key = (revision_id,)
21 # check inventory present
22 if not self.inventories.get_parent_map([key]):
23@@ -1867,10 +1858,13 @@
24 rev.parent_ids)
25 else:
26 rev.inventory_sha1 = self.inventories.get_sha1s([key])[key]
27+ self._add_revision(rev)
28+
29+ def _add_revision(self, rev):
30 if self._real_repository is not None:
31- return self._real_repository.add_revision(
32- revision_id, rev, inv, config)
33+ return self._real_repository._add_revision(rev)
34 text = self._serializer.write_revision_to_string(rev)
35+ key = (rev.revision_id,)
36 parents = tuple((parent,) for parent in rev.parent_ids)
37 self._write_group_tokens, missing_keys = self._get_sink().insert_stream(
38 [('revisions', [FulltextContentFactory(key, parents, None, text)])],
39
40=== modified file 'bzrlib/vf_repository.py'
41--- bzrlib/vf_repository.py 2011-12-19 13:23:58 +0000
42+++ bzrlib/vf_repository.py 2012-01-04 16:12:24 +0000
43@@ -200,8 +200,13 @@
44 revision_id=self._new_revision_id,
45 properties=self._revprops)
46 rev.parent_ids = self.parents
47- self.repository.add_revision(self._new_revision_id, rev,
48- self.new_inventory, self._config_stack)
49+ if self._config_stack.get('create_signatures') == _mod_config.SIGN_ALWAYS:
50+ testament = Testament(rev, self.revision_tree())
51+ plaintext = testament.as_short_text()
52+ self.repository.store_revision_signature(
53+ gpg.GPGStrategy(self._config_stack), plaintext,
54+ self._new_revision_id)
55+ self.repository._add_revision(rev)
56 self._ensure_fallback_inventories()
57 self.repository.commit_write_group()
58 return self._new_revision_id
59@@ -1033,29 +1038,17 @@
60 self.inventories._access.flush()
61 return result
62
63- def add_revision(self, revision_id, rev, inv=None, config=None):
64+ def add_revision(self, revision_id, rev, inv=None):
65 """Add rev to the revision store as revision_id.
66
67 :param revision_id: the revision id to use.
68 :param rev: The revision object.
69 :param inv: The inventory for the revision. if None, it will be looked
70 up in the inventory storer
71- :param config: If None no digital signature will be created.
72- If supplied its signature_needed method will be used
73- to determine if a signature should be made.
74 """
75 # TODO: jam 20070210 Shouldn't we check rev.revision_id and
76 # rev.parent_ids?
77 _mod_revision.check_not_reserved_id(revision_id)
78- if (config is not None and
79- config.get('create_signatures') == _mod_config.SIGN_ALWAYS):
80- if inv is None:
81- inv = self.get_inventory(revision_id)
82- tree = InventoryRevisionTree(self, inv, revision_id)
83- testament = Testament(rev, tree)
84- plaintext = testament.as_short_text()
85- self.store_revision_signature(
86- gpg.GPGStrategy(config), plaintext, revision_id)
87 # check inventory present
88 if not self.inventories.get_parent_map([(revision_id,)]):
89 if inv is None:
90
91=== modified file 'doc/en/release-notes/bzr-2.5.txt'
92--- doc/en/release-notes/bzr-2.5.txt 2012-01-03 13:21:09 +0000
93+++ doc/en/release-notes/bzr-2.5.txt 2012-01-04 16:12:24 +0000
94@@ -125,6 +125,9 @@
95 which can be None or a Branch object for the submit branch location.
96 (Jelmer Vernooij)
97
98+* ``VersionedFileRepository.add_revision`` no longer takes a ``config``
99+ argument. (Jelmer Vernooij)
100+
101 Internals
102 *********
103