bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2005-2012, 2016 Canonical Ltd
|
|
1399.1.12
by Robert Collins
add new test script |
2 |
# Authors: Robert Collins <robert.collins@canonical.com>
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1399.1.12
by Robert Collins
add new test script |
17 |
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
18 |
from .. import ( |
|
2255.2.121
by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file |
19 |
conflicts, |
20 |
errors, |
|
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
21 |
transport, |
|
2255.2.121
by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file |
22 |
workingtree, |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
23 |
)
|
24 |
from ..bzr import ( |
|
25 |
bzrdir, |
|
26 |
workingtree as bzrworkingtree, |
|
|
5816.5.1
by Jelmer Vernooij
Move WorkingTree3 to bzrlib.workingtree_3. |
27 |
workingtree_3, |
|
5816.5.7
by Jelmer Vernooij
Fix more imports. |
28 |
workingtree_4, |
|
2255.2.121
by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file |
29 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
30 |
from ..lock import write_locked |
31 |
from ..lockdir import LockDir |
|
32 |
from . import TestCase, TestCaseWithTransport, TestSkipped |
|
|
6846.6.1
by Jelmer Vernooij
Move Tree{Link,File,Directory,Entry} to breezy.tree. |
33 |
from ..tree import ( |
|
1997.1.1
by Robert Collins
Add WorkingTree.lock_tree_write. |
34 |
TreeEntry, |
35 |
TreeDirectory, |
|
36 |
TreeFile, |
|
37 |
TreeLink, |
|
38 |
)
|
|
|
1399.1.12
by Robert Collins
add new test script |
39 |
|
|
2255.2.121
by John Arbash Meinel
split out the WorkingTreeFormat4 tests into a separate test file |
40 |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
41 |
class TestTreeDirectory(TestCaseWithTransport): |
|
1399.1.12
by Robert Collins
add new test script |
42 |
|
43 |
def test_kind_character(self): |
|
44 |
self.assertEqual(TreeDirectory().kind_character(), '/') |
|
45 |
||
46 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
47 |
class TestTreeEntry(TestCaseWithTransport): |
|
1399.1.12
by Robert Collins
add new test script |
48 |
|
49 |
def test_kind_character(self): |
|
50 |
self.assertEqual(TreeEntry().kind_character(), '???') |
|
51 |
||
52 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
53 |
class TestTreeFile(TestCaseWithTransport): |
|
1399.1.12
by Robert Collins
add new test script |
54 |
|
55 |
def test_kind_character(self): |
|
56 |
self.assertEqual(TreeFile().kind_character(), '') |
|
57 |
||
58 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
59 |
class TestTreeLink(TestCaseWithTransport): |
|
1399.1.12
by Robert Collins
add new test script |
60 |
|
61 |
def test_kind_character(self): |
|
62 |
self.assertEqual(TreeLink().kind_character(), '') |
|
63 |
||
64 |
||
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
65 |
class TestDefaultFormat(TestCaseWithTransport): |
66 |
||
67 |
def test_get_set_default_format(self): |
|
|
5662.3.3
by Jelmer Vernooij
add tests |
68 |
old_format = workingtree.format_registry.get_default() |
|
5816.5.2
by Jelmer Vernooij
Fix comment - default wt format is 6. |
69 |
# default is 6
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
70 |
self.assertTrue(isinstance( |
71 |
old_format, workingtree_4.WorkingTreeFormat6)) |
|
|
5662.3.3
by Jelmer Vernooij
add tests |
72 |
workingtree.format_registry.set_default(SampleTreeFormat()) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
73 |
try: |
74 |
# the default branch format is used by the meta dir format
|
|
75 |
# which is not the default bzrdir format at this point
|
|
76 |
dir = bzrdir.BzrDirMetaFormat1().initialize('.') |
|
77 |
dir.create_repository() |
|
78 |
dir.create_branch() |
|
79 |
result = dir.create_workingtree() |
|
80 |
self.assertEqual(result, 'A tree') |
|
81 |
finally: |
|
|
5662.3.3
by Jelmer Vernooij
add tests |
82 |
workingtree.format_registry.set_default(old_format) |
83 |
self.assertEqual(old_format, workingtree.format_registry.get_default()) |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
84 |
|
|
6349.2.4
by Jelmer Vernooij
Add test for WorkingTreeFormat.from_string. |
85 |
def test_from_string(self): |
86 |
self.assertIsInstance( |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
87 |
SampleTreeFormat.from_string(b"Sample tree format."), |
|
6349.2.4
by Jelmer Vernooij
Add test for WorkingTreeFormat.from_string. |
88 |
SampleTreeFormat) |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
89 |
self.assertRaises( |
90 |
AssertionError, SampleTreeFormat.from_string, |
|
91 |
b"Different format string.") |
|
|
6349.2.4
by Jelmer Vernooij
Add test for WorkingTreeFormat.from_string. |
92 |
|
|
5816.2.1
by Jelmer Vernooij
Allow lazily setting default for working trees. |
93 |
def test_get_set_default_format_by_key(self): |
94 |
old_format = workingtree.format_registry.get_default() |
|
|
5816.5.7
by Jelmer Vernooij
Fix more imports. |
95 |
# default is 6
|
|
5816.2.1
by Jelmer Vernooij
Allow lazily setting default for working trees. |
96 |
format = SampleTreeFormat() |
97 |
workingtree.format_registry.register(format) |
|
98 |
self.addCleanup(workingtree.format_registry.remove, format) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
99 |
self.assertTrue(isinstance( |
100 |
old_format, workingtree_4.WorkingTreeFormat6)) |
|
|
5816.2.1
by Jelmer Vernooij
Allow lazily setting default for working trees. |
101 |
workingtree.format_registry.set_default_key(format.get_format_string()) |
102 |
try: |
|
103 |
# the default branch format is used by the meta dir format
|
|
104 |
# which is not the default bzrdir format at this point
|
|
105 |
dir = bzrdir.BzrDirMetaFormat1().initialize('.') |
|
106 |
dir.create_repository() |
|
107 |
dir.create_branch() |
|
108 |
result = dir.create_workingtree() |
|
109 |
self.assertEqual(result, 'A tree') |
|
110 |
finally: |
|
111 |
workingtree.format_registry.set_default_key( |
|
112 |
old_format.get_format_string()) |
|
113 |
self.assertEqual(old_format, workingtree.format_registry.get_default()) |
|
114 |
||
|
3753.1.1
by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing. |
115 |
def test_open(self): |
116 |
tree = self.make_branch_and_tree('.') |
|
|
3753.1.2
by John Arbash Meinel
Switch to using the class attribute, rather than the instance |
117 |
open_direct = workingtree.WorkingTree.open('.') |
|
3753.1.1
by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing. |
118 |
self.assertEqual(tree.basedir, open_direct.basedir) |
|
3753.1.2
by John Arbash Meinel
Switch to using the class attribute, rather than the instance |
119 |
open_no_args = workingtree.WorkingTree.open() |
|
3753.1.1
by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing. |
120 |
self.assertEqual(tree.basedir, open_no_args.basedir) |
121 |
||
122 |
def test_open_containing(self): |
|
123 |
tree = self.make_branch_and_tree('.') |
|
|
3753.1.2
by John Arbash Meinel
Switch to using the class attribute, rather than the instance |
124 |
open_direct, relpath = workingtree.WorkingTree.open_containing('.') |
|
3753.1.1
by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing. |
125 |
self.assertEqual(tree.basedir, open_direct.basedir) |
126 |
self.assertEqual('', relpath) |
|
|
3753.1.2
by John Arbash Meinel
Switch to using the class attribute, rather than the instance |
127 |
open_no_args, relpath = workingtree.WorkingTree.open_containing() |
|
3753.1.1
by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing. |
128 |
self.assertEqual(tree.basedir, open_no_args.basedir) |
129 |
self.assertEqual('', relpath) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
130 |
open_subdir, relpath = workingtree.WorkingTree.open_containing( |
131 |
'subdir') |
|
|
3753.1.1
by John Arbash Meinel
Add some simple direct tests for WT.open and WT.open_containing. |
132 |
self.assertEqual(tree.basedir, open_subdir.basedir) |
133 |
self.assertEqual('subdir', relpath) |
|
134 |
||
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
135 |
|
|
6653.3.1
by Jelmer Vernooij
Move bzr-specific code to breezy.bzrworkingtree. |
136 |
class SampleTreeFormat(bzrworkingtree.WorkingTreeFormatMetaDir): |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
137 |
"""A sample format |
138 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
139 |
this format is initializable, unsupported to aid in testing the
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
140 |
open and open_downlevel routines.
|
141 |
"""
|
|
142 |
||
|
6349.2.4
by Jelmer Vernooij
Add test for WorkingTreeFormat.from_string. |
143 |
@classmethod
|
144 |
def get_format_string(cls): |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
145 |
"""See WorkingTreeFormat.get_format_string().""" |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
146 |
return b"Sample tree format." |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
147 |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
148 |
def initialize(self, a_controldir, revision_id=None, from_branch=None, |
|
3136.1.5
by Aaron Bentley
Fix sample workingtree format |
149 |
accelerator_tree=None, hardlink=False): |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
150 |
"""Sample branches cannot be created.""" |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
151 |
t = a_controldir.get_workingtree_transport(self) |
|
1955.3.13
by John Arbash Meinel
Run the full test suite, and fix up any deprecation warnings. |
152 |
t.put_bytes('format', self.get_format_string()) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
153 |
return 'A tree' |
154 |
||
155 |
def is_supported(self): |
|
156 |
return False |
|
157 |
||
158 |
def open(self, transport, _found=False): |
|
159 |
return "opened tree." |
|
160 |
||
161 |
||
|
5642.2.4
by Jelmer Vernooij
add tests. |
162 |
class SampleExtraTreeFormat(workingtree.WorkingTreeFormat): |
163 |
"""A sample format that does not support use in a metadir. |
|
164 |
||
165 |
"""
|
|
166 |
||
167 |
def get_format_string(self): |
|
168 |
# Not usable in a metadir, so no format string
|
|
169 |
return None |
|
170 |
||
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
171 |
def initialize(self, a_controldir, revision_id=None, from_branch=None, |
|
5642.2.4
by Jelmer Vernooij
add tests. |
172 |
accelerator_tree=None, hardlink=False): |
173 |
raise NotImplementedError(self.initialize) |
|
174 |
||
175 |
def is_supported(self): |
|
176 |
return False |
|
177 |
||
178 |
def open(self, transport, _found=False): |
|
179 |
raise NotImplementedError(self.open) |
|
180 |
||
181 |
||
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
182 |
class TestWorkingTreeFormat(TestCaseWithTransport): |
183 |
"""Tests for the WorkingTreeFormat facility.""" |
|
184 |
||
|
5816.3.3
by Jelmer Vernooij
Add tariff test to make sure working tree isn't opened by 'bzr serve' |
185 |
def test_find_format_string(self): |
186 |
# is the right format object found for a working tree?
|
|
187 |
branch = self.make_branch('branch') |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
188 |
self.assertRaises( |
189 |
errors.NoWorkingTree, |
|
190 |
bzrworkingtree.WorkingTreeFormatMetaDir.find_format_string, |
|
191 |
branch.controldir) |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
192 |
transport = branch.controldir.get_workingtree_transport(None) |
|
5816.3.3
by Jelmer Vernooij
Add tariff test to make sure working tree isn't opened by 'bzr serve' |
193 |
transport.mkdir('.') |
|
7045.4.23
by Jelmer Vernooij
Fix some help tests. |
194 |
transport.put_bytes("format", b"some format name") |
|
5816.3.3
by Jelmer Vernooij
Add tariff test to make sure working tree isn't opened by 'bzr serve' |
195 |
# The format does not have to be known by Bazaar,
|
196 |
# find_format_string just retrieves the name
|
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
197 |
self.assertEqual( |
198 |
b"some format name", |
|
199 |
bzrworkingtree.WorkingTreeFormatMetaDir.find_format_string( |
|
200 |
branch.controldir)) |
|
|
5816.3.3
by Jelmer Vernooij
Add tariff test to make sure working tree isn't opened by 'bzr serve' |
201 |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
202 |
def test_find_format(self): |
203 |
# is the right format object found for a working tree?
|
|
204 |
# create a branch with a few known format objects.
|
|
205 |
self.build_tree(["foo/", "bar/"]) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
206 |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
207 |
def check_format(format, url): |
|
6746.2.1
by Jelmer Vernooij
Rename matchingbzrdir to matchingcontroldir. |
208 |
dir = format._matchingcontroldir.initialize(url) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
209 |
dir.create_repository() |
210 |
dir.create_branch() |
|
211 |
format.initialize(dir) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
212 |
found_format = bzrworkingtree.WorkingTreeFormatMetaDir.find_format( |
213 |
dir) |
|
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
214 |
self.assertIsInstance(found_format, format.__class__) |
|
5816.5.1
by Jelmer Vernooij
Move WorkingTree3 to bzrlib.workingtree_3. |
215 |
check_format(workingtree_3.WorkingTreeFormat3(), "bar") |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
216 |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
217 |
def test_find_format_no_tree(self): |
218 |
dir = bzrdir.BzrDirMetaFormat1().initialize('.') |
|
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
219 |
self.assertRaises(errors.NoWorkingTree, |
|
6653.5.1
by Jelmer Vernooij
Fix some more tests. |
220 |
bzrworkingtree.WorkingTreeFormatMetaDir.find_format, |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
221 |
dir) |
222 |
||
223 |
def test_find_format_unknown_format(self): |
|
224 |
dir = bzrdir.BzrDirMetaFormat1().initialize('.') |
|
225 |
dir.create_repository() |
|
226 |
dir.create_branch() |
|
227 |
SampleTreeFormat().initialize(dir) |
|
228 |
self.assertRaises(errors.UnknownFormatError, |
|
|
6653.5.1
by Jelmer Vernooij
Fix some more tests. |
229 |
bzrworkingtree.WorkingTreeFormatMetaDir.find_format, |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
230 |
dir) |
231 |
||
|
6213.1.36
by Jelmer Vernooij
Add news entry, test for working tree features. |
232 |
def test_find_format_with_features(self): |
233 |
tree = self.make_branch_and_tree('.', format='2a') |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
234 |
tree.update_feature_flags({b"name": b"necessity"}) |
|
6653.5.1
by Jelmer Vernooij
Fix some more tests. |
235 |
found_format = bzrworkingtree.WorkingTreeFormatMetaDir.find_format( |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
236 |
tree.controldir) |
|
6213.1.36
by Jelmer Vernooij
Add news entry, test for working tree features. |
237 |
self.assertIsInstance(found_format, workingtree.WorkingTreeFormat) |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
238 |
self.assertEqual(found_format.features.get(b"name"), b"necessity") |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
239 |
self.assertRaises( |
240 |
bzrdir.MissingFeature, found_format.check_support_status, True) |
|
241 |
self.addCleanup( |
|
242 |
bzrworkingtree.WorkingTreeFormatMetaDir.unregister_feature, |
|
243 |
b"name") |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
244 |
bzrworkingtree.WorkingTreeFormatMetaDir.register_feature(b"name") |
|
6213.1.36
by Jelmer Vernooij
Add news entry, test for working tree features. |
245 |
found_format.check_support_status(True) |
246 |
||
|
5662.3.3
by Jelmer Vernooij
add tests |
247 |
|
|
5786.1.5
by John Arbash Meinel
Move the logic about InventoryDirectory => TreeReference into iter_entries |
248 |
class TestWorkingTreeIterEntriesByDir_wSubtrees(TestCaseWithTransport): |
249 |
||
250 |
def make_simple_tree(self): |
|
251 |
tree = self.make_branch_and_tree('tree', format='development-subtree') |
|
252 |
self.build_tree(['tree/a/', 'tree/a/b/', 'tree/a/b/c']) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
253 |
tree.set_root_id(b'root-id') |
254 |
tree.add(['a', 'a/b', 'a/b/c'], [b'a-id', b'b-id', b'c-id']) |
|
|
5786.1.5
by John Arbash Meinel
Move the logic about InventoryDirectory => TreeReference into iter_entries |
255 |
tree.commit('initial') |
256 |
return tree |
|
257 |
||
258 |
def test_just_directory(self): |
|
259 |
tree = self.make_simple_tree() |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
260 |
self.assertEqual([('directory', b'root-id'), |
261 |
('directory', b'a-id'), |
|
262 |
('directory', b'b-id'), |
|
263 |
('file', b'c-id')], |
|
|
5786.1.5
by John Arbash Meinel
Move the logic about InventoryDirectory => TreeReference into iter_entries |
264 |
[(ie.kind, ie.file_id) |
265 |
for path, ie in tree.iter_entries_by_dir()]) |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
266 |
self.make_branch_and_tree('tree/a/b') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
267 |
self.assertEqual([('tree-reference', b'b-id')], |
|
5786.1.5
by John Arbash Meinel
Move the logic about InventoryDirectory => TreeReference into iter_entries |
268 |
[(ie.kind, ie.file_id) |
|
6885.6.1
by Jelmer Vernooij
Support specific_files argument to Tree.iter_entries_by_dir. |
269 |
for path, ie in tree.iter_entries_by_dir( |
270 |
specific_files=['a/b'])]) |
|
|
5786.1.5
by John Arbash Meinel
Move the logic about InventoryDirectory => TreeReference into iter_entries |
271 |
|
272 |
def test_direct_subtree(self): |
|
273 |
tree = self.make_simple_tree() |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
274 |
self.make_branch_and_tree('tree/a/b') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
275 |
self.assertEqual([('directory', b'root-id'), |
276 |
('directory', b'a-id'), |
|
277 |
('tree-reference', b'b-id')], |
|
|
5786.1.5
by John Arbash Meinel
Move the logic about InventoryDirectory => TreeReference into iter_entries |
278 |
[(ie.kind, ie.file_id) |
279 |
for path, ie in tree.iter_entries_by_dir()]) |
|
280 |
||
281 |
def test_indirect_subtree(self): |
|
282 |
tree = self.make_simple_tree() |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
283 |
self.make_branch_and_tree('tree/a') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
284 |
self.assertEqual([('directory', b'root-id'), |
285 |
('tree-reference', b'a-id')], |
|
|
5786.1.5
by John Arbash Meinel
Move the logic about InventoryDirectory => TreeReference into iter_entries |
286 |
[(ie.kind, ie.file_id) |
287 |
for path, ie in tree.iter_entries_by_dir()]) |
|
288 |
||
289 |
||
|
5662.3.3
by Jelmer Vernooij
add tests |
290 |
class TestWorkingTreeFormatRegistry(TestCase): |
291 |
||
292 |
def setUp(self): |
|
293 |
super(TestWorkingTreeFormatRegistry, self).setUp() |
|
294 |
self.registry = workingtree.WorkingTreeFormatRegistry() |
|
295 |
||
296 |
def test_register_unregister_format(self): |
|
297 |
format = SampleTreeFormat() |
|
298 |
self.registry.register(format) |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
299 |
self.assertEqual(format, self.registry.get(b"Sample tree format.")) |
|
5662.3.3
by Jelmer Vernooij
add tests |
300 |
self.registry.remove(format) |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
301 |
self.assertRaises(KeyError, self.registry.get, b"Sample tree format.") |
|
5662.3.3
by Jelmer Vernooij
add tests |
302 |
|
303 |
def test_get_all(self): |
|
304 |
format = SampleTreeFormat() |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
305 |
self.assertEqual([], self.registry._get_all()) |
|
5662.3.3
by Jelmer Vernooij
add tests |
306 |
self.registry.register(format) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
307 |
self.assertEqual([format], self.registry._get_all()) |
|
5662.3.3
by Jelmer Vernooij
add tests |
308 |
|
309 |
def test_register_extra(self): |
|
|
5642.2.4
by Jelmer Vernooij
add tests. |
310 |
format = SampleExtraTreeFormat() |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
311 |
self.assertEqual([], self.registry._get_all()) |
|
5662.3.3
by Jelmer Vernooij
add tests |
312 |
self.registry.register_extra(format) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
313 |
self.assertEqual([format], self.registry._get_all()) |
|
5662.3.3
by Jelmer Vernooij
add tests |
314 |
|
315 |
def test_register_extra_lazy(self): |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
316 |
self.assertEqual([], self.registry._get_all()) |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
317 |
self.registry.register_extra_lazy("breezy.tests.test_workingtree", |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
318 |
"SampleExtraTreeFormat") |
|
5662.3.3
by Jelmer Vernooij
add tests |
319 |
formats = self.registry._get_all() |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
320 |
self.assertEqual(1, len(formats)) |
|
5662.3.3
by Jelmer Vernooij
add tests |
321 |
self.assertIsInstance(formats[0], SampleExtraTreeFormat) |
|
1534.4.51
by Robert Collins
Test the disk layout of format3 working trees. |
322 |
|
323 |
||
324 |
class TestWorkingTreeFormat3(TestCaseWithTransport): |
|
325 |
"""Tests specific to WorkingTreeFormat3.""" |
|
326 |
||
327 |
def test_disk_layout(self): |
|
328 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
329 |
control.create_repository() |
|
330 |
control.create_branch() |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
331 |
workingtree_3.WorkingTreeFormat3().initialize(control) |
|
1534.4.51
by Robert Collins
Test the disk layout of format3 working trees. |
332 |
# we want:
|
333 |
# format 'Bazaar-NG Working Tree format 3'
|
|
334 |
# inventory = blank inventory
|
|
335 |
# pending-merges = ''
|
|
336 |
# stat-cache = ??
|
|
337 |
# no inventory.basis yet
|
|
338 |
t = control.get_workingtree_transport(None) |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
339 |
self.assertEqualDiff(b'Bazaar-NG Working Tree format 3', |
|
1534.4.51
by Robert Collins
Test the disk layout of format3 working trees. |
340 |
t.get('format').read()) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
341 |
self.assertEqualDiff(t.get('inventory').read(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
342 |
b'<inventory format="5">\n' |
343 |
b'</inventory>\n', |
|
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
344 |
)
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
345 |
self.assertEqualDiff(b'### bzr hashcache v5\n', |
|
1534.4.51
by Robert Collins
Test the disk layout of format3 working trees. |
346 |
t.get('stat-cache').read()) |
347 |
self.assertFalse(t.has('inventory.basis')) |
|
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
348 |
# no last-revision file means 'None' or 'NULLREVISION'
|
349 |
self.assertFalse(t.has('last-revision')) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
350 |
# TODO RBC 20060210 do a commit, check the inventory.basis is created
|
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
351 |
# correctly and last-revision file becomes present.
|
|
1553.5.74
by Martin Pool
Convert WorkingTree format3 to use LockDirs |
352 |
|
353 |
def test_uses_lockdir(self): |
|
354 |
"""WorkingTreeFormat3 uses its own LockDir: |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
355 |
|
|
1553.5.74
by Martin Pool
Convert WorkingTree format3 to use LockDirs |
356 |
- lock is a directory
|
357 |
- when the WorkingTree is locked, LockDir can see that
|
|
358 |
"""
|
|
359 |
t = self.get_transport() |
|
360 |
url = self.get_url() |
|
361 |
dir = bzrdir.BzrDirMetaFormat1().initialize(url) |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
362 |
dir.create_repository() |
363 |
dir.create_branch() |
|
|
1558.10.1
by Aaron Bentley
Handle lockdirs over NFS properly |
364 |
try: |
|
5816.5.1
by Jelmer Vernooij
Move WorkingTree3 to bzrlib.workingtree_3. |
365 |
tree = workingtree_3.WorkingTreeFormat3().initialize(dir) |
|
1558.10.1
by Aaron Bentley
Handle lockdirs over NFS properly |
366 |
except errors.NotLocalUrl: |
367 |
raise TestSkipped('Not a local URL') |
|
|
1553.5.74
by Martin Pool
Convert WorkingTree format3 to use LockDirs |
368 |
self.assertIsDirectory('.bzr', t) |
369 |
self.assertIsDirectory('.bzr/checkout', t) |
|
370 |
self.assertIsDirectory('.bzr/checkout/lock', t) |
|
371 |
our_lock = LockDir(t, '.bzr/checkout/lock') |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
372 |
self.assertEqual(our_lock.peek(), None) |
|
6969.3.2
by Jelmer Vernooij
Use context managers for locking. |
373 |
with tree.lock_write(): |
374 |
self.assertTrue(our_lock.peek()) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
375 |
self.assertEqual(our_lock.peek(), None) |
|
1534.10.6
by Aaron Bentley
Conflict serialization working for WorkingTree3 |
376 |
|
|
1815.2.2
by Jelmer Vernooij
Move missing_pending_merges test to WorkingTreeFormat3-specific tests. |
377 |
def test_missing_pending_merges(self): |
378 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
379 |
control.create_repository() |
|
380 |
control.create_branch() |
|
|
5816.5.1
by Jelmer Vernooij
Move WorkingTree3 to bzrlib.workingtree_3. |
381 |
tree = workingtree_3.WorkingTreeFormat3().initialize(control) |
|
3407.2.14
by Martin Pool
Remove more cases of getting transport via control_files |
382 |
tree._transport.delete("pending-merges") |
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
383 |
self.assertEqual([], tree.get_parent_ids()) |
|
1815.2.2
by Jelmer Vernooij
Move missing_pending_merges test to WorkingTreeFormat3-specific tests. |
384 |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
385 |
|
|
3017.2.1
by Aaron Bentley
Revert now resolves conflicts recursively (#102739) |
386 |
class TestRevert(TestCaseWithTransport): |
387 |
||
388 |
def test_revert_conflicts_recursive(self): |
|
389 |
this_tree = self.make_branch_and_tree('this-tree') |
|
390 |
self.build_tree_contents([('this-tree/foo/',), |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
391 |
('this-tree/foo/bar', b'bar')]) |
|
3017.2.1
by Aaron Bentley
Revert now resolves conflicts recursively (#102739) |
392 |
this_tree.add(['foo', 'foo/bar']) |
393 |
this_tree.commit('created foo/bar') |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
394 |
other_tree = this_tree.controldir.sprout( |
395 |
'other-tree').open_workingtree() |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
396 |
self.build_tree_contents([('other-tree/foo/bar', b'baz')]) |
|
3017.2.1
by Aaron Bentley
Revert now resolves conflicts recursively (#102739) |
397 |
other_tree.commit('changed bar') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
398 |
self.build_tree_contents([('this-tree/foo/bar', b'qux')]) |
|
3017.2.1
by Aaron Bentley
Revert now resolves conflicts recursively (#102739) |
399 |
this_tree.commit('changed qux') |
400 |
this_tree.merge_from_branch(other_tree.branch) |
|
401 |
self.assertEqual(1, len(this_tree.conflicts())) |
|
402 |
this_tree.revert(['foo']) |
|
403 |
self.assertEqual(0, len(this_tree.conflicts())) |
|
404 |
||
405 |
||
|
2120.7.2
by Aaron Bentley
Move autoresolve functionality to workingtree |
406 |
class TestAutoResolve(TestCaseWithTransport): |
407 |
||
408 |
def test_auto_resolve(self): |
|
409 |
base = self.make_branch_and_tree('base') |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
410 |
self.build_tree_contents([('base/hello', b'Hello')]) |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
411 |
base.add('hello', b'hello_id') |
|
2120.7.2
by Aaron Bentley
Move autoresolve functionality to workingtree |
412 |
base.commit('Hello') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
413 |
other = base.controldir.sprout('other').open_workingtree() |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
414 |
self.build_tree_contents([('other/hello', b'hELLO')]) |
|
2120.7.2
by Aaron Bentley
Move autoresolve functionality to workingtree |
415 |
other.commit('Case switch') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
416 |
this = base.controldir.sprout('this').open_workingtree() |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
417 |
self.assertPathExists('this/hello') |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
418 |
self.build_tree_contents([('this/hello', b'Hello World')]) |
|
2120.7.2
by Aaron Bentley
Move autoresolve functionality to workingtree |
419 |
this.commit('Add World') |
420 |
this.merge_from_branch(other.branch) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
421 |
self.assertEqual([conflicts.TextConflict('hello', b'hello_id')], |
|
2120.7.2
by Aaron Bentley
Move autoresolve functionality to workingtree |
422 |
this.conflicts()) |
423 |
this.auto_resolve() |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
424 |
self.assertEqual([conflicts.TextConflict('hello', b'hello_id')], |
|
2120.7.2
by Aaron Bentley
Move autoresolve functionality to workingtree |
425 |
this.conflicts()) |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
426 |
self.build_tree_contents([('this/hello', b'<<<<<<<')]) |
427 |
this.auto_resolve() |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
428 |
self.assertEqual([conflicts.TextConflict('hello', b'hello_id')], |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
429 |
this.conflicts()) |
430 |
self.build_tree_contents([('this/hello', b'=======')]) |
|
431 |
this.auto_resolve() |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
432 |
self.assertEqual([conflicts.TextConflict('hello', b'hello_id')], |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
433 |
this.conflicts()) |
434 |
self.build_tree_contents([('this/hello', b'\n>>>>>>>')]) |
|
|
2120.7.2
by Aaron Bentley
Move autoresolve functionality to workingtree |
435 |
remaining, resolved = this.auto_resolve() |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
436 |
self.assertEqual([conflicts.TextConflict('hello', b'hello_id')], |
|
2120.7.2
by Aaron Bentley
Move autoresolve functionality to workingtree |
437 |
this.conflicts()) |
438 |
self.assertEqual([], resolved) |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
439 |
self.build_tree_contents([('this/hello', b'hELLO wORLD')]) |
|
2120.7.2
by Aaron Bentley
Move autoresolve functionality to workingtree |
440 |
remaining, resolved = this.auto_resolve() |
441 |
self.assertEqual([], this.conflicts()) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
442 |
self.assertEqual([conflicts.TextConflict('hello', b'hello_id')], |
|
2120.7.2
by Aaron Bentley
Move autoresolve functionality to workingtree |
443 |
resolved) |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
444 |
self.assertPathDoesNotExist('this/hello.BASE') |
|
2120.7.3
by Aaron Bentley
Update resolve command to automatically mark conflicts as resolved |
445 |
|
446 |
def test_auto_resolve_dir(self): |
|
447 |
tree = self.make_branch_and_tree('tree') |
|
448 |
self.build_tree(['tree/hello/']) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
449 |
tree.add('hello', b'hello-id') |
450 |
file_conflict = conflicts.TextConflict('file', b'hello-id') |
|
|
2120.7.3
by Aaron Bentley
Update resolve command to automatically mark conflicts as resolved |
451 |
tree.set_conflicts(conflicts.ConflictList([file_conflict])) |
452 |
tree.auto_resolve() |
|
|
3140.1.4
by Aaron Bentley
Add WorkingTree.find_trees |
453 |
|
454 |
||
455 |
class TestFindTrees(TestCaseWithTransport): |
|
456 |
||
457 |
def test_find_trees(self): |
|
458 |
self.make_branch_and_tree('foo') |
|
459 |
self.make_branch_and_tree('foo/bar') |
|
460 |
# Sticking a tree inside a control dir is heinous, so let's skip it
|
|
461 |
self.make_branch_and_tree('foo/.bzr/baz') |
|
462 |
self.make_branch('qux') |
|
463 |
trees = workingtree.WorkingTree.find_trees('.') |
|
464 |
self.assertEqual(2, len(list(trees))) |
|
|
6538.1.5
by Aaron Bentley
Implement WorkingTree.store_uncommitted. |
465 |
|
466 |
||
467 |
class TestStoredUncommitted(TestCaseWithTransport): |
|
468 |
||
469 |
def store_uncommitted(self): |
|
470 |
tree = self.make_branch_and_tree('tree') |
|
471 |
tree.commit('get root in there') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
472 |
self.build_tree_contents([('tree/file', b'content')]) |
473 |
tree.add('file', b'file-id') |
|
|
6538.1.5
by Aaron Bentley
Implement WorkingTree.store_uncommitted. |
474 |
tree.store_uncommitted() |
475 |
return tree |
|
476 |
||
477 |
def test_store_uncommitted(self): |
|
478 |
self.store_uncommitted() |
|
479 |
self.assertPathDoesNotExist('tree/file') |
|
480 |
||
481 |
def test_store_uncommitted_no_change(self): |
|
482 |
tree = self.make_branch_and_tree('tree') |
|
483 |
tree.commit('get root in there') |
|
484 |
tree.store_uncommitted() |
|
|
6538.1.24
by Aaron Bentley
Eliminate get_stored_uncommitted from API. |
485 |
self.assertIs(None, tree.branch.get_unshelver(tree)) |
|
6538.1.10
by Aaron Bentley
Implement WorkingTree.get_uncommitted_data |
486 |
|
|
6538.1.11
by Aaron Bentley
Switch to much simpler implementation of restore_uncommitted. |
487 |
def test_restore_uncommitted(self): |
488 |
with write_locked(self.store_uncommitted()) as tree: |
|
489 |
tree.restore_uncommitted() |
|
490 |
self.assertPathExists('tree/file') |
|
|
6538.1.24
by Aaron Bentley
Eliminate get_stored_uncommitted from API. |
491 |
self.assertIs(None, tree.branch.get_unshelver(tree)) |
|
6538.1.11
by Aaron Bentley
Switch to much simpler implementation of restore_uncommitted. |
492 |
|
493 |
def test_restore_uncommitted_none(self): |
|
494 |
tree = self.make_branch_and_tree('tree') |
|
495 |
tree.restore_uncommitted() |