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