bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1908.11.5
by John Arbash Meinel
[merge] bzr.dev 2240 |
1 |
# Copyright (C) 2006 Canonical Ltd
|
|
1908.11.2
by Robert Collins
Implement WorkingTree interface conformance tests for |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1908.11.2
by Robert Collins
Implement WorkingTree interface conformance tests for |
16 |
|
17 |
"""Tests for WorkingTree.revision_tree.
|
|
18 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
19 |
These tests are in addition to the tests from
|
|
1908.11.2
by Robert Collins
Implement WorkingTree interface conformance tests for |
20 |
tree_implementations.test_revision_tree which cover the behaviour expected from
|
21 |
all Trees. WorkingTrees implement the revision_tree api to allow access to
|
|
22 |
cached data, but we don't require that all WorkingTrees have such a cache,
|
|
23 |
so these tests are testing that when there is a cache, it performs correctly.
|
|
24 |
"""
|
|
25 |
||
26 |
from bzrlib import errors |
|
27 |
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree |
|
28 |
||
29 |
||
30 |
class TestRevisionTree(TestCaseWithWorkingTree): |
|
31 |
||
32 |
def test_get_zeroth_basis_tree_via_revision_tree(self): |
|
33 |
tree = self.make_branch_and_tree('.') |
|
34 |
try: |
|
35 |
revision_tree = tree.revision_tree(tree.last_revision()) |
|
36 |
except errors.NoSuchRevision: |
|
37 |
# its ok for a working tree to not cache trees, so just return.
|
|
38 |
return
|
|
39 |
basis_tree = tree.basis_tree() |
|
40 |
self.assertTreesEqual(revision_tree, basis_tree) |
|
41 |
||
42 |
def test_get_nonzeroth_basis_tree_via_revision_tree(self): |
|
43 |
tree = self.make_branch_and_tree('.') |
|
44 |
revision1 = tree.commit('first post') |
|
45 |
revision_tree = tree.revision_tree(revision1) |
|
46 |
basis_tree = tree.basis_tree() |
|
47 |
self.assertTreesEqual(revision_tree, basis_tree) |
|
48 |
||
49 |
def test_get_pending_merge_revision_tree(self): |
|
50 |
tree = self.make_branch_and_tree('tree1') |
|
51 |
tree.commit('first post') |
|
52 |
tree2 = tree.bzrdir.sprout('tree2').open_workingtree() |
|
53 |
revision1 = tree2.commit('commit in branch', allow_pointless=True) |
|
54 |
tree.merge_from_branch(tree2.branch) |
|
55 |
try: |
|
56 |
cached_revision_tree = tree.revision_tree(revision1) |
|
57 |
except errors.NoSuchRevision: |
|
58 |
# its ok for a working tree to not cache trees, so just return.
|
|
59 |
return
|
|
60 |
real_revision_tree = tree2.basis_tree() |
|
61 |
self.assertTreesEqual(real_revision_tree, cached_revision_tree) |
|
62 |
||
63 |
def test_get_uncached_basis_via_revision_tree(self): |
|
64 |
# The basis_tree method returns an empty tree when you ask for the
|
|
65 |
# basis if the basis is not cached, and it is a ghost. However the
|
|
66 |
# revision_tree method should always raise when a request tree is not
|
|
67 |
# cached, so we force this by setting a basis that is a ghost and
|
|
68 |
# thus cannot be cached.
|
|
69 |
tree = self.make_branch_and_tree('.') |
|
70 |
tree.set_parent_ids(['a-ghost'], allow_leftmost_as_ghost=True) |
|
71 |
self.assertRaises(errors.NoSuchRevision, tree.revision_tree, 'a-ghost') |
|
|
2255.2.76
by Robert Collins
Add tests for revision trees with a different unique root to the current tree. |
72 |
|
73 |
def test_revision_tree_different_root_id(self): |
|
74 |
"""A revision tree might have a very different root.""" |
|
75 |
tree = self.make_branch_and_tree('tree1') |
|
76 |
tree.set_root_id('one') |
|
77 |
rev1 = tree.commit('first post') |
|
78 |
tree.set_root_id('two') |
|
79 |
try: |
|
80 |
cached_revision_tree = tree.revision_tree(rev1) |
|
81 |
except errors.NoSuchRevision: |
|
82 |
# its ok for a working tree to not cache trees, so just return.
|
|
83 |
return
|
|
84 |
repository_revision_tree = tree.branch.repository.revision_tree(rev1) |
|
85 |
self.assertTreesEqual(repository_revision_tree, cached_revision_tree) |