Merge lp:~abentley/bzr/commit-preview into lp:~bzr/bzr/trunk-old

Proposed by Aaron Bentley on 2009-05-20
Status: Merged
Merged at revision: not available
Proposed branch: lp:~abentley/bzr/commit-preview
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 41 lines
To merge this branch: bzr merge lp:~abentley/bzr/commit-preview
Reviewer Review Type Date Requested Status
Bazaar Developers 2009-05-20 Pending
Review via email: mp+6716@code.launchpad.net
To post a comment you must log in.
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

This patch enables committing a TreeTransform and its PreviewTree to a
branch. This allows synthetic trees to be committed to disk. It could
be useful with looms and for committing to new branches. The current
client is Launchpad Translations.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkoUPMEACgkQ0F+nu1YWqI0c4wCfRowxvpZOFBbHBe2xF/1QZGHM
a5AAn3YvgboQD/78oaR5ZqpbwcOp5iXG
=PRxG
-----END PGP SIGNATURE-----

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/test_transform.py'
2--- bzrlib/tests/test_transform.py 2009-05-06 05:36:28 +0000
3+++ bzrlib/tests/test_transform.py 2009-05-20 17:35:10 +0000
4@@ -2604,6 +2604,23 @@
5 'tree/foo'))
6 self.assertEqual(False, preview_tree.is_executable('baz-id'))
7
8+ def test_commit_preview_tree(self):
9+ tree = self.make_branch_and_tree('tree')
10+ rev_id = tree.commit('rev1')
11+ tree.branch.lock_write()
12+ self.addCleanup(tree.branch.unlock)
13+ tt = TransformPreview(tree)
14+ tt.new_file('file', tt.root, 'contents', 'file_id')
15+ self.addCleanup(tt.finalize)
16+ preview = tt.get_preview_tree()
17+ preview.set_parent_ids([rev_id])
18+ builder = tree.branch.get_commit_builder([rev_id])
19+ list(builder.record_iter_changes(preview, rev_id, tt.iter_changes()))
20+ builder.finish_inventory()
21+ rev2_id = builder.commit('rev2')
22+ rev2_tree = tree.branch.repository.revision_tree(rev2_id)
23+ self.assertEqual('contents', rev2_tree.get_file_text('file_id'))
24+
25
26 class FakeSerializer(object):
27 """Serializer implementation that simply returns the input.
28
29=== modified file 'bzrlib/transform.py'
30--- bzrlib/transform.py 2009-05-06 05:36:28 +0000
31+++ bzrlib/transform.py 2009-05-20 17:35:10 +0000
32@@ -1880,6 +1880,9 @@
33 name = self._transform._limbo_name(trans_id)
34 return open(name, 'rb')
35
36+ def get_file_with_stat(self, file_id, path):
37+ return self.get_file(file_id, path), None
38+
39 def annotate_iter(self, file_id,
40 default_revision=_mod_revision.CURRENT_REVISION):
41 changes = self._changes(file_id)