~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge from by-reference-trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
from bzrlib import tests
17
18
from bzrlib.tests.tree_implementations import TestCaseWithTree
18
19
 
19
20
class TestAnnotate(TestCaseWithTree):
29
30
                self.assertEqual(tree_revision, revision)
30
31
        finally:
31
32
            tree.unlock()
 
33
 
 
34
 
 
35
class TestReference(TestCaseWithTree):
 
36
 
 
37
    def skip_if_no_reference(self, tree):
 
38
        if not getattr(tree, 'supports_tree_reference', lambda: False)():
 
39
            raise tests.TestSkipped('Tree references not supported')
 
40
 
 
41
    def create_nested(self):
 
42
        work_tree = self.make_branch_and_tree('wt')
 
43
        self.skip_if_no_reference(work_tree)
 
44
        subtree = self.make_branch_and_tree('wt/subtree')
 
45
        subtree.set_root_id('sub-root')
 
46
        subtree.commit('foo', rev_id='sub-1')
 
47
        work_tree.add_reference(subtree)
 
48
        tree = self._convert_tree(work_tree)
 
49
        self.skip_if_no_reference(tree)
 
50
        return tree
 
51
 
 
52
    def test_get_reference_revision(self):
 
53
        tree = self.create_nested()
 
54
        entry = tree.inventory['sub-root']
 
55
        path = tree.id2path('sub-root')
 
56
        self.assertEqual('sub-1', tree.get_reference_revision(entry, path))
 
57
 
 
58
    def test_iter_reference_entries(self):
 
59
        tree = self.create_nested()
 
60
        entry = tree.inventory['sub-root']
 
61
        self.assertEqual([entry], [e for p, e in
 
62
                                   tree.iter_reference_entries()])