90
89
super(TestTreeTransform, self).setUp()
91
self.wt = self.make_branch_and_tree('.', format='development-subtree')
90
self.wt = self.make_branch_and_tree('.', format='dirstate-with-subtree')
94
93
def get_transform(self):
1554
1554
self.assertPathExists("foo")
1556
1556
self.addCleanup(wt.unlock)
1557
self.assertEqual(wt.kind(wt.path2id("foo")), "symlink")
1557
self.assertEqual(wt.inventory.get_file_kind(wt.path2id("foo")),
1559
1560
def test_dir_to_file(self):
1560
1561
wt = self.make_branch_and_tree('.')
1572
1573
self.assertPathExists("foo")
1574
1575
self.addCleanup(wt.unlock)
1575
self.assertEqual(wt.kind(wt.path2id("foo")), "file")
1576
self.assertEqual(wt.inventory.get_file_kind(wt.path2id("foo")),
1577
1579
def test_dir_to_hardlink(self):
1578
1580
self.requireFeature(HardlinkFeature)
1593
1595
self.assertPathExists("baz")
1595
1597
self.addCleanup(wt.unlock)
1596
self.assertEqual(wt.kind(wt.path2id("foo")), "file")
1598
self.assertEqual(wt.inventory.get_file_kind(wt.path2id("foo")),
1598
1601
def test_no_final_path(self):
1599
1602
transform, root = self.get_transform()
1761
1764
merge_modified = this.wt.merge_modified()
1762
1765
self.assertSubset(merge_modified, modified)
1763
1766
self.assertEqual(len(merge_modified), len(modified))
1764
with file(this.wt.id2abspath('a'), 'wb') as f: f.write('booga')
1767
file(this.wt.id2abspath('a'), 'wb').write('booga')
1765
1768
modified.pop(0)
1766
1769
merge_modified = this.wt.merge_modified()
1767
1770
self.assertSubset(merge_modified, modified)
1884
1887
a = BzrDir.create_standalone_workingtree('a')
1885
1888
os.mkdir('a/foo')
1886
with file('a/foo/bar', 'wb') as f: f.write('contents')
1889
file('a/foo/bar', 'wb').write('contents')
1887
1890
os.symlink('a/foo/bar', 'a/foo/baz')
1888
1891
a.add(['foo', 'foo/bar', 'foo/baz'])
1889
1892
a.commit('initial commit')
1899
1902
def test_build_with_references(self):
1900
1903
tree = self.make_branch_and_tree('source',
1901
format='development-subtree')
1904
format='dirstate-with-subtree')
1902
1905
subtree = self.make_branch_and_tree('source/subtree',
1903
format='development-subtree')
1906
format='dirstate-with-subtree')
1904
1907
tree.add_reference(subtree)
1905
1908
tree.commit('a revision')
1906
1909
tree.branch.create_checkout('target')
2793
2796
def test_iter_changes(self):
2794
2797
revision_tree, preview_tree = self.get_tree_and_preview_tree()
2795
root = revision_tree.get_root_id()
2798
root = revision_tree.inventory.root.file_id
2796
2799
self.assertEqual([('a-id', ('a', 'a'), True, (True, True),
2797
2800
(root, root), ('a', 'a'), ('file', 'file'),
2798
2801
(False, False))],
2802
2805
revision_tree, preview_tree = self.get_tree_and_preview_tree()
2803
2806
changes = preview_tree.iter_changes(revision_tree,
2804
2807
include_unchanged=True)
2805
root = revision_tree.get_root_id()
2808
root = revision_tree.inventory.root.file_id
2807
2810
self.assertEqual([ROOT_ENTRY, A_ENTRY], list(changes))
3634
3637
self.assertRaises(NotImplementedError, tt.new_orphan, 'foo', 'bar')
3636
3639
def _set_orphan_policy(self, wt, policy):
3637
wt.branch.get_config_stack().set('bzr.transform.orphan_policy',
3640
wt.branch.get_config().set_user_option('bzr.transform.orphan_policy',
3640
3643
def _prepare_orphan(self, wt):
3714
3717
remaining_conflicts.pop())
3715
3718
self.assertLength(1, warnings)
3716
3719
self.assertStartsWith(warnings[0], 'donttouchmypreciouuus')
3719
class TestTransformHooks(tests.TestCaseWithTransport):
3722
super(TestTransformHooks, self).setUp()
3723
self.wt = self.make_branch_and_tree('.')
3726
def get_transform(self):
3727
transform = TreeTransform(self.wt)
3728
self.addCleanup(transform.finalize)
3729
return transform, transform.root
3731
def test_pre_commit_hooks(self):
3733
def record_pre_transform(tree, tt):
3734
calls.append((tree, tt))
3735
MutableTree.hooks.install_named_hook('pre_transform',
3736
record_pre_transform, "Pre transform")
3737
transform, root = self.get_transform()
3738
old_root_id = transform.tree_file_id(root)
3740
self.assertEqual(old_root_id, self.wt.get_root_id())
3741
self.assertEquals([(self.wt, transform)], calls)
3743
def test_post_commit_hooks(self):
3745
def record_post_transform(tree, tt):
3746
calls.append((tree, tt))
3747
MutableTree.hooks.install_named_hook('post_transform',
3748
record_post_transform, "Post transform")
3749
transform, root = self.get_transform()
3750
old_root_id = transform.tree_file_id(root)
3752
self.assertEqual(old_root_id, self.wt.get_root_id())
3753
self.assertEquals([(self.wt, transform)], calls)