bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5557.1.15
by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt |
1 |
# Copyright (C) 2006-2009, 2011 Canonical Ltd
|
|
2100.3.8
by Aaron Bentley
Add add_reference |
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
|
|
2100.3.8
by Aaron Bentley
Add add_reference |
16 |
|
17 |
import os |
|
18 |
||
|
5582.10.4
by Jelmer Vernooij
Fix a bunch of tests. |
19 |
from bzrlib import errors, tests, workingtree |
|
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
20 |
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree |
|
2100.3.8
by Aaron Bentley
Add add_reference |
21 |
|
|
2255.6.3
by Aaron Bentley
tweak tests |
22 |
|
|
2100.3.8
by Aaron Bentley
Add add_reference |
23 |
class TestBasisInventory(TestCaseWithWorkingTree): |
24 |
||
25 |
def make_trees(self): |
|
26 |
tree = self.make_branch_and_tree('tree') |
|
27 |
tree.set_root_id('root-id') |
|
28 |
self.build_tree(['tree/file1']) |
|
29 |
tree.add('file1', 'file1-id') |
|
30 |
sub_tree = self.make_branch_and_tree('tree/sub-tree') |
|
31 |
sub_tree.set_root_id('sub-tree-root-id') |
|
|
2100.3.19
by Aaron Bentley
Ensure commit preserves reference revision |
32 |
sub_tree.commit('commit', rev_id='sub_1') |
|
2100.3.8
by Aaron Bentley
Add add_reference |
33 |
return tree, sub_tree |
34 |
||
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
35 |
def _references_unsupported(self, tree): |
|
5582.10.4
by Jelmer Vernooij
Fix a bunch of tests. |
36 |
if not tree.supports_tree_reference(): |
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
37 |
raise tests.TestSkipped('Tree format does not support references') |
38 |
else: |
|
39 |
self.fail('%r does not support references but should' |
|
40 |
% (tree, )) |
|
41 |
||
|
2100.3.27
by Aaron Bentley
Enable nested commits |
42 |
def make_nested_trees(self): |
43 |
tree, sub_tree = self.make_trees() |
|
44 |
try: |
|
45 |
tree.add_reference(sub_tree) |
|
46 |
except errors.UnsupportedOperation: |
|
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
47 |
self._references_unsupported(tree) |
|
2100.3.27
by Aaron Bentley
Enable nested commits |
48 |
return tree, sub_tree |
49 |
||
|
2100.3.8
by Aaron Bentley
Add add_reference |
50 |
def test_add_reference(self): |
|
2100.3.27
by Aaron Bentley
Enable nested commits |
51 |
self.make_nested_trees() |
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
52 |
tree = workingtree.WorkingTree.open('tree') |
|
2255.6.9
by Aaron Bentley
Fix test locking for dirstate |
53 |
tree.lock_write() |
54 |
try: |
|
55 |
self.assertEqual(tree.path2id('sub-tree'), 'sub-tree-root-id') |
|
|
5807.1.2
by Jelmer Vernooij
Skip some inventory-specific tests for non-inventory working trees. |
56 |
self.assertEqual(tree.kind('sub-tree-root-id'), 'tree-reference') |
|
2255.6.9
by Aaron Bentley
Fix test locking for dirstate |
57 |
tree.commit('commit reference') |
58 |
basis = tree.basis_tree() |
|
59 |
basis.lock_read() |
|
60 |
try: |
|
|
2255.2.228
by Robert Collins
Make all test_add_reference tests pass again. |
61 |
sub_tree = tree.get_nested_tree('sub-tree-root-id') |
|
2255.6.9
by Aaron Bentley
Fix test locking for dirstate |
62 |
self.assertEqual(sub_tree.last_revision(), |
|
2255.2.228
by Robert Collins
Make all test_add_reference tests pass again. |
63 |
tree.get_reference_revision('sub-tree-root-id')) |
|
2255.6.9
by Aaron Bentley
Fix test locking for dirstate |
64 |
finally: |
65 |
basis.unlock() |
|
66 |
finally: |
|
67 |
tree.unlock() |
|
|
2100.3.8
by Aaron Bentley
Add add_reference |
68 |
|
69 |
def test_add_reference_same_root(self): |
|
70 |
tree = self.make_branch_and_tree('tree') |
|
71 |
self.build_tree(['tree/file1']) |
|
72 |
tree.add('file1', 'file1-id') |
|
73 |
tree.set_root_id('root-id') |
|
74 |
sub_tree = self.make_branch_and_tree('tree/sub-tree') |
|
75 |
sub_tree.set_root_id('root-id') |
|
76 |
try: |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
77 |
self.assertRaises(errors.BadReferenceTarget, tree.add_reference, |
|
2100.3.8
by Aaron Bentley
Add add_reference |
78 |
sub_tree) |
79 |
except errors.UnsupportedOperation: |
|
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
80 |
self._references_unsupported(tree) |
|
2100.3.8
by Aaron Bentley
Add add_reference |
81 |
|
82 |
def test_root_present(self): |
|
83 |
"""Subtree root is present, though not the working tree root""" |
|
84 |
tree, sub_tree = self.make_trees() |
|
85 |
sub_tree.set_root_id('file1-id') |
|
86 |
try: |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
87 |
self.assertRaises(errors.BadReferenceTarget, tree.add_reference, |
|
2100.3.8
by Aaron Bentley
Add add_reference |
88 |
sub_tree) |
89 |
except errors.UnsupportedOperation: |
|
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
90 |
self._references_unsupported(tree) |
|
2100.3.8
by Aaron Bentley
Add add_reference |
91 |
|
92 |
def test_add_non_subtree(self): |
|
93 |
tree, sub_tree = self.make_trees() |
|
94 |
os.rename('tree/sub-tree', 'sibling') |
|
95 |
sibling = workingtree.WorkingTree.open('sibling') |
|
96 |
try: |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
97 |
self.assertRaises(errors.BadReferenceTarget, tree.add_reference, |
|
2100.3.8
by Aaron Bentley
Add add_reference |
98 |
sibling) |
99 |
except errors.UnsupportedOperation: |
|
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
100 |
self._references_unsupported(tree) |
|
2100.3.8
by Aaron Bentley
Add add_reference |
101 |
|
|
2100.3.27
by Aaron Bentley
Enable nested commits |
102 |
def test_get_nested_tree(self): |
103 |
tree, sub_tree = self.make_nested_trees() |
|
|
2255.6.9
by Aaron Bentley
Fix test locking for dirstate |
104 |
tree.lock_read() |
105 |
try: |
|
|
2255.2.228
by Robert Collins
Make all test_add_reference tests pass again. |
106 |
sub_tree2 = tree.get_nested_tree('sub-tree-root-id') |
|
2255.6.9
by Aaron Bentley
Fix test locking for dirstate |
107 |
self.assertEqual(sub_tree.basedir, sub_tree2.basedir) |
|
2255.2.228
by Robert Collins
Make all test_add_reference tests pass again. |
108 |
sub_tree2 = tree.get_nested_tree('sub-tree-root-id', 'sub-tree') |
|
2255.6.9
by Aaron Bentley
Fix test locking for dirstate |
109 |
finally: |
110 |
tree.unlock() |