Rev 3569: test that we can add more files into an existing build in http://bzr.arbash-meinel.com/branches/bzr/1.7-dev/branch_builder
John Arbash Meinel
john at arbash-meinel.com
Tue Jul 22 18:08:46 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.7-dev/branch_builder
------------------------------------------------------------
revno: 3569
revision-id: john at arbash-meinel.com-20080722170741-yy0w48dac09xp1lz
parent: john at arbash-meinel.com-20080722170355-00mcj4j1a8pdsout
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: branch_builder
timestamp: Tue 2008-07-22 12:07:41 -0500
message:
test that we can add more files into an existing build
-------------- next part --------------
=== modified file 'bzrlib/tests/test_branchbuilder.py'
--- a/bzrlib/tests/test_branchbuilder.py 2008-07-22 17:03:55 +0000
+++ b/bzrlib/tests/test_branchbuilder.py 2008-07-22 17:07:41 +0000
@@ -26,8 +26,15 @@
class TestBranchBuilder(tests.TestCaseWithMemoryTransport):
- def assertTreeShape(self, entries, tree):
+ def assertTreeShape(self, expected_shape, tree):
"""Check that the tree shape matches expectations."""
+ tree.lock_read()
+ try:
+ entries = [(path, ie.file_id, ie.kind)
+ for path, ie in tree.iter_entries_by_dir()]
+ finally:
+ tree.unlock()
+ self.assertEqual(expected_shape, entries)
def test_create(self):
"""Test the constructor api."""
@@ -86,8 +93,25 @@
rev_tree = branch.repository.revision_tree(rev_id1)
rev_tree.lock_read()
self.addCleanup(rev_tree.unlock)
- entries = [(path, ie.file_id, ie.kind)
- for path, ie in rev_tree.iter_entries_by_dir()]
- self.assertEqual([(u'', 'a-root-id', 'directory'),
- (u'a', 'a-id', 'file')], entries)
+ self.assertTreeShape([(u'', 'a-root-id', 'directory'),
+ (u'a', 'a-id', 'file')], rev_tree)
self.assertEqual('contents', rev_tree.get_file_text('a-id'))
+
+ def test_build_snapshot_add_content(self):
+ builder = BranchBuilder(self.get_transport().clone('foo'))
+ rev_id1 = builder.build_snapshot(None, 'A-id',
+ [('add', ('', 'a-root-id', 'directory', None)),
+ ('add', ('a', 'a-id', 'file', 'contents'))])
+ self.assertEqual('A-id', rev_id1)
+ rev_id2 = builder.build_snapshot(None, 'B-id',
+ [('add', ('b', 'b-id', 'file', 'content_b'))])
+ self.assertEqual('B-id', rev_id2)
+ branch = builder.get_branch()
+ self.assertEqual((2, rev_id2), branch.last_revision_info())
+ rev_tree = branch.repository.revision_tree(rev_id2)
+ rev_tree.lock_read()
+ self.addCleanup(rev_tree.unlock)
+ self.assertTreeShape([(u'', 'a-root-id', 'directory'),
+ (u'a', 'a-id', 'file'),
+ (u'b', 'b-id', 'file')], rev_tree)
+ self.assertEqual('content_b', rev_tree.get_file_text('b-id'))
More information about the bazaar-commits
mailing list