~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_revision_tree.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Tests for WorkingTree.revision_tree.
18
18
 
19
 
These tests are in addition to the tests from
20
 
per_tree.test_revision_tree which cover the behaviour expected from
 
19
These tests are in addition to the tests from 
 
20
tree_implementations.test_revision_tree which cover the behaviour expected from
21
21
all Trees. WorkingTrees implement the revision_tree api to allow access to
22
22
cached data, but we don't require that all WorkingTrees have such a cache,
23
23
so these tests are testing that when there is a cache, it performs correctly.
24
24
"""
25
25
 
26
 
from bzrlib import (
27
 
    errors,
28
 
    tests,
29
 
    )
30
 
from bzrlib.tests import per_workingtree
31
 
 
32
 
 
33
 
class TestRevisionTree(per_workingtree.TestCaseWithWorkingTree):
 
26
from bzrlib import errors
 
27
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
 
28
 
 
29
 
 
30
class TestRevisionTree(TestCaseWithWorkingTree):
34
31
 
35
32
    def test_get_zeroth_basis_tree_via_revision_tree(self):
36
33
        tree = self.make_branch_and_tree('.')
86
83
            return
87
84
        repository_revision_tree = tree.branch.repository.revision_tree(rev1)
88
85
        self.assertTreesEqual(repository_revision_tree, cached_revision_tree)
89
 
 
90
 
 
91
 
class TestRevisionTreeKind(per_workingtree.TestCaseWithWorkingTree):
92
 
 
93
 
    def make_branch_with_merged_deletions(self, relpath='tree'):
94
 
        tree = self.make_branch_and_tree(relpath)
95
 
        files = ['a', 'b/', 'b/c']
96
 
        self.build_tree(files, line_endings='binary',
97
 
                        transport=tree.bzrdir.root_transport)
98
 
        tree.set_root_id('root-id')
99
 
        tree.add(files, ['a-id', 'b-id', 'c-id'])
100
 
        tree.commit('a, b and b/c', rev_id='base')
101
 
        tree2 = tree.bzrdir.sprout(relpath + '2').open_workingtree()
102
 
        # Delete 'a' in tree
103
 
        tree.remove('a', keep_files=False)
104
 
        tree.commit('remove a', rev_id='this')
105
 
        # Delete 'c' in tree2
106
 
        tree2.remove('b/c', keep_files=False)
107
 
        tree2.remove('b', keep_files=False)
108
 
        tree2.commit('remove b/c', rev_id='other')
109
 
        # Merge tree2 into tree
110
 
        tree.merge_from_branch(tree2.branch)
111
 
        return tree
112
 
 
113
 
    def test_kind_parent_tree(self):
114
 
        tree = self.make_branch_with_merged_deletions()
115
 
        tree.lock_read()
116
 
        self.addCleanup(tree.unlock)
117
 
        parents = tree.get_parent_ids()
118
 
        self.assertEqual(['this', 'other'], parents)
119
 
        basis = tree.revision_tree(parents[0])
120
 
        basis.lock_read()
121
 
        self.addCleanup(basis.unlock)
122
 
        self.assertRaises(errors.NoSuchId, basis.kind, 'a-id')
123
 
        self.assertEqual(['directory', 'file'],
124
 
                         [basis.kind('b-id'), basis.kind('c-id')])
125
 
        try:
126
 
            other = tree.revision_tree(parents[1])
127
 
        except errors.NoSuchRevisionInTree:
128
 
            raise tests.TestNotApplicable(
129
 
                'Tree type %s caches only the basis revision tree.'
130
 
                % type(tree))
131
 
        other.lock_read()
132
 
        self.addCleanup(other.unlock)
133
 
        self.assertRaises(errors.NoSuchId, other.kind, 'b-id')
134
 
        self.assertRaises(errors.NoSuchId, other.kind, 'c-id')
135
 
        self.assertEqual('file', other.kind('a-id'))