~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/tree_implementations/test_tree.py

  • Committer: Robert Collins
  • Date: 2007-07-25 00:52:21 UTC
  • mfrom: (2650 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2651.
  • Revision ID: robertc@robertcollins.net-20070725005221-0ysm6il5mqnme3wz
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
        tree = self.get_tree_no_parents_abc_content(work_tree)
29
29
        tree_revision = getattr(tree, 'get_revision_id', lambda: 'current:')()
30
30
        tree.lock_read()
31
 
        try:
32
 
            for revision, line in tree.annotate_iter('a-id'):
33
 
                self.assertEqual('contents of a\n', line)
34
 
                self.assertEqual(tree_revision, revision)
35
 
        finally:
36
 
            tree.unlock()
 
31
        self.addCleanup(tree.unlock)
 
32
        for revision, line in tree.annotate_iter('a-id'):
 
33
            self.assertEqual('contents of a\n', line)
 
34
            self.assertEqual(tree_revision, revision)
 
35
        tree_revision = getattr(tree, 'get_revision_id', lambda: 'random:')()
 
36
        for revision, line in tree.annotate_iter('a-id', 'random:'):
 
37
            self.assertEqual('contents of a\n', line)
 
38
            self.assertEqual(tree_revision, revision)
 
39
 
 
40
 
 
41
class TestPlanFileMerge(TestCaseWithTree):
 
42
 
 
43
    def test_plan_file_merge(self):
 
44
        work_a = self.make_branch_and_tree('wta')
 
45
        self.build_tree_contents([('wta/file', 'a\nb\nc\nd\n')])
 
46
        work_a.add('file', 'file-id')
 
47
        work_a.commit('base version')
 
48
        work_b = work_a.bzrdir.sprout('wtb').open_workingtree()
 
49
        self.build_tree_contents([('wta/file', 'b\nc\nd\ne\n')])
 
50
        tree_a = self.workingtree_to_test_tree(work_a)
 
51
        tree_a.lock_read()
 
52
        self.addCleanup(tree_a.unlock)
 
53
        self.build_tree_contents([('wtb/file', 'a\nc\nd\nf\n')])
 
54
        tree_b = self.workingtree_to_test_tree(work_b)
 
55
        tree_b.lock_read()
 
56
        self.addCleanup(tree_b.unlock)
 
57
        self.assertEqual([
 
58
            ('killed-b', 'b\n'),
 
59
            ('killed-a', 'a\n'),
 
60
            ('unchanged', 'c\n'),
 
61
            ('unchanged', 'd\n'),
 
62
            ('new-a', 'e\n'),
 
63
            ('new-b', 'f\n'),
 
64
        ], list(tree_a.plan_file_merge('file-id', tree_b)))
37
65
 
38
66
 
39
67
class TestReference(TestCaseWithTree):