bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
2255.7.83
by John Arbash Meinel
 Update some obvious copyright headers to include 2007.  | 
1  | 
# Copyright (C) 2006, 2007 Canonical Ltd
 | 
| 
1551.9.21
by Aaron Bentley
 Fix copyright statements  | 
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
 | 
|
15  | 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|
16  | 
||
| 
2255.11.5
by Martin Pool
 Tree.id2path should raise NoSuchId, not return None.  | 
17  | 
from bzrlib import (  | 
18  | 
errors,  | 
|
| 
2255.2.180
by Martin Pool
 merge dirstate  | 
19  | 
tests,  | 
| 
2748.2.2
by Lukáš Lalinsky
 Add TestConflicts to tests.tree_implementations.test_tree. Update NEWS.  | 
20  | 
conflicts,  | 
| 
2255.11.5
by Martin Pool
 Tree.id2path should raise NoSuchId, not return None.  | 
21  | 
    )
 | 
| 
2338.4.4
by Marien Zwart
 Increase test coverage.  | 
22  | 
from bzrlib.tests import TestSkipped  | 
| 
1551.9.16
by Aaron Bentley
 Implement Tree.annotate_iter for RevisionTree and WorkingTree  | 
23  | 
from bzrlib.tests.tree_implementations import TestCaseWithTree  | 
24  | 
||
25  | 
class TestAnnotate(TestCaseWithTree):  | 
|
| 
2255.2.69
by John Arbash Meinel
 Implement annotate_iter, get_revision_id, and walkdirs so that all tree_implementations now pass  | 
26  | 
|
| 
1551.9.16
by Aaron Bentley
 Implement Tree.annotate_iter for RevisionTree and WorkingTree  | 
27  | 
def test_annotate(self):  | 
28  | 
work_tree = self.make_branch_and_tree('wt')  | 
|
29  | 
tree = self.get_tree_no_parents_abc_content(work_tree)  | 
|
30  | 
tree_revision = getattr(tree, 'get_revision_id', lambda: 'current:')()  | 
|
| 
2255.2.69
by John Arbash Meinel
 Implement annotate_iter, get_revision_id, and walkdirs so that all tree_implementations now pass  | 
31  | 
tree.lock_read()  | 
| 
1551.15.48
by Aaron Bentley
 Add tests for annotate and plan_merge  | 
32  | 
self.addCleanup(tree.unlock)  | 
33  | 
for revision, line in tree.annotate_iter('a-id'):  | 
|
34  | 
self.assertEqual('contents of a\n', line)  | 
|
35  | 
self.assertEqual(tree_revision, revision)  | 
|
36  | 
tree_revision = getattr(tree, 'get_revision_id', lambda: 'random:')()  | 
|
37  | 
for revision, line in tree.annotate_iter('a-id', 'random:'):  | 
|
38  | 
self.assertEqual('contents of a\n', line)  | 
|
39  | 
self.assertEqual(tree_revision, revision)  | 
|
40  | 
||
41  | 
||
| 
1551.15.52
by Aaron Bentley
 Tweak from review comments  | 
42  | 
class TestPlanFileMerge(TestCaseWithTree):  | 
| 
1551.15.48
by Aaron Bentley
 Add tests for annotate and plan_merge  | 
43  | 
|
| 
1551.15.52
by Aaron Bentley
 Tweak from review comments  | 
44  | 
def test_plan_file_merge(self):  | 
| 
1551.15.48
by Aaron Bentley
 Add tests for annotate and plan_merge  | 
45  | 
work_a = self.make_branch_and_tree('wta')  | 
46  | 
self.build_tree_contents([('wta/file', 'a\nb\nc\nd\n')])  | 
|
47  | 
work_a.add('file', 'file-id')  | 
|
48  | 
work_a.commit('base version')  | 
|
49  | 
work_b = work_a.bzrdir.sprout('wtb').open_workingtree()  | 
|
50  | 
self.build_tree_contents([('wta/file', 'b\nc\nd\ne\n')])  | 
|
51  | 
tree_a = self.workingtree_to_test_tree(work_a)  | 
|
52  | 
tree_a.lock_read()  | 
|
53  | 
self.addCleanup(tree_a.unlock)  | 
|
54  | 
self.build_tree_contents([('wtb/file', 'a\nc\nd\nf\n')])  | 
|
55  | 
tree_b = self.workingtree_to_test_tree(work_b)  | 
|
56  | 
tree_b.lock_read()  | 
|
57  | 
self.addCleanup(tree_b.unlock)  | 
|
58  | 
self.assertEqual([  | 
|
59  | 
('killed-b', 'b\n'),  | 
|
60  | 
('killed-a', 'a\n'),  | 
|
61  | 
('unchanged', 'c\n'),  | 
|
62  | 
('unchanged', 'd\n'),  | 
|
63  | 
('new-a', 'e\n'),  | 
|
64  | 
('new-b', 'f\n'),  | 
|
| 
1551.15.52
by Aaron Bentley
 Tweak from review comments  | 
65  | 
], list(tree_a.plan_file_merge('file-id', tree_b)))  | 
| 
2100.3.20
by Aaron Bentley
 Implement tree comparison for tree references  | 
66  | 
|
67  | 
||
68  | 
class TestReference(TestCaseWithTree):  | 
|
69  | 
||
70  | 
def skip_if_no_reference(self, tree):  | 
|
71  | 
if not getattr(tree, 'supports_tree_reference', lambda: False)():  | 
|
72  | 
raise tests.TestSkipped('Tree references not supported')  | 
|
73  | 
||
| 
2100.3.27
by Aaron Bentley
 Enable nested commits  | 
74  | 
def create_nested(self):  | 
| 
2100.3.20
by Aaron Bentley
 Implement tree comparison for tree references  | 
75  | 
work_tree = self.make_branch_and_tree('wt')  | 
| 
2255.2.158
by Martin Pool
 Most of the integration of dirstate and subtree  | 
76  | 
work_tree.lock_write()  | 
77  | 
try:  | 
|
78  | 
self.skip_if_no_reference(work_tree)  | 
|
79  | 
subtree = self.make_branch_and_tree('wt/subtree')  | 
|
80  | 
subtree.set_root_id('sub-root')  | 
|
81  | 
subtree.commit('foo', rev_id='sub-1')  | 
|
82  | 
work_tree.add_reference(subtree)  | 
|
83  | 
finally:  | 
|
84  | 
work_tree.unlock()  | 
|
| 
2100.3.20
by Aaron Bentley
 Implement tree comparison for tree references  | 
85  | 
tree = self._convert_tree(work_tree)  | 
86  | 
self.skip_if_no_reference(tree)  | 
|
| 
2100.3.27
by Aaron Bentley
 Enable nested commits  | 
87  | 
return tree  | 
88  | 
||
89  | 
def test_get_reference_revision(self):  | 
|
90  | 
tree = self.create_nested()  | 
|
| 
2100.3.20
by Aaron Bentley
 Implement tree comparison for tree references  | 
91  | 
path = tree.id2path('sub-root')  | 
| 
2255.2.226
by Robert Collins
 Get merge_nested finally working: change nested tree iterators to take file_ids, and ensure the right branch is connected to in the merge logic. May not be suitable for shared repositories yet.  | 
92  | 
self.assertEqual('sub-1', tree.get_reference_revision('sub-root', path))  | 
| 
2100.3.27
by Aaron Bentley
 Enable nested commits  | 
93  | 
|
| 
2255.2.226
by Robert Collins
 Get merge_nested finally working: change nested tree iterators to take file_ids, and ensure the right branch is connected to in the merge logic. May not be suitable for shared repositories yet.  | 
94  | 
def test_iter_references(self):  | 
| 
2100.3.27
by Aaron Bentley
 Enable nested commits  | 
95  | 
tree = self.create_nested()  | 
| 
2255.2.158
by Martin Pool
 Most of the integration of dirstate and subtree  | 
96  | 
tree.lock_read()  | 
| 
2255.2.226
by Robert Collins
 Get merge_nested finally working: change nested tree iterators to take file_ids, and ensure the right branch is connected to in the merge logic. May not be suitable for shared repositories yet.  | 
97  | 
self.addCleanup(tree.unlock)  | 
98  | 
entry = tree.inventory['sub-root']  | 
|
99  | 
self.assertEqual([(tree.abspath('subtree'), 'sub-root')],  | 
|
100  | 
list(tree.iter_references()))  | 
|
| 
2255.2.166
by Martin Pool
 (broken) Add Tree.get_root_id() & test  | 
101  | 
|
102  | 
def test_get_root_id(self):  | 
|
103  | 
        # trees should return some kind of root id; it can be none
 | 
|
104  | 
tree = self.make_branch_and_tree('tree')  | 
|
105  | 
root_id = tree.get_root_id()  | 
|
106  | 
if root_id is not None:  | 
|
107  | 
self.assertIsInstance(root_id, str)  | 
|
| 
2255.2.180
by Martin Pool
 merge dirstate  | 
108  | 
|
109  | 
||
| 
2255.11.5
by Martin Pool
 Tree.id2path should raise NoSuchId, not return None.  | 
110  | 
class TestFileIds(TestCaseWithTree):  | 
111  | 
||
112  | 
def test_id2path(self):  | 
|
113  | 
        # translate from file-id back to path
 | 
|
114  | 
work_tree = self.make_branch_and_tree('wt')  | 
|
115  | 
tree = self.get_tree_no_parents_abc_content(work_tree)  | 
|
116  | 
tree.lock_read()  | 
|
117  | 
try:  | 
|
118  | 
self.assertEqual(u'a', tree.id2path('a-id'))  | 
|
119  | 
            # other ids give an error- don't return None for this case
 | 
|
120  | 
self.assertRaises(errors.NoSuchId, tree.id2path, 'a')  | 
|
121  | 
finally:  | 
|
122  | 
tree.unlock()  | 
|
| 
2708.1.1
by Aaron Bentley
 Implement Tree.extract_files  | 
123  | 
|
124  | 
||
| 
2743.3.5
by Ian Clatworthy
 Incorporate feedback from abentley  | 
125  | 
class TestFileContent(TestCaseWithTree):  | 
126  | 
||
127  | 
def test_get_file(self):  | 
|
128  | 
work_tree = self.make_branch_and_tree('wt')  | 
|
129  | 
tree = self.get_tree_no_parents_abc_content_2(work_tree)  | 
|
130  | 
tree.lock_read()  | 
|
131  | 
try:  | 
|
132  | 
            # Test lookup without path works
 | 
|
133  | 
lines = tree.get_file('a-id').readlines()  | 
|
134  | 
self.assertEqual(['foobar\n'], lines)  | 
|
135  | 
            # Test lookup with path works
 | 
|
136  | 
lines = tree.get_file('a-id', path='a').readlines()  | 
|
137  | 
self.assertEqual(['foobar\n'], lines)  | 
|
138  | 
finally:  | 
|
139  | 
tree.unlock()  | 
|
140  | 
||
141  | 
||
| 
2708.1.1
by Aaron Bentley
 Implement Tree.extract_files  | 
142  | 
class TestExtractFilesBytes(TestCaseWithTree):  | 
143  | 
||
| 
2708.1.7
by Aaron Bentley
 Rename extract_files_bytes to iter_files_bytes  | 
144  | 
def test_iter_files_bytes(self):  | 
| 
2708.1.1
by Aaron Bentley
 Implement Tree.extract_files  | 
145  | 
work_tree = self.make_branch_and_tree('wt')  | 
146  | 
self.build_tree_contents([('wt/foo', 'foo'),  | 
|
147  | 
('wt/bar', 'bar'),  | 
|
148  | 
('wt/baz', 'baz')])  | 
|
149  | 
work_tree.add(['foo', 'bar', 'baz'], ['foo-id', 'bar-id', 'baz-id'])  | 
|
150  | 
tree = self._convert_tree(work_tree)  | 
|
151  | 
tree.lock_read()  | 
|
152  | 
self.addCleanup(tree.unlock)  | 
|
| 
2708.1.6
by Aaron Bentley
 Turn extract_files_bytes into an iterator  | 
153  | 
extracted = dict((i, ''.join(b)) for i, b in  | 
| 
2708.1.7
by Aaron Bentley
 Rename extract_files_bytes to iter_files_bytes  | 
154  | 
tree.iter_files_bytes([('foo-id', 'id1'),  | 
155  | 
('bar-id', 'id2'),  | 
|
156  | 
('baz-id', 'id3')]))  | 
|
| 
2708.1.6
by Aaron Bentley
 Turn extract_files_bytes into an iterator  | 
157  | 
self.assertEqual('foo', extracted['id1'])  | 
158  | 
self.assertEqual('bar', extracted['id2'])  | 
|
159  | 
self.assertEqual('baz', extracted['id3'])  | 
|
| 
2708.1.11
by Aaron Bentley
 Test and tweak error handling  | 
160  | 
self.assertRaises(errors.NoSuchId, lambda: list(  | 
161  | 
tree.iter_files_bytes(  | 
|
162  | 
[('qux-id', 'file1-notpresent')])))  | 
|
| 
2748.2.2
by Lukáš Lalinsky
 Add TestConflicts to tests.tree_implementations.test_tree. Update NEWS.  | 
163  | 
|
164  | 
||
165  | 
class TestConflicts(TestCaseWithTree):  | 
|
166  | 
||
167  | 
def test_conflicts(self):  | 
|
168  | 
"""Tree.conflicts() should return a ConflictList instance."""  | 
|
169  | 
work_tree = self.make_branch_and_tree('wt')  | 
|
170  | 
tree = self._convert_tree(work_tree)  | 
|
| 
2761.1.3
by Aaron Bentley
 Update test to use assertIsInstance  | 
171  | 
self.assertIsInstance(tree.conflicts(), conflicts.ConflictList)  |