1
1
from bzrlib.tests import TestCaseInTempDir
2
2
from bzrlib.branch import Branch
3
3
from bzrlib.transform import TreeTransform
4
from bzrlib.errors import DuplicateKey
4
from bzrlib.errors import DuplicateKey, MalformedTransform
6
6
class TestTreeTransform(TestCaseInTempDir):
7
7
def test_build(self):
34
34
trans_id = transform.new_file('name', root, 'contents',
37
self.assertEqual(len(transform.find_conflicts()), 0)
38
self.assertEqual('contents', file('name').read())
39
self.assertEqual(wt.path2id('name'), 'my_pretties')
43
def test_conflicts(self):
44
branch = Branch.initialize('.')
45
wt = branch.working_tree()
46
transform = TreeTransform(wt)
48
root = transform.get_id_tree(wt.get_root_id())
49
trans_id = transform.new_file('name', root, 'contents',
51
self.assertEqual(len(transform.find_conflicts()), 0)
52
trans_id2 = transform.new_file('name', root, 'Crontents', 'toto')
53
self.assertEqual(transform.find_conflicts(),
54
[('duplicate', trans_id, trans_id2)])
55
self.assertRaises(MalformedTransform, transform.apply)
56
transform.adjust_path('name2', root, trans_id2)
37
58
self.assertEqual('contents', file('name').read())
38
59
self.assertEqual(wt.path2id('name'), 'my_pretties')