bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
1 |
# Copyright (C) 2006, 2007, 2009, 2010 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
|
|
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
20 |
per_tree.test_revision_tree which cover the behaviour expected from
|
|
1908.11.2
by Robert Collins
Implement WorkingTree interface conformance tests for |
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 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
26 |
from breezy import ( |
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
27 |
errors, |
28 |
tests, |
|
29 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
30 |
from breezy.tests import per_workingtree |
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
31 |
|
32 |
||
33 |
class TestRevisionTree(per_workingtree.TestCaseWithWorkingTree): |
|
|
1908.11.2
by Robert Collins
Implement WorkingTree interface conformance tests for |
34 |
|
35 |
def test_get_zeroth_basis_tree_via_revision_tree(self): |
|
36 |
tree = self.make_branch_and_tree('.') |
|
37 |
try: |
|
38 |
revision_tree = tree.revision_tree(tree.last_revision()) |
|
39 |
except errors.NoSuchRevision: |
|
40 |
# its ok for a working tree to not cache trees, so just return.
|
|
41 |
return
|
|
42 |
basis_tree = tree.basis_tree() |
|
43 |
self.assertTreesEqual(revision_tree, basis_tree) |
|
44 |
||
45 |
def test_get_nonzeroth_basis_tree_via_revision_tree(self): |
|
46 |
tree = self.make_branch_and_tree('.') |
|
47 |
revision1 = tree.commit('first post') |
|
48 |
revision_tree = tree.revision_tree(revision1) |
|
49 |
basis_tree = tree.basis_tree() |
|
50 |
self.assertTreesEqual(revision_tree, basis_tree) |
|
51 |
||
52 |
def test_get_pending_merge_revision_tree(self): |
|
53 |
tree = self.make_branch_and_tree('tree1') |
|
54 |
tree.commit('first post') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
55 |
tree2 = tree.controldir.sprout('tree2').open_workingtree() |
|
1908.11.2
by Robert Collins
Implement WorkingTree interface conformance tests for |
56 |
revision1 = tree2.commit('commit in branch', allow_pointless=True) |
57 |
tree.merge_from_branch(tree2.branch) |
|
58 |
try: |
|
59 |
cached_revision_tree = tree.revision_tree(revision1) |
|
60 |
except errors.NoSuchRevision: |
|
61 |
# its ok for a working tree to not cache trees, so just return.
|
|
62 |
return
|
|
63 |
real_revision_tree = tree2.basis_tree() |
|
64 |
self.assertTreesEqual(real_revision_tree, cached_revision_tree) |
|
65 |
||
66 |
def test_get_uncached_basis_via_revision_tree(self): |
|
67 |
# The basis_tree method returns an empty tree when you ask for the
|
|
68 |
# basis if the basis is not cached, and it is a ghost. However the
|
|
69 |
# revision_tree method should always raise when a request tree is not
|
|
70 |
# cached, so we force this by setting a basis that is a ghost and
|
|
71 |
# thus cannot be cached.
|
|
72 |
tree = self.make_branch_and_tree('.') |
|
|
6844.1.1
by Jelmer Vernooij
Many more foreign branch fixes. |
73 |
if not tree.branch.repository._format.supports_ghosts: |
74 |
self.skipTest('format does not support ghosts') |
|
|
6973.10.6
by Jelmer Vernooij
Fix tests. |
75 |
tree.set_parent_ids([b'a-ghost'], allow_leftmost_as_ghost=True) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
76 |
self.assertRaises(errors.NoSuchRevision, |
77 |
tree.revision_tree, b'a-ghost') |
|
|
2255.2.76
by Robert Collins
Add tests for revision trees with a different unique root to the current tree. |
78 |
|
79 |
def test_revision_tree_different_root_id(self): |
|
80 |
"""A revision tree might have a very different root.""" |
|
81 |
tree = self.make_branch_and_tree('tree1') |
|
|
6844.1.1
by Jelmer Vernooij
Many more foreign branch fixes. |
82 |
if not tree.supports_setting_file_ids(): |
83 |
raise tests.TestNotApplicable( |
|
84 |
'tree does not support setting file ids') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
85 |
tree.set_root_id(b'one') |
|
2255.2.76
by Robert Collins
Add tests for revision trees with a different unique root to the current tree. |
86 |
rev1 = tree.commit('first post') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
87 |
tree.set_root_id(b'two') |
|
2255.2.76
by Robert Collins
Add tests for revision trees with a different unique root to the current tree. |
88 |
try: |
89 |
cached_revision_tree = tree.revision_tree(rev1) |
|
90 |
except errors.NoSuchRevision: |
|
91 |
# its ok for a working tree to not cache trees, so just return.
|
|
92 |
return
|
|
93 |
repository_revision_tree = tree.branch.repository.revision_tree(rev1) |
|
94 |
self.assertTreesEqual(repository_revision_tree, cached_revision_tree) |
|
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
95 |
|
96 |
||
97 |
class TestRevisionTreeKind(per_workingtree.TestCaseWithWorkingTree): |
|
98 |
||
99 |
def make_branch_with_merged_deletions(self, relpath='tree'): |
|
100 |
tree = self.make_branch_and_tree(relpath) |
|
101 |
files = ['a', 'b/', 'b/c'] |
|
102 |
self.build_tree(files, line_endings='binary', |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
103 |
transport=tree.controldir.root_transport) |
|
6844.1.1
by Jelmer Vernooij
Many more foreign branch fixes. |
104 |
tree.add(files) |
|
6861.5.2
by Jelmer Vernooij
Fix some more foreign branch tests. |
105 |
base_revid = tree.commit('a, b and b/c') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
106 |
tree2 = tree.controldir.sprout(relpath + '2').open_workingtree() |
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
107 |
# Delete 'a' in tree
|
108 |
tree.remove('a', keep_files=False) |
|
|
6861.5.2
by Jelmer Vernooij
Fix some more foreign branch tests. |
109 |
this_revid = tree.commit('remove a') |
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
110 |
# Delete 'c' in tree2
|
111 |
tree2.remove('b/c', keep_files=False) |
|
112 |
tree2.remove('b', keep_files=False) |
|
|
6861.5.2
by Jelmer Vernooij
Fix some more foreign branch tests. |
113 |
other_revid = tree2.commit('remove b/c') |
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
114 |
# Merge tree2 into tree
|
115 |
tree.merge_from_branch(tree2.branch) |
|
|
6861.5.2
by Jelmer Vernooij
Fix some more foreign branch tests. |
116 |
return tree, [base_revid, this_revid, other_revid] |
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
117 |
|
118 |
def test_kind_parent_tree(self): |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
119 |
tree, [base_revid, this_revid, |
120 |
other_revid] = self.make_branch_with_merged_deletions() |
|
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
121 |
tree.lock_read() |
122 |
self.addCleanup(tree.unlock) |
|
123 |
parents = tree.get_parent_ids() |
|
|
6861.5.2
by Jelmer Vernooij
Fix some more foreign branch tests. |
124 |
self.assertEqual([this_revid, other_revid], parents) |
|
5080.3.4
by Vincent Ladeuil
Cleanup test from overly cautious checks. |
125 |
basis = tree.revision_tree(parents[0]) |
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
126 |
basis.lock_read() |
127 |
self.addCleanup(basis.unlock) |
|
|
6883.10.1
by Jelmer Vernooij
Fix more tets. |
128 |
self.assertRaises(errors.NoSuchFile, basis.kind, 'a') |
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
129 |
self.assertEqual(['directory', 'file'], |
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
130 |
[basis.kind('b'), basis.kind('b/c')]) |
|
5080.3.2
by Vincent Ladeuil
Reproduce bug #533547 where DirstateRevisionTree.kind query the wrong inventory entry. |
131 |
try: |
132 |
other = tree.revision_tree(parents[1]) |
|
133 |
except errors.NoSuchRevisionInTree: |
|
134 |
raise tests.TestNotApplicable( |
|
135 |
'Tree type %s caches only the basis revision tree.' |
|
136 |
% type(tree)) |
|
137 |
other.lock_read() |
|
138 |
self.addCleanup(other.unlock) |
|
|
6883.10.1
by Jelmer Vernooij
Fix more tets. |
139 |
self.assertRaises(errors.NoSuchFile, other.kind, 'b') |
140 |
self.assertRaises(errors.NoSuchFile, other.kind, 'c') |
|
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
141 |
self.assertEqual('file', other.kind('a')) |