~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2007-01-12 04:48:18 UTC
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20070112044818-nnw6iunriqq073qc
Implement tree comparison for tree references

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):
25
26
        for revision, line in tree.annotate_iter('a-id'):
26
27
            self.assertEqual('contents of a\n', line)
27
28
            self.assertEqual(tree_revision, revision)
 
29
 
 
30
 
 
31
class TestReference(TestCaseWithTree):
 
32
 
 
33
    def skip_if_no_reference(self, tree):
 
34
        if not getattr(tree, 'supports_tree_reference', lambda: False)():
 
35
            raise tests.TestSkipped('Tree references not supported')
 
36
 
 
37
    def test_get_reference_revision(self):
 
38
        work_tree = self.make_branch_and_tree('wt')
 
39
        self.skip_if_no_reference(work_tree)
 
40
        subtree = self.make_branch_and_tree('wt/subtree')
 
41
        subtree.set_root_id('sub-root')
 
42
        subtree.commit('foo', rev_id='sub-1')
 
43
        work_tree.add_reference(subtree)
 
44
        tree = self._convert_tree(work_tree)
 
45
        self.skip_if_no_reference(tree)
 
46
        entry = tree.inventory['sub-root']
 
47
        path = tree.id2path('sub-root')
 
48
        self.assertEqual('sub-1', tree.get_reference_revision(entry, path))
 
49
        self.assertEqual('sub-1', tree.get_reference_revision(entry))