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