bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1 |
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
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 |
||
17 |
"""Tests for bzrdir implementations - tests a bzrdir format."""
|
|
18 |
||
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
19 |
from cStringIO import StringIO |
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
20 |
import errno |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
21 |
import os |
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
22 |
from stat import S_ISDIR |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
23 |
import sys |
24 |
||
|
1508.1.25
by Robert Collins
Update per review comments. |
25 |
import bzrlib.branch |
|
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
26 |
from bzrlib import ( |
27 |
bzrdir, |
|
28 |
errors, |
|
29 |
lockdir, |
|
30 |
repository, |
|
31 |
transactions, |
|
32 |
transport, |
|
33 |
ui, |
|
34 |
workingtree, |
|
35 |
)
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
36 |
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
37 |
from bzrlib.check import check |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
38 |
from bzrlib.errors import (FileExists, |
39 |
NoSuchRevision, |
|
40 |
NoSuchFile, |
|
41 |
UninitializableFormat, |
|
42 |
NotBranchError, |
|
43 |
)
|
|
|
1551.8.20
by Aaron Bentley
Fix BzrDir.create_workingtree for NULL_REVISION |
44 |
import bzrlib.revision |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
45 |
from bzrlib.tests import ( |
46 |
ChrootedTestCase, |
|
47 |
TestCase, |
|
48 |
TestCaseWithTransport, |
|
49 |
TestSkipped, |
|
50 |
)
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
51 |
from bzrlib.trace import mutter |
52 |
from bzrlib.transport import get_transport |
|
53 |
from bzrlib.upgrade import upgrade |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
54 |
from bzrlib.repofmt import weaverepo |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
55 |
|
56 |
||
57 |
class TestCaseWithBzrDir(TestCaseWithTransport): |
|
58 |
||
59 |
def setUp(self): |
|
60 |
super(TestCaseWithBzrDir, self).setUp() |
|
61 |
self.bzrdir = None |
|
62 |
||
63 |
def get_bzrdir(self): |
|
64 |
if self.bzrdir is None: |
|
65 |
self.bzrdir = self.make_bzrdir(None) |
|
66 |
return self.bzrdir |
|
67 |
||
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
68 |
def make_bzrdir(self, relpath, format=None): |
69 |
return super(TestCaseWithBzrDir, self).make_bzrdir( |
|
70 |
relpath, format=self.bzrdir_format) |
|
71 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
72 |
|
73 |
||
74 |
class TestBzrDir(TestCaseWithBzrDir): |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
75 |
# Many of these tests test for disk equality rather than checking
|
76 |
# for semantic equivalence. This works well for some tests but
|
|
77 |
# is not good at handling changes in representation or the addition
|
|
78 |
# or removal of control data. It would be nice to for instance:
|
|
79 |
# sprout a new branch, check that the nickname has been reset by hand
|
|
80 |
# and then set the nickname to match the source branch, at which point
|
|
81 |
# a semantic equivalence should pass
|
|
82 |
||
83 |
def assertDirectoriesEqual(self, source, target, ignore_list=[]): |
|
84 |
"""Assert that the content of source and target are identical. |
|
85 |
||
86 |
paths in ignore list will be completely ignored.
|
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
87 |
|
88 |
We ignore paths that represent data which is allowed to change during
|
|
89 |
a clone or sprout: for instance, inventory.knit contains gzip fragements
|
|
90 |
which have timestamps in them, and as we have read the inventory from
|
|
91 |
the source knit, the already-read data is recompressed rather than
|
|
92 |
reading it again, which leads to changed timestamps. This is ok though,
|
|
93 |
because the inventory.kndx file is not ignored, and the integrity of
|
|
94 |
knit joins is tested by test_knit and test_versionedfile.
|
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
95 |
"""
|
96 |
files = [] |
|
97 |
directories = ['.'] |
|
98 |
while directories: |
|
99 |
dir = directories.pop() |
|
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
100 |
for path in set(source.list_dir(dir) + target.list_dir(dir)): |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
101 |
path = dir + '/' + path |
102 |
if path in ignore_list: |
|
103 |
continue
|
|
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
104 |
try: |
105 |
stat = source.stat(path) |
|
|
2230.3.30
by Aaron Bentley
Fix whitespace issues |
106 |
except errors.NoSuchFile: |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
107 |
self.fail('%s not in source' % path) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
108 |
if S_ISDIR(stat.st_mode): |
109 |
self.assertTrue(S_ISDIR(target.stat(path).st_mode)) |
|
110 |
directories.append(path) |
|
111 |
else: |
|
112 |
self.assertEqualDiff(source.get(path).read(), |
|
113 |
target.get(path).read(), |
|
114 |
"text for file %r differs:\n" % path) |
|
115 |
||
|
1910.4.12
by Andrew Bennetts
Use camelCase for test helpers to be more consistent unittest naming. |
116 |
def skipIfNoWorkingTree(self, a_bzrdir): |
|
1910.4.11
by Andrew Bennetts
Add 'create_workingtree_or_skip' and 'skip_if_no_workingtree' helper methods to reduce duplicated code. |
117 |
"""Raises TestSkipped if a_bzrdir doesn't have a working tree. |
118 |
|
|
119 |
If the bzrdir does have a workingtree, this is a no-op.
|
|
120 |
"""
|
|
121 |
try: |
|
122 |
a_bzrdir.open_workingtree() |
|
123 |
except (errors.NotLocalUrl, errors.NoWorkingTree): |
|
124 |
raise TestSkipped("bzrdir on transport %r has no working tree" |
|
125 |
% a_bzrdir.transport) |
|
126 |
||
|
1910.4.13
by Andrew Bennetts
Slightly more consistent names. |
127 |
def createWorkingTreeOrSkip(self, a_bzrdir): |
|
1910.4.11
by Andrew Bennetts
Add 'create_workingtree_or_skip' and 'skip_if_no_workingtree' helper methods to reduce duplicated code. |
128 |
"""Create a working tree on a_bzrdir, or raise TestSkipped. |
129 |
|
|
130 |
A simple wrapper for create_workingtree that translates NotLocalUrl into
|
|
131 |
TestSkipped. Returns the newly created working tree.
|
|
132 |
"""
|
|
133 |
try: |
|
134 |
return a_bzrdir.create_workingtree() |
|
135 |
except errors.NotLocalUrl: |
|
136 |
raise TestSkipped("cannot make working tree with transport %r" |
|
137 |
% a_bzrdir.transport) |
|
138 |
||
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
139 |
def sproutOrSkip(self, from_bzrdir, to_url, revision_id=None, |
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
140 |
force_new_repo=False): |
141 |
"""Sprout from_bzrdir into to_url, or raise TestSkipped. |
|
142 |
|
|
143 |
A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into
|
|
144 |
TestSkipped. Returns the newly sprouted bzrdir.
|
|
145 |
"""
|
|
146 |
try: |
|
147 |
target = from_bzrdir.sprout(to_url, revision_id=revision_id, |
|
148 |
force_new_repo=force_new_repo) |
|
149 |
except errors.NotLocalUrl: |
|
150 |
raise TestSkipped('Cannot sprout to remote bzrdirs.') |
|
151 |
return target |
|
152 |
||
|
1551.8.20
by Aaron Bentley
Fix BzrDir.create_workingtree for NULL_REVISION |
153 |
def test_create_null_workingtree(self): |
154 |
dir = self.make_bzrdir('dir1') |
|
155 |
dir.create_repository() |
|
156 |
dir.create_branch() |
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
157 |
try: |
158 |
wt = dir.create_workingtree(revision_id=bzrlib.revision.NULL_REVISION) |
|
159 |
except errors.NotLocalUrl: |
|
160 |
raise TestSkipped("cannot make working tree with transport %r" |
|
161 |
% dir.transport) |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
162 |
self.assertEqual([], wt.get_parent_ids()) |
|
1551.8.20
by Aaron Bentley
Fix BzrDir.create_workingtree for NULL_REVISION |
163 |
|
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
164 |
def test_destroy_workingtree(self): |
165 |
tree = self.make_branch_and_tree('tree') |
|
166 |
self.build_tree(['tree/file']) |
|
167 |
tree.add('file') |
|
168 |
tree.commit('first commit') |
|
169 |
bzrdir = tree.bzrdir |
|
170 |
try: |
|
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
171 |
bzrdir.destroy_workingtree() |
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
172 |
except errors.UnsupportedOperation: |
173 |
raise TestSkipped('Format does not support destroying tree') |
|
174 |
self.failIfExists('tree/file') |
|
175 |
self.assertRaises(errors.NoWorkingTree, bzrdir.open_workingtree) |
|
176 |
bzrdir.create_workingtree() |
|
177 |
self.failUnlessExists('tree/file') |
|
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
178 |
bzrdir.destroy_workingtree_metadata() |
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
179 |
self.failUnlessExists('tree/file') |
180 |
self.assertRaises(errors.NoWorkingTree, bzrdir.open_workingtree) |
|
181 |
||
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
182 |
def test_clone_bzrdir_empty(self): |
183 |
dir = self.make_bzrdir('source') |
|
184 |
target = dir.clone(self.get_url('target')) |
|
185 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
186 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
187 |
['./.bzr/merge-hashes']) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
188 |
|
|
1534.6.8
by Robert Collins
Test the use of clone on empty bzrdir with force_new_repo. |
189 |
def test_clone_bzrdir_empty_force_new_ignored(self): |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
190 |
# the force_new_repo parameter should have no effect on an empty
|
|
1534.6.8
by Robert Collins
Test the use of clone on empty bzrdir with force_new_repo. |
191 |
# bzrdir's clone logic
|
192 |
dir = self.make_bzrdir('source') |
|
193 |
target = dir.clone(self.get_url('target'), force_new_repo=True) |
|
194 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
195 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
196 |
['./.bzr/merge-hashes']) |
|
|
1534.6.8
by Robert Collins
Test the use of clone on empty bzrdir with force_new_repo. |
197 |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
198 |
def test_clone_bzrdir_repository(self): |
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
199 |
tree = self.make_branch_and_tree('commit_tree') |
200 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
201 |
tree.add('foo') |
|
202 |
tree.commit('revision 1', rev_id='1') |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
203 |
dir = self.make_bzrdir('source') |
204 |
repo = dir.create_repository() |
|
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
205 |
repo.fetch(tree.branch.repository) |
206 |
self.assertTrue(repo.has_revision('1')) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
207 |
target = dir.clone(self.get_url('target')) |
208 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
209 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
210 |
[
|
211 |
'./.bzr/merge-hashes', |
|
212 |
'./.bzr/repository/inventory.knit', |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
213 |
])
|
214 |
||
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
215 |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
216 |
def test_clone_bzrdir_repository_under_shared(self): |
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
217 |
tree = self.make_branch_and_tree('commit_tree') |
218 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
219 |
tree.add('foo') |
|
220 |
tree.commit('revision 1', rev_id='1') |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
221 |
dir = self.make_bzrdir('source') |
222 |
repo = dir.create_repository() |
|
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
223 |
repo.fetch(tree.branch.repository) |
224 |
self.assertTrue(repo.has_revision('1')) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
225 |
try: |
226 |
self.make_repository('target', shared=True) |
|
227 |
except errors.IncompatibleFormat: |
|
228 |
return
|
|
229 |
target = dir.clone(self.get_url('target/child')) |
|
230 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
231 |
self.assertRaises(errors.NoRepositoryPresent, target.open_repository) |
|
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
232 |
|
233 |
def test_clone_bzrdir_repository_branch_both_under_shared(self): |
|
234 |
try: |
|
235 |
shared_repo = self.make_repository('shared', shared=True) |
|
236 |
except errors.IncompatibleFormat: |
|
237 |
return
|
|
238 |
tree = self.make_branch_and_tree('commit_tree') |
|
239 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
240 |
tree.add('foo') |
|
241 |
tree.commit('revision 1', rev_id='1') |
|
242 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
|
1908.6.1
by Robert Collins
Change all callers of set_last_revision to use set_parent_trees. |
243 |
tree.set_parent_trees([]) |
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
244 |
tree.commit('revision 2', rev_id='2') |
245 |
tree.bzrdir.open_repository().copy_content_into(shared_repo) |
|
246 |
dir = self.make_bzrdir('shared/source') |
|
247 |
dir.create_branch() |
|
248 |
target = dir.clone(self.get_url('shared/target')) |
|
249 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
250 |
self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base) |
|
251 |
self.assertTrue(shared_repo.has_revision('1')) |
|
|
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
252 |
|
253 |
def test_clone_bzrdir_repository_branch_only_source_under_shared(self): |
|
254 |
try: |
|
255 |
shared_repo = self.make_repository('shared', shared=True) |
|
256 |
except errors.IncompatibleFormat: |
|
257 |
return
|
|
258 |
tree = self.make_branch_and_tree('commit_tree') |
|
259 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
260 |
tree.add('foo') |
|
261 |
tree.commit('revision 1', rev_id='1') |
|
262 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
|
1908.6.1
by Robert Collins
Change all callers of set_last_revision to use set_parent_trees. |
263 |
tree.set_parent_trees([]) |
|
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
264 |
tree.commit('revision 2', rev_id='2') |
265 |
tree.bzrdir.open_repository().copy_content_into(shared_repo) |
|
266 |
shared_repo.set_make_working_trees(False) |
|
267 |
self.assertFalse(shared_repo.make_working_trees()) |
|
268 |
self.assertTrue(shared_repo.has_revision('1')) |
|
269 |
dir = self.make_bzrdir('shared/source') |
|
270 |
dir.create_branch() |
|
271 |
target = dir.clone(self.get_url('target')) |
|
272 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
273 |
self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base) |
|
274 |
branch = target.open_branch() |
|
275 |
self.assertTrue(branch.repository.has_revision('1')) |
|
276 |
self.assertFalse(branch.repository.make_working_trees()) |
|
277 |
self.assertTrue(branch.repository.is_shared()) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
278 |
|
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
279 |
def test_clone_bzrdir_repository_under_shared_force_new_repo(self): |
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
280 |
tree = self.make_branch_and_tree('commit_tree') |
281 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
282 |
tree.add('foo') |
|
283 |
tree.commit('revision 1', rev_id='1') |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
284 |
dir = self.make_bzrdir('source') |
285 |
repo = dir.create_repository() |
|
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
286 |
repo.fetch(tree.branch.repository) |
287 |
self.assertTrue(repo.has_revision('1')) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
288 |
try: |
289 |
self.make_repository('target', shared=True) |
|
290 |
except errors.IncompatibleFormat: |
|
291 |
return
|
|
292 |
target = dir.clone(self.get_url('target/child'), force_new_repo=True) |
|
293 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
294 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
295 |
['./.bzr/repository/inventory.knit', |
|
296 |
])
|
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
297 |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
298 |
def test_clone_bzrdir_repository_revision(self): |
299 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
300 |
# make a repository with some revisions,
|
|
301 |
# and clone it with a revision limit.
|
|
302 |
#
|
|
303 |
tree = self.make_branch_and_tree('commit_tree') |
|
304 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
305 |
tree.add('foo') |
|
306 |
tree.commit('revision 1', rev_id='1') |
|
307 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
|
1908.6.1
by Robert Collins
Change all callers of set_last_revision to use set_parent_trees. |
308 |
tree.set_parent_trees([]) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
309 |
tree.commit('revision 2', rev_id='2') |
310 |
source = self.make_repository('source') |
|
311 |
tree.bzrdir.open_repository().copy_content_into(source) |
|
312 |
dir = source.bzrdir |
|
313 |
target = dir.clone(self.get_url('target'), revision_id='2') |
|
314 |
raise TestSkipped('revision limiting not strict yet') |
|
315 |
||
316 |
def test_clone_bzrdir_branch_and_repo(self): |
|
317 |
tree = self.make_branch_and_tree('commit_tree') |
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
318 |
self.build_tree(['foo'], transport=tree.bzrdir.root_transport) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
319 |
tree.add('foo') |
320 |
tree.commit('revision 1') |
|
321 |
source = self.make_branch('source') |
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
322 |
tree.branch.repository.copy_content_into(source.repository) |
323 |
tree.branch.copy_content_into(source) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
324 |
dir = source.bzrdir |
325 |
target = dir.clone(self.get_url('target')) |
|
326 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
327 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
328 |
[
|
329 |
'./.bzr/basis-inventory-cache', |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
330 |
'./.bzr/checkout/stat-cache', |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
331 |
'./.bzr/merge-hashes', |
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
332 |
'./.bzr/repository/inventory.knit', |
|
2230.3.30
by Aaron Bentley
Fix whitespace issues |
333 |
'./.bzr/stat-cache', |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
334 |
])
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
335 |
|
336 |
def test_clone_bzrdir_branch_and_repo_into_shared_repo(self): |
|
337 |
# by default cloning into a shared repo uses the shared repo.
|
|
338 |
tree = self.make_branch_and_tree('commit_tree') |
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
339 |
self.build_tree(['foo'], transport=tree.bzrdir.root_transport) |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
340 |
tree.add('foo') |
341 |
tree.commit('revision 1') |
|
342 |
source = self.make_branch('source') |
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
343 |
tree.branch.repository.copy_content_into(source.repository) |
344 |
tree.branch.copy_content_into(source) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
345 |
try: |
346 |
self.make_repository('target', shared=True) |
|
347 |
except errors.IncompatibleFormat: |
|
348 |
return
|
|
349 |
dir = source.bzrdir |
|
350 |
target = dir.clone(self.get_url('target/child')) |
|
351 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
352 |
self.assertRaises(errors.NoRepositoryPresent, target.open_repository) |
|
353 |
self.assertEqual(source.revision_history(), |
|
354 |
target.open_branch().revision_history()) |
|
355 |
||
356 |
def test_clone_bzrdir_branch_and_repo_into_shared_repo_force_new_repo(self): |
|
357 |
# by default cloning into a shared repo uses the shared repo.
|
|
358 |
tree = self.make_branch_and_tree('commit_tree') |
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
359 |
self.build_tree(['foo'], transport=tree.bzrdir.root_transport) |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
360 |
tree.add('foo') |
361 |
tree.commit('revision 1') |
|
362 |
source = self.make_branch('source') |
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
363 |
tree.branch.repository.copy_content_into(source.repository) |
364 |
tree.branch.copy_content_into(source) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
365 |
try: |
366 |
self.make_repository('target', shared=True) |
|
367 |
except errors.IncompatibleFormat: |
|
368 |
return
|
|
369 |
dir = source.bzrdir |
|
370 |
target = dir.clone(self.get_url('target/child'), force_new_repo=True) |
|
371 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
372 |
target.open_repository() |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
373 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
374 |
['./.bzr/repository/inventory.knit', |
|
375 |
])
|
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
376 |
|
377 |
def test_clone_bzrdir_branch_reference(self): |
|
378 |
# cloning should preserve the reference status of the branch in a bzrdir
|
|
379 |
referenced_branch = self.make_branch('referencced') |
|
380 |
dir = self.make_bzrdir('source') |
|
381 |
try: |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
382 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
383 |
referenced_branch) |
384 |
except errors.IncompatibleFormat: |
|
385 |
# this is ok too, not all formats have to support references.
|
|
386 |
return
|
|
387 |
target = dir.clone(self.get_url('target')) |
|
388 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
389 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
390 |
['./.bzr/repository/inventory.knit', |
|
391 |
])
|
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
392 |
|
393 |
def test_clone_bzrdir_branch_revision(self): |
|
394 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
395 |
# make a branch with some revisions,
|
|
396 |
# and clone it with a revision limit.
|
|
397 |
#
|
|
398 |
tree = self.make_branch_and_tree('commit_tree') |
|
399 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
400 |
tree.add('foo') |
|
401 |
tree.commit('revision 1', rev_id='1') |
|
402 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
403 |
source = self.make_branch('source') |
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
404 |
tree.branch.repository.copy_content_into(source.repository) |
405 |
tree.branch.copy_content_into(source) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
406 |
dir = source.bzrdir |
407 |
target = dir.clone(self.get_url('target'), revision_id='1') |
|
408 |
self.assertEqual('1', target.open_branch().last_revision()) |
|
409 |
||
410 |
def test_clone_bzrdir_tree_branch_repo(self): |
|
411 |
tree = self.make_branch_and_tree('sourcce') |
|
412 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
413 |
tree.add('foo') |
|
414 |
tree.commit('revision 1') |
|
415 |
dir = tree.bzrdir |
|
416 |
target = dir.clone(self.get_url('target')) |
|
|
1910.4.12
by Andrew Bennetts
Use camelCase for test helpers to be more consistent unittest naming. |
417 |
self.skipIfNoWorkingTree(target) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
418 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
419 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
420 |
['./.bzr/stat-cache', |
|
2255.10.5
by John Arbash Meinel
Fix a small bug when we have a symlink that does not need to be re-read. |
421 |
'./.bzr/checkout/dirstate', |
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
422 |
'./.bzr/checkout/stat-cache', |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
423 |
'./.bzr/checkout/merge-hashes', |
424 |
'./.bzr/merge-hashes', |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
425 |
'./.bzr/repository/inventory.knit', |
426 |
])
|
|
427 |
||
|
1534.7.175
by Aaron Bentley
Ensured revert writes a normal inventory |
428 |
target.open_workingtree().revert([]) |
429 |
||
430 |
def test_revert_inventory(self): |
|
431 |
tree = self.make_branch_and_tree('sourcce') |
|
432 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
433 |
tree.add('foo') |
|
434 |
tree.commit('revision 1') |
|
435 |
dir = tree.bzrdir |
|
436 |
target = dir.clone(self.get_url('target')) |
|
|
1910.4.12
by Andrew Bennetts
Use camelCase for test helpers to be more consistent unittest naming. |
437 |
self.skipIfNoWorkingTree(target) |
|
1534.7.175
by Aaron Bentley
Ensured revert writes a normal inventory |
438 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
439 |
['./.bzr/stat-cache', |
|
2255.10.8
by John Arbash Meinel
Fix another tests that was assuming dirstate was identical |
440 |
'./.bzr/checkout/dirstate', |
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
441 |
'./.bzr/checkout/stat-cache', |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
442 |
'./.bzr/checkout/merge-hashes', |
443 |
'./.bzr/merge-hashes', |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
444 |
'./.bzr/repository/inventory.knit', |
445 |
])
|
|
446 |
||
|
1534.7.175
by Aaron Bentley
Ensured revert writes a normal inventory |
447 |
target.open_workingtree().revert([]) |
448 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
449 |
['./.bzr/stat-cache', |
|
2255.10.8
by John Arbash Meinel
Fix another tests that was assuming dirstate was identical |
450 |
'./.bzr/checkout/dirstate', |
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
451 |
'./.bzr/checkout/stat-cache', |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
452 |
'./.bzr/checkout/merge-hashes', |
453 |
'./.bzr/merge-hashes', |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
454 |
'./.bzr/repository/inventory.knit', |
455 |
])
|
|
456 |
||
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
457 |
def test_clone_bzrdir_tree_branch_reference(self): |
458 |
# a tree with a branch reference (aka a checkout)
|
|
459 |
# should stay a checkout on clone.
|
|
460 |
referenced_branch = self.make_branch('referencced') |
|
461 |
dir = self.make_bzrdir('source') |
|
462 |
try: |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
463 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
464 |
referenced_branch) |
465 |
except errors.IncompatibleFormat: |
|
466 |
# this is ok too, not all formats have to support references.
|
|
467 |
return
|
|
|
1910.4.13
by Andrew Bennetts
Slightly more consistent names. |
468 |
self.createWorkingTreeOrSkip(dir) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
469 |
target = dir.clone(self.get_url('target')) |
|
1910.4.12
by Andrew Bennetts
Use camelCase for test helpers to be more consistent unittest naming. |
470 |
self.skipIfNoWorkingTree(target) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
471 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
472 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
473 |
['./.bzr/stat-cache', |
474 |
'./.bzr/checkout/stat-cache', |
|
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
475 |
'./.bzr/checkout/merge-hashes', |
476 |
'./.bzr/merge-hashes', |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
477 |
'./.bzr/repository/inventory.knit', |
478 |
])
|
|
479 |
||
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
480 |
def test_clone_bzrdir_tree_revision(self): |
481 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
482 |
# make a tree with a revision with a last-revision
|
|
483 |
# and clone it with a revision limit.
|
|
484 |
# This smoke test just checks the revision-id is right. Tree specific
|
|
485 |
# tests will check corner cases.
|
|
486 |
tree = self.make_branch_and_tree('source') |
|
487 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
488 |
tree.add('foo') |
|
489 |
tree.commit('revision 1', rev_id='1') |
|
490 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
491 |
dir = tree.bzrdir |
|
492 |
target = dir.clone(self.get_url('target'), revision_id='1') |
|
|
1910.4.12
by Andrew Bennetts
Use camelCase for test helpers to be more consistent unittest naming. |
493 |
self.skipIfNoWorkingTree(target) |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
494 |
self.assertEqual(['1'], target.open_workingtree().get_parent_ids()) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
495 |
|
496 |
def test_sprout_bzrdir_empty(self): |
|
497 |
dir = self.make_bzrdir('source') |
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
498 |
target = self.sproutOrSkip(dir, self.get_url('target')) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
499 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
500 |
# creates a new repository branch and tree
|
|
501 |
target.open_repository() |
|
502 |
target.open_branch() |
|
503 |
target.open_workingtree() |
|
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
504 |
|
505 |
def test_sprout_bzrdir_empty_under_shared_repo(self): |
|
506 |
# sprouting an empty dir into a repo uses the repo
|
|
507 |
dir = self.make_bzrdir('source') |
|
508 |
try: |
|
509 |
self.make_repository('target', shared=True) |
|
510 |
except errors.IncompatibleFormat: |
|
511 |
return
|
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
512 |
target = self.sproutOrSkip(dir, self.get_url('target/child')) |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
513 |
self.assertRaises(errors.NoRepositoryPresent, target.open_repository) |
514 |
target.open_branch() |
|
515 |
target.open_workingtree() |
|
516 |
||
|
1910.4.10
by Andrew Bennetts
Skip various test_sprout* tests when sprouting to non-local bzrdirs that can't have working trees; plus fix a test method naming clash and the bug it revealed in bzrdir.sprout. |
517 |
def test_sprout_bzrdir_empty_under_shared_repo_force_new(self): |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
518 |
# the force_new_repo parameter should force use of a new repo in an empty
|
519 |
# bzrdir's sprout logic
|
|
520 |
dir = self.make_bzrdir('source') |
|
521 |
try: |
|
522 |
self.make_repository('target', shared=True) |
|
523 |
except errors.IncompatibleFormat: |
|
524 |
return
|
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
525 |
target = self.sproutOrSkip(dir, self.get_url('target/child'), |
526 |
force_new_repo=True) |
|
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
527 |
target.open_repository() |
528 |
target.open_branch() |
|
529 |
target.open_workingtree() |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
530 |
|
531 |
def test_sprout_bzrdir_repository(self): |
|
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
532 |
tree = self.make_branch_and_tree('commit_tree') |
533 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
534 |
tree.add('foo') |
|
535 |
tree.commit('revision 1', rev_id='1') |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
536 |
dir = self.make_bzrdir('source') |
537 |
repo = dir.create_repository() |
|
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
538 |
repo.fetch(tree.branch.repository) |
539 |
self.assertTrue(repo.has_revision('1')) |
|
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
540 |
try: |
541 |
self.assertIs(dir.open_branch().last_revision(), None) |
|
542 |
except errors.NotBranchError: |
|
543 |
pass
|
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
544 |
target = self.sproutOrSkip(dir, self.get_url('target')) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
545 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
546 |
# testing inventory isn't reasonable for repositories
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
547 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
548 |
[
|
549 |
'./.bzr/branch', |
|
550 |
'./.bzr/checkout', |
|
551 |
'./.bzr/inventory', |
|
552 |
'./.bzr/parent', |
|
553 |
'./.bzr/repository/inventory.knit', |
|
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
554 |
])
|
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
555 |
try: |
556 |
# If we happen to have a tree, we'll guarantee everything
|
|
557 |
# except for the tree root is the same.
|
|
558 |
inventory_f = file(dir.transport.base+'inventory', 'rb') |
|
559 |
self.assertContainsRe(inventory_f.read(), |
|
560 |
'<inventory file_id="TREE_ROOT[^"]*"'
|
|
561 |
' format="5">\n</inventory>\n') |
|
562 |
inventory_f.close() |
|
563 |
except IOError, e: |
|
564 |
if e.errno != errno.ENOENT: |
|
565 |
raise
|
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
566 |
|
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
567 |
def test_sprout_bzrdir_with_repository_to_shared(self): |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
568 |
tree = self.make_branch_and_tree('commit_tree') |
569 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
570 |
tree.add('foo') |
|
571 |
tree.commit('revision 1', rev_id='1') |
|
572 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
|
1908.6.1
by Robert Collins
Change all callers of set_last_revision to use set_parent_trees. |
573 |
tree.set_parent_trees([]) |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
574 |
tree.commit('revision 2', rev_id='2') |
575 |
source = self.make_repository('source') |
|
576 |
tree.bzrdir.open_repository().copy_content_into(source) |
|
577 |
dir = source.bzrdir |
|
578 |
try: |
|
579 |
shared_repo = self.make_repository('target', shared=True) |
|
580 |
except errors.IncompatibleFormat: |
|
581 |
return
|
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
582 |
target = self.sproutOrSkip(dir, self.get_url('target/child')) |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
583 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
584 |
self.assertTrue(shared_repo.has_revision('1')) |
|
585 |
||
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
586 |
def test_sprout_bzrdir_repository_branch_both_under_shared(self): |
587 |
try: |
|
588 |
shared_repo = self.make_repository('shared', shared=True) |
|
589 |
except errors.IncompatibleFormat: |
|
590 |
return
|
|
591 |
tree = self.make_branch_and_tree('commit_tree') |
|
592 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
593 |
tree.add('foo') |
|
594 |
tree.commit('revision 1', rev_id='1') |
|
595 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
|
1908.6.1
by Robert Collins
Change all callers of set_last_revision to use set_parent_trees. |
596 |
tree.set_parent_trees([]) |
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
597 |
tree.commit('revision 2', rev_id='2') |
598 |
tree.bzrdir.open_repository().copy_content_into(shared_repo) |
|
599 |
dir = self.make_bzrdir('shared/source') |
|
600 |
dir.create_branch() |
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
601 |
target = self.sproutOrSkip(dir, self.get_url('shared/target')) |
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
602 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
603 |
self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base) |
|
604 |
self.assertTrue(shared_repo.has_revision('1')) |
|
605 |
||
|
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
606 |
def test_sprout_bzrdir_repository_branch_only_source_under_shared(self): |
607 |
try: |
|
608 |
shared_repo = self.make_repository('shared', shared=True) |
|
609 |
except errors.IncompatibleFormat: |
|
610 |
return
|
|
611 |
tree = self.make_branch_and_tree('commit_tree') |
|
612 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
613 |
tree.add('foo') |
|
614 |
tree.commit('revision 1', rev_id='1') |
|
615 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
|
1908.6.1
by Robert Collins
Change all callers of set_last_revision to use set_parent_trees. |
616 |
tree.set_parent_trees([]) |
|
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
617 |
tree.commit('revision 2', rev_id='2') |
618 |
tree.bzrdir.open_repository().copy_content_into(shared_repo) |
|
619 |
shared_repo.set_make_working_trees(False) |
|
620 |
self.assertFalse(shared_repo.make_working_trees()) |
|
621 |
self.assertTrue(shared_repo.has_revision('1')) |
|
622 |
dir = self.make_bzrdir('shared/source') |
|
623 |
dir.create_branch() |
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
624 |
target = self.sproutOrSkip(dir, self.get_url('target')) |
|
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
625 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
626 |
self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base) |
|
627 |
branch = target.open_branch() |
|
628 |
self.assertTrue(branch.repository.has_revision('1')) |
|
629 |
self.assertTrue(branch.repository.make_working_trees()) |
|
630 |
self.assertFalse(branch.repository.is_shared()) |
|
631 |
||
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
632 |
def test_sprout_bzrdir_repository_under_shared_force_new_repo(self): |
633 |
tree = self.make_branch_and_tree('commit_tree') |
|
634 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
635 |
tree.add('foo') |
|
636 |
tree.commit('revision 1', rev_id='1') |
|
637 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
|
1908.6.1
by Robert Collins
Change all callers of set_last_revision to use set_parent_trees. |
638 |
tree.set_parent_trees([]) |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
639 |
tree.commit('revision 2', rev_id='2') |
640 |
source = self.make_repository('source') |
|
641 |
tree.bzrdir.open_repository().copy_content_into(source) |
|
642 |
dir = source.bzrdir |
|
643 |
try: |
|
644 |
shared_repo = self.make_repository('target', shared=True) |
|
645 |
except errors.IncompatibleFormat: |
|
646 |
return
|
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
647 |
target = self.sproutOrSkip(dir, self.get_url('target/child'), |
648 |
force_new_repo=True) |
|
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
649 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
650 |
self.assertFalse(shared_repo.has_revision('1')) |
|
651 |
||
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
652 |
def test_sprout_bzrdir_repository_revision(self): |
653 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
654 |
# make a repository with some revisions,
|
|
655 |
# and sprout it with a revision limit.
|
|
656 |
#
|
|
657 |
tree = self.make_branch_and_tree('commit_tree') |
|
658 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
659 |
tree.add('foo') |
|
660 |
tree.commit('revision 1', rev_id='1') |
|
661 |
tree.bzrdir.open_branch().set_revision_history([]) |
|
|
1908.6.1
by Robert Collins
Change all callers of set_last_revision to use set_parent_trees. |
662 |
tree.set_parent_trees([]) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
663 |
tree.commit('revision 2', rev_id='2') |
664 |
source = self.make_repository('source') |
|
665 |
tree.bzrdir.open_repository().copy_content_into(source) |
|
666 |
dir = source.bzrdir |
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
667 |
target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='2') |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
668 |
raise TestSkipped('revision limiting not strict yet') |
669 |
||
670 |
def test_sprout_bzrdir_branch_and_repo(self): |
|
671 |
tree = self.make_branch_and_tree('commit_tree') |
|
672 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
673 |
tree.add('foo') |
|
674 |
tree.commit('revision 1') |
|
675 |
source = self.make_branch('source') |
|
676 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
677 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
678 |
dir = source.bzrdir |
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
679 |
target = self.sproutOrSkip(dir, self.get_url('target')) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
680 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
681 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
682 |
[
|
683 |
'./.bzr/basis-inventory-cache', |
|
684 |
'./.bzr/branch/branch.conf', |
|
685 |
'./.bzr/branch/parent', |
|
686 |
'./.bzr/checkout', |
|
687 |
'./.bzr/checkout/inventory', |
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
688 |
'./.bzr/checkout/stat-cache', |
689 |
'./.bzr/inventory', |
|
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
690 |
'./.bzr/parent', |
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
691 |
'./.bzr/repository/inventory.knit', |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
692 |
'./.bzr/stat-cache', |
693 |
'./foo', |
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
694 |
])
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
695 |
|
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
696 |
def test_sprout_bzrdir_branch_and_repo_shared(self): |
697 |
# sprouting a branch with a repo into a shared repo uses the shared
|
|
698 |
# repo
|
|
699 |
tree = self.make_branch_and_tree('commit_tree') |
|
700 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
701 |
tree.add('foo') |
|
702 |
tree.commit('revision 1', rev_id='1') |
|
703 |
source = self.make_branch('source') |
|
704 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
705 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
706 |
dir = source.bzrdir |
|
707 |
try: |
|
708 |
shared_repo = self.make_repository('target', shared=True) |
|
709 |
except errors.IncompatibleFormat: |
|
710 |
return
|
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
711 |
target = self.sproutOrSkip(dir, self.get_url('target/child')) |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
712 |
self.assertTrue(shared_repo.has_revision('1')) |
713 |
||
714 |
def test_sprout_bzrdir_branch_and_repo_shared_force_new_repo(self): |
|
715 |
# sprouting a branch with a repo into a shared repo uses the shared
|
|
716 |
# repo
|
|
717 |
tree = self.make_branch_and_tree('commit_tree') |
|
718 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
719 |
tree.add('foo') |
|
720 |
tree.commit('revision 1', rev_id='1') |
|
721 |
source = self.make_branch('source') |
|
722 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
723 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
724 |
dir = source.bzrdir |
|
725 |
try: |
|
726 |
shared_repo = self.make_repository('target', shared=True) |
|
727 |
except errors.IncompatibleFormat: |
|
728 |
return
|
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
729 |
target = self.sproutOrSkip(dir, self.get_url('target/child'), |
730 |
force_new_repo=True) |
|
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
731 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
732 |
self.assertFalse(shared_repo.has_revision('1')) |
|
733 |
||
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
734 |
def test_sprout_bzrdir_branch_reference(self): |
735 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
736 |
referenced_branch = self.make_branch('referencced') |
|
737 |
dir = self.make_bzrdir('source') |
|
738 |
try: |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
739 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
740 |
referenced_branch) |
741 |
except errors.IncompatibleFormat: |
|
742 |
# this is ok too, not all formats have to support references.
|
|
743 |
return
|
|
744 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
745 |
target = self.sproutOrSkip(dir, self.get_url('target')) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
746 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
747 |
# we want target to have a branch that is in-place.
|
|
748 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
749 |
# and as we dont support repositories being detached yet, a repo in
|
|
750 |
# place
|
|
751 |
target.open_repository() |
|
752 |
||
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
753 |
def test_sprout_bzrdir_branch_reference_shared(self): |
754 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
755 |
referenced_tree = self.make_branch_and_tree('referenced') |
|
756 |
referenced_tree.commit('1', rev_id='1', allow_pointless=True) |
|
757 |
dir = self.make_bzrdir('source') |
|
758 |
try: |
|
759 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
760 |
referenced_tree.branch) |
|
761 |
except errors.IncompatibleFormat: |
|
762 |
# this is ok too, not all formats have to support references.
|
|
763 |
return
|
|
764 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
765 |
try: |
|
766 |
shared_repo = self.make_repository('target', shared=True) |
|
767 |
except errors.IncompatibleFormat: |
|
768 |
return
|
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
769 |
target = self.sproutOrSkip(dir, self.get_url('target/child')) |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
770 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
771 |
# we want target to have a branch that is in-place.
|
|
772 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
773 |
# and we want no repository as the target is shared
|
|
774 |
self.assertRaises(errors.NoRepositoryPresent, |
|
775 |
target.open_repository) |
|
776 |
# and we want revision '1' in the shared repo
|
|
777 |
self.assertTrue(shared_repo.has_revision('1')) |
|
778 |
||
779 |
def test_sprout_bzrdir_branch_reference_shared_force_new_repo(self): |
|
780 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
781 |
referenced_tree = self.make_branch_and_tree('referenced') |
|
782 |
referenced_tree.commit('1', rev_id='1', allow_pointless=True) |
|
783 |
dir = self.make_bzrdir('source') |
|
784 |
try: |
|
785 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
786 |
referenced_tree.branch) |
|
787 |
except errors.IncompatibleFormat: |
|
788 |
# this is ok too, not all formats have to support references.
|
|
789 |
return
|
|
790 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
791 |
try: |
|
792 |
shared_repo = self.make_repository('target', shared=True) |
|
793 |
except errors.IncompatibleFormat: |
|
794 |
return
|
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
795 |
target = self.sproutOrSkip(dir, self.get_url('target/child'), |
796 |
force_new_repo=True) |
|
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
797 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
798 |
# we want target to have a branch that is in-place.
|
|
799 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
800 |
# and we want revision '1' in the new repo
|
|
801 |
self.assertTrue(target.open_repository().has_revision('1')) |
|
802 |
# but not the shared one
|
|
803 |
self.assertFalse(shared_repo.has_revision('1')) |
|
804 |
||
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
805 |
def test_sprout_bzrdir_branch_revision(self): |
806 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
807 |
# make a repository with some revisions,
|
|
808 |
# and sprout it with a revision limit.
|
|
809 |
#
|
|
810 |
tree = self.make_branch_and_tree('commit_tree') |
|
811 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
812 |
tree.add('foo') |
|
813 |
tree.commit('revision 1', rev_id='1') |
|
814 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
815 |
source = self.make_branch('source') |
|
816 |
tree.bzrdir.open_repository().copy_content_into(source.repository) |
|
817 |
tree.bzrdir.open_branch().copy_content_into(source) |
|
818 |
dir = source.bzrdir |
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
819 |
target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='1') |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
820 |
self.assertEqual('1', target.open_branch().last_revision()) |
821 |
||
822 |
def test_sprout_bzrdir_tree_branch_repo(self): |
|
823 |
tree = self.make_branch_and_tree('sourcce') |
|
824 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
825 |
tree.add('foo') |
|
826 |
tree.commit('revision 1') |
|
827 |
dir = tree.bzrdir |
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
828 |
target = self.sproutOrSkip(dir, self.get_url('target')) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
829 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
830 |
self.assertDirectoriesEqual(dir.root_transport, target.root_transport, |
|
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
831 |
[
|
832 |
'./.bzr/branch/branch.conf', |
|
833 |
'./.bzr/branch/parent', |
|
|
2255.10.9
by John Arbash Meinel
one more test that needs to ignore dirstate |
834 |
'./.bzr/checkout/dirstate', |
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
835 |
'./.bzr/checkout/stat-cache', |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
836 |
'./.bzr/checkout/inventory', |
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
837 |
'./.bzr/inventory', |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
838 |
'./.bzr/parent', |
|
1666.1.16
by Robert Collins
Fix occasional test failuresin bzrdir_implementations. |
839 |
'./.bzr/repository/inventory.knit', |
|
2230.3.15
by Aaron Bentley
assertDirectoriesEqual detects missing source, tests handle Branch6 |
840 |
'./.bzr/stat-cache', |
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
841 |
])
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
842 |
|
843 |
def test_sprout_bzrdir_tree_branch_reference(self): |
|
844 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
845 |
# the tree state should not be copied.
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
846 |
referenced_branch = self.make_branch('referencced') |
847 |
dir = self.make_bzrdir('source') |
|
848 |
try: |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
849 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
850 |
referenced_branch) |
851 |
except errors.IncompatibleFormat: |
|
852 |
# this is ok too, not all formats have to support references.
|
|
853 |
return
|
|
854 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
|
1910.4.13
by Andrew Bennetts
Slightly more consistent names. |
855 |
tree = self.createWorkingTreeOrSkip(dir) |
|
2381.1.3
by Robert Collins
Review feedback. |
856 |
self.build_tree(['source/subdir/']) |
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
857 |
tree.add('subdir') |
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
858 |
target = self.sproutOrSkip(dir, self.get_url('target')) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
859 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
860 |
# we want target to have a branch that is in-place.
|
|
861 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
862 |
# and as we dont support repositories being detached yet, a repo in
|
|
863 |
# place
|
|
864 |
target.open_repository() |
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
865 |
result_tree = target.open_workingtree() |
866 |
self.assertFalse(result_tree.has_filename('subdir')) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
867 |
|
868 |
def test_sprout_bzrdir_tree_branch_reference_revision(self): |
|
869 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
870 |
# the tree state should not be copied but the revision changed,
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
871 |
# and the likewise the new branch should be truncated too
|
872 |
referenced_branch = self.make_branch('referencced') |
|
873 |
dir = self.make_bzrdir('source') |
|
874 |
try: |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
875 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
876 |
referenced_branch) |
877 |
except errors.IncompatibleFormat: |
|
878 |
# this is ok too, not all formats have to support references.
|
|
879 |
return
|
|
880 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
|
1910.4.13
by Andrew Bennetts
Slightly more consistent names. |
881 |
tree = self.createWorkingTreeOrSkip(dir) |
|
2381.1.3
by Robert Collins
Review feedback. |
882 |
self.build_tree(['source/foo']) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
883 |
tree.add('foo') |
884 |
tree.commit('revision 1', rev_id='1') |
|
885 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
886 |
target = dir.sprout(self.get_url('target'), revision_id='1') |
|
|
1910.4.12
by Andrew Bennetts
Use camelCase for test helpers to be more consistent unittest naming. |
887 |
self.skipIfNoWorkingTree(target) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
888 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
889 |
# we want target to have a branch that is in-place.
|
|
890 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
891 |
# and as we dont support repositories being detached yet, a repo in
|
|
892 |
# place
|
|
893 |
target.open_repository() |
|
894 |
# we trust that the working tree sprouting works via the other tests.
|
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
895 |
self.assertEqual(['1'], target.open_workingtree().get_parent_ids()) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
896 |
self.assertEqual('1', target.open_branch().last_revision()) |
897 |
||
898 |
def test_sprout_bzrdir_tree_revision(self): |
|
899 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
900 |
# make a tree with a revision with a last-revision
|
|
901 |
# and sprout it with a revision limit.
|
|
902 |
# This smoke test just checks the revision-id is right. Tree specific
|
|
903 |
# tests will check corner cases.
|
|
904 |
tree = self.make_branch_and_tree('source') |
|
|
2381.1.3
by Robert Collins
Review feedback. |
905 |
self.build_tree(['source/foo']) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
906 |
tree.add('foo') |
907 |
tree.commit('revision 1', rev_id='1') |
|
908 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
909 |
dir = tree.bzrdir |
|
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
910 |
target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='1') |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
911 |
self.assertEqual(['1'], target.open_workingtree().get_parent_ids()) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
912 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
913 |
def test_format_initialize_find_open(self): |
914 |
# loopback test to check the current format initializes to itself.
|
|
915 |
if not self.bzrdir_format.is_supported(): |
|
916 |
# unsupported formats are not loopback testable
|
|
917 |
# because the default open will not open them and
|
|
918 |
# they may not be initializable.
|
|
919 |
return
|
|
920 |
# supported formats must be able to init and open
|
|
921 |
t = get_transport(self.get_url()) |
|
922 |
readonly_t = get_transport(self.get_readonly_url()) |
|
923 |
made_control = self.bzrdir_format.initialize(t.base) |
|
924 |
self.failUnless(isinstance(made_control, bzrdir.BzrDir)) |
|
925 |
self.assertEqual(self.bzrdir_format, |
|
926 |
bzrdir.BzrDirFormat.find_format(readonly_t)) |
|
927 |
direct_opened_dir = self.bzrdir_format.open(readonly_t) |
|
928 |
opened_dir = bzrdir.BzrDir.open(t.base) |
|
929 |
self.assertEqual(made_control._format, |
|
930 |
opened_dir._format) |
|
931 |
self.assertEqual(direct_opened_dir._format, |
|
932 |
opened_dir._format) |
|
933 |
self.failUnless(isinstance(opened_dir, bzrdir.BzrDir)) |
|
934 |
||
935 |
def test_open_not_bzrdir(self): |
|
936 |
# test the formats specific behaviour for no-content or similar dirs.
|
|
937 |
self.assertRaises(NotBranchError, |
|
938 |
self.bzrdir_format.open, |
|
939 |
get_transport(self.get_readonly_url())) |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
940 |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
941 |
def test_create_branch(self): |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
942 |
# a bzrdir can construct a branch and repository for itself.
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
943 |
if not self.bzrdir_format.is_supported(): |
944 |
# unsupported formats are not loopback testable
|
|
945 |
# because the default open will not open them and
|
|
946 |
# they may not be initializable.
|
|
947 |
return
|
|
948 |
t = get_transport(self.get_url()) |
|
949 |
made_control = self.bzrdir_format.initialize(t.base) |
|
950 |
made_repo = made_control.create_repository() |
|
951 |
made_branch = made_control.create_branch() |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
952 |
self.failUnless(isinstance(made_branch, bzrlib.branch.Branch)) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
953 |
self.assertEqual(made_control, made_branch.bzrdir) |
954 |
||
955 |
def test_open_branch(self): |
|
956 |
if not self.bzrdir_format.is_supported(): |
|
957 |
# unsupported formats are not loopback testable
|
|
958 |
# because the default open will not open them and
|
|
959 |
# they may not be initializable.
|
|
960 |
return
|
|
961 |
t = get_transport(self.get_url()) |
|
962 |
made_control = self.bzrdir_format.initialize(t.base) |
|
963 |
made_repo = made_control.create_repository() |
|
964 |
made_branch = made_control.create_branch() |
|
965 |
opened_branch = made_control.open_branch() |
|
966 |
self.assertEqual(made_control, opened_branch.bzrdir) |
|
967 |
self.failUnless(isinstance(opened_branch, made_branch.__class__)) |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
968 |
self.failUnless(isinstance(opened_branch._format, made_branch._format.__class__)) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
969 |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
970 |
def test_create_repository(self): |
971 |
# a bzrdir can construct a repository for itself.
|
|
972 |
if not self.bzrdir_format.is_supported(): |
|
973 |
# unsupported formats are not loopback testable
|
|
974 |
# because the default open will not open them and
|
|
975 |
# they may not be initializable.
|
|
976 |
return
|
|
977 |
t = get_transport(self.get_url()) |
|
978 |
made_control = self.bzrdir_format.initialize(t.base) |
|
979 |
made_repo = made_control.create_repository() |
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
980 |
# Check that we have a repository object.
|
981 |
made_repo.has_revision('foo') |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
982 |
self.assertEqual(made_control, made_repo.bzrdir) |
|
1841.2.2
by Jelmer Vernooij
Add more tests for create_repository(). |
983 |
|
984 |
def test_create_repository_shared(self): |
|
985 |
# a bzrdir can create a shared repository or
|
|
986 |
# fail appropriately
|
|
987 |
if not self.bzrdir_format.is_supported(): |
|
988 |
# unsupported formats are not loopback testable
|
|
989 |
# because the default open will not open them and
|
|
990 |
# they may not be initializable.
|
|
991 |
return
|
|
992 |
t = get_transport(self.get_url()) |
|
993 |
made_control = self.bzrdir_format.initialize(t.base) |
|
994 |
try: |
|
995 |
made_repo = made_control.create_repository(shared=True) |
|
996 |
except errors.IncompatibleFormat: |
|
997 |
# Old bzrdir formats don't support shared repositories
|
|
998 |
# and should raise IncompatibleFormat
|
|
999 |
return
|
|
1000 |
self.assertTrue(made_repo.is_shared()) |
|
1001 |
||
1002 |
def test_create_repository_nonshared(self): |
|
1003 |
# a bzrdir can create a non-shared repository
|
|
1004 |
if not self.bzrdir_format.is_supported(): |
|
1005 |
# unsupported formats are not loopback testable
|
|
1006 |
# because the default open will not open them and
|
|
1007 |
# they may not be initializable.
|
|
1008 |
return
|
|
1009 |
t = get_transport(self.get_url()) |
|
1010 |
made_control = self.bzrdir_format.initialize(t.base) |
|
1011 |
made_repo = made_control.create_repository(shared=False) |
|
1012 |
self.assertFalse(made_repo.is_shared()) |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1013 |
|
1014 |
def test_open_repository(self): |
|
1015 |
if not self.bzrdir_format.is_supported(): |
|
1016 |
# unsupported formats are not loopback testable
|
|
1017 |
# because the default open will not open them and
|
|
1018 |
# they may not be initializable.
|
|
1019 |
return
|
|
1020 |
t = get_transport(self.get_url()) |
|
1021 |
made_control = self.bzrdir_format.initialize(t.base) |
|
1022 |
made_repo = made_control.create_repository() |
|
1023 |
opened_repo = made_control.open_repository() |
|
1024 |
self.assertEqual(made_control, opened_repo.bzrdir) |
|
1025 |
self.failUnless(isinstance(opened_repo, made_repo.__class__)) |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1026 |
self.failUnless(isinstance(opened_repo._format, made_repo._format.__class__)) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1027 |
|
1028 |
def test_create_workingtree(self): |
|
1029 |
# a bzrdir can construct a working tree for itself.
|
|
1030 |
if not self.bzrdir_format.is_supported(): |
|
1031 |
# unsupported formats are not loopback testable
|
|
1032 |
# because the default open will not open them and
|
|
1033 |
# they may not be initializable.
|
|
1034 |
return
|
|
|
1910.5.1
by Andrew Bennetts
Make some old formats create at least a stub working tree rather than incomplete bzrdirs, and change some tests to use the test suite transport rather than hard-coded to local-only. |
1035 |
t = self.get_transport() |
|
1910.5.9
by Andrew Bennetts
Move stuff out of a try block that doesn't need to be there. |
1036 |
made_control = self.bzrdir_format.initialize(t.base) |
1037 |
made_repo = made_control.create_repository() |
|
1038 |
made_branch = made_control.create_branch() |
|
|
1910.5.11
by Andrew Bennetts
Use createWorkingTreeOrSkip helper in test_create_workingtree. |
1039 |
made_tree = self.createWorkingTreeOrSkip(made_control) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1040 |
self.failUnless(isinstance(made_tree, workingtree.WorkingTree)) |
1041 |
self.assertEqual(made_control, made_tree.bzrdir) |
|
1042 |
||
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1043 |
def test_create_workingtree_revision(self): |
1044 |
# a bzrdir can construct a working tree for itself @ a specific revision.
|
|
|
1910.5.1
by Andrew Bennetts
Make some old formats create at least a stub working tree rather than incomplete bzrdirs, and change some tests to use the test suite transport rather than hard-coded to local-only. |
1045 |
t = self.get_transport() |
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1046 |
source = self.make_branch_and_tree('source') |
1047 |
source.commit('a', rev_id='a', allow_pointless=True) |
|
1048 |
source.commit('b', rev_id='b', allow_pointless=True) |
|
1049 |
self.build_tree(['new/']) |
|
|
1910.5.1
by Andrew Bennetts
Make some old formats create at least a stub working tree rather than incomplete bzrdirs, and change some tests to use the test suite transport rather than hard-coded to local-only. |
1050 |
t_new = t.clone('new') |
1051 |
made_control = self.bzrdir_format.initialize_on_transport(t_new) |
|
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1052 |
source.branch.repository.clone(made_control) |
1053 |
source.branch.clone(made_control) |
|
|
1910.5.1
by Andrew Bennetts
Make some old formats create at least a stub working tree rather than incomplete bzrdirs, and change some tests to use the test suite transport rather than hard-coded to local-only. |
1054 |
try: |
1055 |
made_tree = made_control.create_workingtree(revision_id='a') |
|
1056 |
except errors.NotLocalUrl: |
|
1057 |
raise TestSkipped("Can't make working tree on transport %r" % t) |
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
1058 |
self.assertEqual(['a'], made_tree.get_parent_ids()) |
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1059 |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1060 |
def test_open_workingtree(self): |
1061 |
if not self.bzrdir_format.is_supported(): |
|
1062 |
# unsupported formats are not loopback testable
|
|
1063 |
# because the default open will not open them and
|
|
1064 |
# they may not be initializable.
|
|
1065 |
return
|
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
1066 |
# this has to be tested with local access as we still support creating
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1067 |
# format 6 bzrdirs
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
1068 |
t = self.get_transport() |
1069 |
try: |
|
1070 |
made_control = self.bzrdir_format.initialize(t.base) |
|
1071 |
made_repo = made_control.create_repository() |
|
1072 |
made_branch = made_control.create_branch() |
|
1073 |
made_tree = made_control.create_workingtree() |
|
1074 |
except errors.NotLocalUrl: |
|
1075 |
raise TestSkipped("Can't initialize %r on transport %r" |
|
1076 |
% (self.bzrdir_format, t)) |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1077 |
opened_tree = made_control.open_workingtree() |
1078 |
self.assertEqual(made_control, opened_tree.bzrdir) |
|
1079 |
self.failUnless(isinstance(opened_tree, made_tree.__class__)) |
|
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1080 |
self.failUnless(isinstance(opened_tree._format, made_tree._format.__class__)) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1081 |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1082 |
def test_get_branch_transport(self): |
1083 |
dir = self.make_bzrdir('.') |
|
1084 |
# without a format, get_branch_transport gives use a transport
|
|
1085 |
# which -may- point to an existing dir.
|
|
1086 |
self.assertTrue(isinstance(dir.get_branch_transport(None), |
|
1087 |
transport.Transport)) |
|
1088 |
# with a given format, either the bzr dir supports identifiable
|
|
1089 |
# branches, or it supports anonymous branch formats, but not both.
|
|
|
1508.1.25
by Robert Collins
Update per review comments. |
1090 |
anonymous_format = bzrlib.branch.BzrBranchFormat4() |
1091 |
identifiable_format = bzrlib.branch.BzrBranchFormat5() |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1092 |
try: |
1093 |
found_transport = dir.get_branch_transport(anonymous_format) |
|
1094 |
self.assertRaises(errors.IncompatibleFormat, |
|
1095 |
dir.get_branch_transport, |
|
1096 |
identifiable_format) |
|
1097 |
except errors.IncompatibleFormat: |
|
1098 |
found_transport = dir.get_branch_transport(identifiable_format) |
|
1099 |
self.assertTrue(isinstance(found_transport, transport.Transport)) |
|
|
1910.4.1
by Andrew Bennetts
Clearer comment and more precise test for directory existence in test_get_branch_transport. |
1100 |
# and the dir which has been initialized for us must exist.
|
1101 |
found_transport.list_dir('.') |
|
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
1102 |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1103 |
def test_get_repository_transport(self): |
1104 |
dir = self.make_bzrdir('.') |
|
1105 |
# without a format, get_repository_transport gives use a transport
|
|
1106 |
# which -may- point to an existing dir.
|
|
1107 |
self.assertTrue(isinstance(dir.get_repository_transport(None), |
|
1108 |
transport.Transport)) |
|
1109 |
# with a given format, either the bzr dir supports identifiable
|
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1110 |
# repositories, or it supports anonymous repository formats, but not both.
|
1111 |
anonymous_format = weaverepo.RepositoryFormat6() |
|
1112 |
identifiable_format = weaverepo.RepositoryFormat7() |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1113 |
try: |
1114 |
found_transport = dir.get_repository_transport(anonymous_format) |
|
1115 |
self.assertRaises(errors.IncompatibleFormat, |
|
1116 |
dir.get_repository_transport, |
|
1117 |
identifiable_format) |
|
1118 |
except errors.IncompatibleFormat: |
|
1119 |
found_transport = dir.get_repository_transport(identifiable_format) |
|
1120 |
self.assertTrue(isinstance(found_transport, transport.Transport)) |
|
|
1910.4.2
by Andrew Bennetts
Clearer comment and more precise test for directory existence in test_get_*_transport. |
1121 |
# and the dir which has been initialized for us must exist.
|
1122 |
found_transport.list_dir('.') |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1123 |
|
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
1124 |
def test_get_workingtree_transport(self): |
1125 |
dir = self.make_bzrdir('.') |
|
1126 |
# without a format, get_workingtree_transport gives use a transport
|
|
1127 |
# which -may- point to an existing dir.
|
|
1128 |
self.assertTrue(isinstance(dir.get_workingtree_transport(None), |
|
1129 |
transport.Transport)) |
|
1130 |
# with a given format, either the bzr dir supports identifiable
|
|
1131 |
# trees, or it supports anonymous tree formats, but not both.
|
|
1132 |
anonymous_format = workingtree.WorkingTreeFormat2() |
|
1133 |
identifiable_format = workingtree.WorkingTreeFormat3() |
|
1134 |
try: |
|
1135 |
found_transport = dir.get_workingtree_transport(anonymous_format) |
|
1136 |
self.assertRaises(errors.IncompatibleFormat, |
|
1137 |
dir.get_workingtree_transport, |
|
1138 |
identifiable_format) |
|
1139 |
except errors.IncompatibleFormat: |
|
1140 |
found_transport = dir.get_workingtree_transport(identifiable_format) |
|
1141 |
self.assertTrue(isinstance(found_transport, transport.Transport)) |
|
|
1910.4.2
by Andrew Bennetts
Clearer comment and more precise test for directory existence in test_get_*_transport. |
1142 |
# and the dir which has been initialized for us must exist.
|
1143 |
found_transport.list_dir('.') |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
1144 |
|
1145 |
def test_root_transport(self): |
|
1146 |
dir = self.make_bzrdir('.') |
|
1147 |
self.assertEqual(dir.root_transport.base, |
|
1148 |
get_transport(self.get_url('.')).base) |
|
1149 |
||
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
1150 |
def test_find_repository_no_repo_under_standalone_branch(self): |
1151 |
# finding a repo stops at standalone branches even if there is a
|
|
1152 |
# higher repository available.
|
|
1153 |
try: |
|
1154 |
repo = self.make_repository('.', shared=True) |
|
1155 |
except errors.IncompatibleFormat: |
|
1156 |
# need a shared repository to test this.
|
|
1157 |
return
|
|
1158 |
url = self.get_url('intermediate') |
|
1159 |
get_transport(self.get_url()).mkdir('intermediate') |
|
1160 |
get_transport(self.get_url()).mkdir('intermediate/child') |
|
1161 |
made_control = self.bzrdir_format.initialize(url) |
|
1162 |
made_control.create_repository() |
|
1163 |
innermost_control = self.bzrdir_format.initialize( |
|
1164 |
self.get_url('intermediate/child')) |
|
1165 |
try: |
|
1166 |
child_repo = innermost_control.open_repository() |
|
1167 |
# if there is a repository, then the format cannot ever hit this
|
|
1168 |
# code path.
|
|
1169 |
return
|
|
1170 |
except errors.NoRepositoryPresent: |
|
1171 |
pass
|
|
1172 |
self.assertRaises(errors.NoRepositoryPresent, |
|
1173 |
innermost_control.find_repository) |
|
1174 |
||
1175 |
def test_find_repository_containing_shared_repository(self): |
|
1176 |
# find repo inside a shared repo with an empty control dir
|
|
1177 |
# returns the shared repo.
|
|
1178 |
try: |
|
1179 |
repo = self.make_repository('.', shared=True) |
|
1180 |
except errors.IncompatibleFormat: |
|
1181 |
# need a shared repository to test this.
|
|
1182 |
return
|
|
1183 |
url = self.get_url('childbzrdir') |
|
1184 |
get_transport(self.get_url()).mkdir('childbzrdir') |
|
1185 |
made_control = self.bzrdir_format.initialize(url) |
|
1186 |
try: |
|
1187 |
child_repo = made_control.open_repository() |
|
1188 |
# if there is a repository, then the format cannot ever hit this
|
|
1189 |
# code path.
|
|
1190 |
return
|
|
1191 |
except errors.NoRepositoryPresent: |
|
1192 |
pass
|
|
1193 |
found_repo = made_control.find_repository() |
|
1194 |
self.assertEqual(repo.bzrdir.root_transport.base, |
|
1195 |
found_repo.bzrdir.root_transport.base) |
|
1196 |
||
1197 |
def test_find_repository_standalone_with_containing_shared_repository(self): |
|
1198 |
# find repo inside a standalone repo inside a shared repo finds the standalone repo
|
|
1199 |
try: |
|
1200 |
containing_repo = self.make_repository('.', shared=True) |
|
1201 |
except errors.IncompatibleFormat: |
|
1202 |
# need a shared repository to test this.
|
|
1203 |
return
|
|
1204 |
child_repo = self.make_repository('childrepo') |
|
1205 |
opened_control = bzrdir.BzrDir.open(self.get_url('childrepo')) |
|
1206 |
found_repo = opened_control.find_repository() |
|
1207 |
self.assertEqual(child_repo.bzrdir.root_transport.base, |
|
1208 |
found_repo.bzrdir.root_transport.base) |
|
1209 |
||
1210 |
def test_find_repository_shared_within_shared_repository(self): |
|
1211 |
# find repo at a shared repo inside a shared repo finds the inner repo
|
|
1212 |
try: |
|
1213 |
containing_repo = self.make_repository('.', shared=True) |
|
1214 |
except errors.IncompatibleFormat: |
|
1215 |
# need a shared repository to test this.
|
|
1216 |
return
|
|
1217 |
url = self.get_url('childrepo') |
|
1218 |
get_transport(self.get_url()).mkdir('childrepo') |
|
1219 |
child_control = self.bzrdir_format.initialize(url) |
|
1220 |
child_repo = child_control.create_repository(shared=True) |
|
1221 |
opened_control = bzrdir.BzrDir.open(self.get_url('childrepo')) |
|
1222 |
found_repo = opened_control.find_repository() |
|
1223 |
self.assertEqual(child_repo.bzrdir.root_transport.base, |
|
1224 |
found_repo.bzrdir.root_transport.base) |
|
1225 |
self.assertNotEqual(child_repo.bzrdir.root_transport.base, |
|
1226 |
containing_repo.bzrdir.root_transport.base) |
|
1227 |
||
1228 |
def test_find_repository_with_nested_dirs_works(self): |
|
1229 |
# find repo inside a bzrdir inside a bzrdir inside a shared repo
|
|
1230 |
# finds the outer shared repo.
|
|
1231 |
try: |
|
1232 |
repo = self.make_repository('.', shared=True) |
|
1233 |
except errors.IncompatibleFormat: |
|
1234 |
# need a shared repository to test this.
|
|
1235 |
return
|
|
1236 |
url = self.get_url('intermediate') |
|
1237 |
get_transport(self.get_url()).mkdir('intermediate') |
|
1238 |
get_transport(self.get_url()).mkdir('intermediate/child') |
|
1239 |
made_control = self.bzrdir_format.initialize(url) |
|
1240 |
try: |
|
1241 |
child_repo = made_control.open_repository() |
|
1242 |
# if there is a repository, then the format cannot ever hit this
|
|
1243 |
# code path.
|
|
1244 |
return
|
|
1245 |
except errors.NoRepositoryPresent: |
|
1246 |
pass
|
|
1247 |
innermost_control = self.bzrdir_format.initialize( |
|
1248 |
self.get_url('intermediate/child')) |
|
1249 |
try: |
|
1250 |
child_repo = innermost_control.open_repository() |
|
1251 |
# if there is a repository, then the format cannot ever hit this
|
|
1252 |
# code path.
|
|
1253 |
return
|
|
1254 |
except errors.NoRepositoryPresent: |
|
1255 |
pass
|
|
1256 |
found_repo = innermost_control.find_repository() |
|
1257 |
self.assertEqual(repo.bzrdir.root_transport.base, |
|
1258 |
found_repo.bzrdir.root_transport.base) |
|
1259 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1260 |
def test_can_and_needs_format_conversion(self): |
|
1534.5.8
by Robert Collins
Ensure that bzrdir implementations offer the can_update_format and needs_format_update api. |
1261 |
# check that we can ask an instance if its upgradable
|
1262 |
dir = self.make_bzrdir('.') |
|
|
1534.5.16
by Robert Collins
Review feedback. |
1263 |
if dir.can_convert_format(): |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1264 |
# if its default updatable there must be an updater
|
|
2204.4.14
by Aaron Bentley
lastest -> latest |
1265 |
# (we force the latest known format as downgrades may not be
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
1266 |
# available
|
1267 |
self.assertTrue(isinstance(dir._format.get_converter( |
|
1268 |
format=dir._format), bzrdir.Converter)) |
|
|
1534.5.16
by Robert Collins
Review feedback. |
1269 |
dir.needs_format_conversion(None) |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
1270 |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
1271 |
def test_upgrade_new_instance(self): |
|
1910.4.9
by Andrew Bennetts
Skip test_upgrade_new_instance if we don't have a local transport, and cosmetic tweaks. |
1272 |
"""Does an available updater work?""" |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
1273 |
dir = self.make_bzrdir('.') |
|
1910.4.9
by Andrew Bennetts
Skip test_upgrade_new_instance if we don't have a local transport, and cosmetic tweaks. |
1274 |
# for now, upgrade is not ready for partial bzrdirs.
|
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1275 |
dir.create_repository() |
1276 |
dir.create_branch() |
|
|
1910.4.13
by Andrew Bennetts
Slightly more consistent names. |
1277 |
self.createWorkingTreeOrSkip(dir) |
|
1534.5.16
by Robert Collins
Review feedback. |
1278 |
if dir.can_convert_format(): |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1279 |
# if its default updatable there must be an updater
|
|
2204.4.14
by Aaron Bentley
lastest -> latest |
1280 |
# (we force the latest known format as downgrades may not be
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
1281 |
# available
|
|
1594.1.3
by Robert Collins
Fixup pb usage to use nested_progress_bar. |
1282 |
pb = ui.ui_factory.nested_progress_bar() |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1283 |
try: |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
1284 |
dir._format.get_converter(format=dir._format).convert(dir, pb) |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1285 |
finally: |
|
1594.1.3
by Robert Collins
Fixup pb usage to use nested_progress_bar. |
1286 |
pb.finished() |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
1287 |
# and it should pass 'check' now.
|
1288 |
check(bzrdir.BzrDir.open(self.get_url('.')).open_branch(), False) |
|
1289 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1290 |
def test_format_description(self): |
1291 |
dir = self.make_bzrdir('.') |
|
1292 |
text = dir._format.get_format_description() |
|
1293 |
self.failUnless(len(text)) |
|
1294 |
||
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
1295 |
def test_retire_bzrdir(self): |
1296 |
bd = self.make_bzrdir('.') |
|
1297 |
# must not overwrite existing directories
|
|
1298 |
self.build_tree(['.bzr.retired.0/', '.bzr.retired.0/junk',]) |
|
1299 |
self.failUnlessExists('.bzr') |
|
1300 |
bd.retire_bzrdir() |
|
1301 |
self.failIfExists('.bzr') |
|
1302 |
self.failUnlessExists('.bzr.retired.1') |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
1303 |
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1304 |
class TestBreakLock(TestCaseWithBzrDir): |
1305 |
||
1306 |
def setUp(self): |
|
1307 |
super(TestBreakLock, self).setUp() |
|
1308 |
# we want a UI factory that accepts canned input for the tests:
|
|
1309 |
# while SilentUIFactory still accepts stdin, we need to customise
|
|
1310 |
# ours
|
|
1311 |
self.old_factory = bzrlib.ui.ui_factory |
|
|
1687.1.15
by Robert Collins
Review comments. |
1312 |
self.addCleanup(self.restoreFactory) |
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1313 |
bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory() |
1314 |
||
|
1687.1.15
by Robert Collins
Review comments. |
1315 |
def restoreFactory(self): |
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1316 |
bzrlib.ui.ui_factory = self.old_factory |
1317 |
||
1318 |
def test_break_lock_empty(self): |
|
1319 |
# break lock on an empty bzrdir should work silently.
|
|
1320 |
dir = self.make_bzrdir('.') |
|
1321 |
try: |
|
1322 |
dir.break_lock() |
|
1323 |
except NotImplementedError: |
|
1324 |
pass
|
|
1325 |
||
1326 |
def test_break_lock_repository(self): |
|
1327 |
# break lock with just a repo should unlock the repo.
|
|
1328 |
repo = self.make_repository('.') |
|
1329 |
repo.lock_write() |
|
1330 |
# only one yes needed here: it should only be unlocking
|
|
1331 |
# the repo
|
|
1332 |
bzrlib.ui.ui_factory.stdin = StringIO("y\n") |
|
1333 |
try: |
|
1334 |
repo.bzrdir.break_lock() |
|
1335 |
except NotImplementedError: |
|
1336 |
# this bzrdir does not implement break_lock - so we cant test it.
|
|
1337 |
repo.unlock() |
|
1338 |
return
|
|
1339 |
lock_repo = repo.bzrdir.open_repository() |
|
1340 |
lock_repo.lock_write() |
|
1341 |
lock_repo.unlock() |
|
1342 |
self.assertRaises(errors.LockBroken, repo.unlock) |
|
1343 |
||
1344 |
def test_break_lock_branch(self): |
|
1345 |
# break lock with just a repo should unlock the branch.
|
|
1346 |
# and not directly try the repository.
|
|
1347 |
# we test this by making a branch reference to a branch
|
|
1348 |
# and repository in another bzrdir
|
|
1349 |
# for pre-metadir formats this will fail, thats ok.
|
|
1350 |
master = self.make_branch('branch') |
|
1351 |
thisdir = self.make_bzrdir('this') |
|
1352 |
try: |
|
1353 |
bzrlib.branch.BranchReferenceFormat().initialize( |
|
1354 |
thisdir, master) |
|
1355 |
except errors.IncompatibleFormat: |
|
1356 |
return
|
|
1357 |
unused_repo = thisdir.create_repository() |
|
1358 |
master.lock_write() |
|
1359 |
unused_repo.lock_write() |
|
|
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
1360 |
try: |
1361 |
# two yes's : branch and repository. If the repo in this
|
|
1362 |
# dir is inappropriately accessed, 3 will be needed, and
|
|
1363 |
# we'll see that because the stream will be fully consumed
|
|
1364 |
bzrlib.ui.ui_factory.stdin = StringIO("y\ny\ny\n") |
|
1365 |
master.bzrdir.break_lock() |
|
1366 |
# only two ys should have been read
|
|
1367 |
self.assertEqual("y\n", bzrlib.ui.ui_factory.stdin.read()) |
|
1368 |
# we should be able to lock a newly opened branch now
|
|
1369 |
branch = master.bzrdir.open_branch() |
|
1370 |
branch.lock_write() |
|
1371 |
branch.unlock() |
|
1372 |
# we should not be able to lock the repository in thisdir as its still
|
|
1373 |
# held by the explicit lock we took, and the break lock should not have
|
|
1374 |
# touched it.
|
|
1375 |
repo = thisdir.open_repository() |
|
1376 |
orig_default = lockdir._DEFAULT_TIMEOUT_SECONDS |
|
1377 |
try: |
|
1378 |
lockdir._DEFAULT_TIMEOUT_SECONDS = 1 |
|
1379 |
self.assertRaises(errors.LockContention, repo.lock_write) |
|
1380 |
finally: |
|
1381 |
lockdir._DEFAULT_TIMEOUT_SECONDS = orig_default |
|
1382 |
finally: |
|
1383 |
unused_repo.unlock() |
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1384 |
self.assertRaises(errors.LockBroken, master.unlock) |
1385 |
||
1386 |
def test_break_lock_tree(self): |
|
1387 |
# break lock with a tree should unlock the tree but not try the
|
|
1388 |
# branch explicitly. However this is very hard to test for as we
|
|
1389 |
# dont have a tree reference class, nor is one needed;
|
|
1390 |
# the worst case if this code unlocks twice is an extra question
|
|
1391 |
# being asked.
|
|
1392 |
tree = self.make_branch_and_tree('.') |
|
1393 |
tree.lock_write() |
|
1394 |
# three yes's : tree, branch and repository.
|
|
1395 |
bzrlib.ui.ui_factory.stdin = StringIO("y\ny\ny\ny\n") |
|
1396 |
try: |
|
1397 |
tree.bzrdir.break_lock() |
|
|
2255.2.145
by Robert Collins
Support unbreakable locks for trees. |
1398 |
except (NotImplementedError, errors.LockActive): |
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1399 |
# bzrdir does not support break_lock
|
|
2255.2.145
by Robert Collins
Support unbreakable locks for trees. |
1400 |
# or one of the locked objects (currently only tree does this)
|
1401 |
# raised a LockActive because we do still have a live locked
|
|
1402 |
# object.
|
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1403 |
tree.unlock() |
1404 |
return
|
|
1405 |
self.assertEqual("y\n", bzrlib.ui.ui_factory.stdin.read()) |
|
1406 |
lock_tree = tree.bzrdir.open_workingtree() |
|
1407 |
lock_tree.lock_write() |
|
1408 |
lock_tree.unlock() |
|
1409 |
self.assertRaises(errors.LockBroken, tree.unlock) |
|
1410 |
||
1411 |
||
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
1412 |
class ChrootedBzrDirTests(ChrootedTestCase): |
1413 |
||
1414 |
def test_find_repository_no_repository(self): |
|
1415 |
# loopback test to check the current format fails to find a
|
|
1416 |
# share repository correctly.
|
|
1417 |
if not self.bzrdir_format.is_supported(): |
|
1418 |
# unsupported formats are not loopback testable
|
|
1419 |
# because the default open will not open them and
|
|
1420 |
# they may not be initializable.
|
|
1421 |
return
|
|
1422 |
# supported formats must be able to init and open
|
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
1423 |
# - do the vfs initialisation over the basic vfs transport
|
1424 |
# XXX: TODO this should become a 'bzrdirlocation' api call.
|
|
1425 |
url = self.get_vfs_only_url('subdir') |
|
1426 |
get_transport(self.get_vfs_only_url()).mkdir('subdir') |
|
1427 |
made_control = self.bzrdir_format.initialize(self.get_url('subdir')) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
1428 |
try: |
1429 |
repo = made_control.open_repository() |
|
1430 |
# if there is a repository, then the format cannot ever hit this
|
|
1431 |
# code path.
|
|
1432 |
return
|
|
1433 |
except errors.NoRepositoryPresent: |
|
1434 |
pass
|
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
1435 |
made_control = bzrdir.BzrDir.open(self.get_readonly_url('subdir')) |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
1436 |
self.assertRaises(errors.NoRepositoryPresent, |
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
1437 |
made_control.find_repository) |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
1438 |