Beispiel #1
0
 def test_id2path(self):
     self.oldtree.lock_write()
     self.addCleanup(self.oldtree.unlock)
     builder = TreeBuilder()
     builder.start_tree(self.oldtree)
     builder.build(['foo'])
     builder.build(['bar'])
     builder.build(['bla'])
     builder.finish_tree()
     self.maptree = MapTree(self.oldtree, {})
     self.assertEquals("foo",
             self.maptree.id2path(self.maptree.path2id("foo")))
Beispiel #2
0
 def test_has_id(self):
     self.oldtree.lock_write()
     self.addCleanup(self.oldtree.unlock)
     builder = TreeBuilder()
     builder.start_tree(self.oldtree)
     builder.build(['foo'])
     builder.build(['bar'])
     builder.build(['bla'])
     builder.finish_tree()
     self.maptree = MapTree(self.oldtree, {})
     self.assertTrue(self.maptree.has_id(
                           self.maptree.path2id("foo")))
     self.assertFalse(self.maptree.has_id("bar"))
 def test_build_tree(self):
     """Test building works using a MemoryTree."""
     branch = self.make_branch('branch')
     tree = MemoryTree.create_on_branch(branch)
     builder = TreeBuilder()
     builder.start_tree(tree)
     builder.build(['foo', "bar/", "bar/file"])
     self.assertEqual('contents of foo\n',
         tree.get_file(tree.path2id('foo')).read())
     self.assertEqual('contents of bar/file\n',
         tree.get_file(tree.path2id('bar/file')).read())
     builder.finish_tree()
Beispiel #4
0
 def test_has_filename(self):
     self.oldtree.lock_write()
     builder = TreeBuilder()
     builder.start_tree(self.oldtree)
     builder.build(['foo'])
     builder.finish_tree()
     self.maptree = MapTree(self.oldtree, {})
     self.oldtree.unlock()
     self.assertTrue(self.maptree.has_filename('foo'))
     self.assertTrue(self.oldtree.has_filename('foo'))
     self.assertFalse(self.maptree.has_filename('bar'))
Beispiel #5
0
 def test_build_tree(self):
     """Test building works using a MemoryTree."""
     branch = self.make_branch('branch')
     tree = MemoryTree.create_on_branch(branch)
     builder = TreeBuilder()
     builder.start_tree(tree)
     builder.build(['foo', "bar/", "bar/file"])
     self.assertEqual('contents of foo\n',
         tree.get_file(tree.path2id('foo')).read())
     self.assertEqual('contents of bar/file\n',
         tree.get_file(tree.path2id('bar/file')).read())
     builder.finish_tree()
Beispiel #6
0
 def test_create_on_branch_with_content(self):
     """Creating a mutable tree on a non-trivial branch works."""
     branch = self.make_branch('branch')
     tree = MemoryTree.create_on_branch(branch)
     # build some content
     tree.lock_write()
     builder = TreeBuilder()
     builder.start_tree(tree)
     builder.build(['foo'])
     builder.finish_tree()
     rev_id = tree.commit('first post')
     tree.unlock()
     tree = MemoryTree.create_on_branch(branch)
     tree.lock_read()
     self.assertEqual([rev_id], tree.get_parent_ids())
     self.assertEqual('contents of foo\n',
                      tree.get_file(tree.path2id('foo')).read())
     tree.unlock()
Beispiel #7
0
 def test_create_on_branch_with_content(self):
     """Creating a mutable tree on a non-trivial branch works."""
     branch = self.make_branch('branch')
     tree = MemoryTree.create_on_branch(branch)
     # build some content
     tree.lock_write()
     builder = TreeBuilder()
     builder.start_tree(tree)
     builder.build(['foo'])
     builder.finish_tree()
     rev_id = tree.commit('first post')
     tree.unlock()
     tree = MemoryTree.create_on_branch(branch)
     tree.lock_read()
     self.assertEqual([rev_id], tree.get_parent_ids())
     self.assertEqual('contents of foo\n',
         tree.get_file(tree.path2id('foo')).read())
     tree.unlock()
Beispiel #8
0
 def test_finish_tree_unlocks(self):
     builder = TreeBuilder()
     tree = FakeTree()
     builder.start_tree(tree)
     builder.finish_tree()
     self.assertEqual(["lock_tree_write", "unlock"], tree._calls)
Beispiel #9
0
 def test_start_tree_when_started_fails(self):
     builder = TreeBuilder()
     tree = FakeTree()
     builder.start_tree(tree)
     self.assertRaises(errors.AlreadyBuilding, builder.start_tree, tree)
Beispiel #10
0
 def test_start_tree_locks_write(self):
     builder = TreeBuilder()
     tree = FakeTree()
     builder.start_tree(tree)
     self.assertEqual(["lock_tree_write"], tree._calls)
 def test_build_tree_not_started_errors(self):
     builder = TreeBuilder()
     self.assertRaises(errors.NotBuilding, builder.build, "foo")
 def test_finish_tree_unlocks(self):
     builder = TreeBuilder()
     tree = FakeTree()
     builder.start_tree(tree)
     builder.finish_tree()
     self.assertEqual(["lock_tree_write", "unlock"], tree._calls)
 def test_finish_tree_not_started_errors(self):
     builder = TreeBuilder()
     self.assertRaises(errors.NotBuilding, builder.finish_tree)
 def test_start_tree_when_started_fails(self):
     builder = TreeBuilder()
     tree = FakeTree()
     builder.start_tree(tree)
     self.assertRaises(errors.AlreadyBuilding, builder.start_tree, tree)
 def test_start_tree_locks_write(self):
     builder = TreeBuilder()
     tree = FakeTree()
     builder.start_tree(tree)
     self.assertEqual(["lock_tree_write"], tree._calls)
 def test_create(self):
     builder = TreeBuilder()