5557.1.7
by John Arbash Meinel
Merge in the bzr.dev 5582 |
1 |
# Copyright (C) 2006-2011 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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
16 |
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
17 |
"""Tests for control directory implementations - tests a controldir format."""
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
18 |
|
3015.2.2
by Robert Collins
Make test_bzrdir work with packs - which always change the pack value during clone. |
19 |
from itertools import izip |
1534.4.39
by Robert Collins
Basic BzrDir support. |
20 |
|
1508.1.25
by Robert Collins
Update per review comments. |
21 |
import bzrlib.branch |
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
22 |
from bzrlib import ( |
23 |
bzrdir, |
|
4332.3.36
by Robert Collins
Silence a warning in test_bzrdir. |
24 |
check, |
5363.2.3
by Jelmer Vernooij
Add ControlDirFormat. |
25 |
controldir, |
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
26 |
errors, |
4695.2.2
by Vincent Ladeuil
There is no good reason for not writing a test. |
27 |
gpg, |
3872.3.3
by Jelmer Vernooij
Add test for backup_bzrdir. |
28 |
osutils, |
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
29 |
transport, |
30 |
ui, |
|
3872.3.3
by Jelmer Vernooij
Add test for backup_bzrdir. |
31 |
urlutils, |
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
32 |
workingtree, |
33 |
)
|
|
1551.8.20
by Aaron Bentley
Fix BzrDir.create_workingtree for NULL_REVISION |
34 |
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. |
35 |
from bzrlib.tests import ( |
5651.5.3
by Andrew Bennetts
Use new fixture in more tests. |
36 |
fixtures, |
5582.9.6
by Jelmer Vernooij
More cleanups, remove more dependencies on specific formats. |
37 |
ChrootedTestCase, |
38 |
TestNotApplicable, |
|
39 |
TestSkipped, |
|
40 |
)
|
|
5363.2.18
by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir. |
41 |
from bzrlib.tests.per_controldir import TestCaseWithControlDir |
2485.8.56
by Vincent Ladeuil
Fix bug #112173 and bzr branch multiple connections. |
42 |
from bzrlib.transport.local import LocalTransport |
4449.3.25
by Martin Pool
Move CannedInputUIFactory to bzrlib.ui for reuse |
43 |
from bzrlib.ui import ( |
44 |
CannedInputUIFactory, |
|
45 |
)
|
|
5582.9.6
by Jelmer Vernooij
More cleanups, remove more dependencies on specific formats. |
46 |
from bzrlib.remote import ( |
47 |
RemoteBzrDir, |
|
5712.3.15
by Jelmer Vernooij
Remove unused register format functions. |
48 |
RemoteBzrDirFormat, |
5582.9.6
by Jelmer Vernooij
More cleanups, remove more dependencies on specific formats. |
49 |
RemoteRepository, |
50 |
)
|
|
5671.3.1
by Jelmer Vernooij
Use stub format for tests in bzrlib.tests.per_controldir.test_controldir.. |
51 |
|
52 |
||
5363.2.22
by Jelmer Vernooij
Provide bzrlib.bzrdir.format_registry. |
53 |
class TestControlDir(TestCaseWithControlDir): |
3015.2.2
by Robert Collins
Make test_bzrdir work with packs - which always change the pack value during clone. |
54 |
|
1910.4.12
by Andrew Bennetts
Use camelCase for test helpers to be more consistent unittest naming. |
55 |
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. |
56 |
"""Raises TestSkipped if a_bzrdir doesn't have a working tree.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
57 |
|
1910.4.11
by Andrew Bennetts
Add 'create_workingtree_or_skip' and 'skip_if_no_workingtree' helper methods to reduce duplicated code. |
58 |
If the bzrdir does have a workingtree, this is a no-op.
|
59 |
"""
|
|
60 |
try: |
|
61 |
a_bzrdir.open_workingtree() |
|
62 |
except (errors.NotLocalUrl, errors.NoWorkingTree): |
|
63 |
raise TestSkipped("bzrdir on transport %r has no working tree" |
|
64 |
% a_bzrdir.transport) |
|
65 |
||
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
66 |
def openWorkingTreeIfLocal(self, a_bzrdir): |
67 |
"""If a_bzrdir is on a local transport, call open_workingtree() on it.
|
|
68 |
"""
|
|
69 |
if not isinstance(a_bzrdir.root_transport, LocalTransport): |
|
70 |
# it's not local, but that's ok
|
|
71 |
return
|
|
72 |
a_bzrdir.open_workingtree() |
|
73 |
||
1910.4.13
by Andrew Bennetts
Slightly more consistent names. |
74 |
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. |
75 |
"""Create a working tree on a_bzrdir, or raise TestSkipped.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
76 |
|
1910.4.11
by Andrew Bennetts
Add 'create_workingtree_or_skip' and 'skip_if_no_workingtree' helper methods to reduce duplicated code. |
77 |
A simple wrapper for create_workingtree that translates NotLocalUrl into
|
78 |
TestSkipped. Returns the newly created working tree.
|
|
79 |
"""
|
|
80 |
try: |
|
81 |
return a_bzrdir.create_workingtree() |
|
5418.3.1
by Jelmer Vernooij
Cope with control directories that are local but can't have working trees. |
82 |
except (errors.NotLocalUrl, errors.UnsupportedOperation): |
1910.4.11
by Andrew Bennetts
Add 'create_workingtree_or_skip' and 'skip_if_no_workingtree' helper methods to reduce duplicated code. |
83 |
raise TestSkipped("cannot make working tree with transport %r" |
84 |
% a_bzrdir.transport) |
|
85 |
||
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
86 |
def sproutOrSkip(self, from_bzrdir, to_url, revision_id=None, |
3983.1.3
by Daniel Watkins
Added test to ensure BzrDirs accept the 'no_tree' argument. |
87 |
force_new_repo=False, accelerator_tree=None, |
3983.1.7
by Daniel Watkins
Review comments from jam. |
88 |
create_tree_if_local=True): |
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
89 |
"""Sprout from_bzrdir into to_url, or raise TestSkipped.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
90 |
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
91 |
A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into
|
92 |
TestSkipped. Returns the newly sprouted bzrdir.
|
|
93 |
"""
|
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
94 |
to_transport = transport.get_transport(to_url) |
2485.8.56
by Vincent Ladeuil
Fix bug #112173 and bzr branch multiple connections. |
95 |
if not isinstance(to_transport, LocalTransport): |
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
96 |
raise TestSkipped('Cannot sprout to remote bzrdirs.') |
2485.8.56
by Vincent Ladeuil
Fix bug #112173 and bzr branch multiple connections. |
97 |
target = from_bzrdir.sprout(to_url, revision_id=revision_id, |
98 |
force_new_repo=force_new_repo, |
|
3123.5.8
by Aaron Bentley
Work around double-opening lock issue |
99 |
possible_transports=[to_transport], |
3983.1.3
by Daniel Watkins
Added test to ensure BzrDirs accept the 'no_tree' argument. |
100 |
accelerator_tree=accelerator_tree, |
3983.1.7
by Daniel Watkins
Review comments from jam. |
101 |
create_tree_if_local=create_tree_if_local) |
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
102 |
return target |
103 |
||
1551.8.20
by Aaron Bentley
Fix BzrDir.create_workingtree for NULL_REVISION |
104 |
def test_create_null_workingtree(self): |
105 |
dir = self.make_bzrdir('dir1') |
|
106 |
dir.create_repository() |
|
107 |
dir.create_branch() |
|
1752.2.87
by Andrew Bennetts
Make tests pass. |
108 |
try: |
109 |
wt = dir.create_workingtree(revision_id=bzrlib.revision.NULL_REVISION) |
|
5418.3.1
by Jelmer Vernooij
Cope with control directories that are local but can't have working trees. |
110 |
except (errors.NotLocalUrl, errors.UnsupportedOperation): |
1752.2.87
by Andrew Bennetts
Make tests pass. |
111 |
raise TestSkipped("cannot make working tree with transport %r" |
112 |
% dir.transport) |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
113 |
self.assertEqual([], wt.get_parent_ids()) |
1551.8.20
by Aaron Bentley
Fix BzrDir.create_workingtree for NULL_REVISION |
114 |
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
115 |
def test_destroy_workingtree(self): |
116 |
tree = self.make_branch_and_tree('tree') |
|
117 |
self.build_tree(['tree/file']) |
|
118 |
tree.add('file') |
|
119 |
tree.commit('first commit') |
|
120 |
bzrdir = tree.bzrdir |
|
121 |
try: |
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
122 |
bzrdir.destroy_workingtree() |
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
123 |
except errors.UnsupportedOperation: |
124 |
raise TestSkipped('Format does not support destroying tree') |
|
125 |
self.failIfExists('tree/file') |
|
126 |
self.assertRaises(errors.NoWorkingTree, bzrdir.open_workingtree) |
|
127 |
bzrdir.create_workingtree() |
|
128 |
self.failUnlessExists('tree/file') |
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
129 |
bzrdir.destroy_workingtree_metadata() |
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
130 |
self.failUnlessExists('tree/file') |
131 |
self.assertRaises(errors.NoWorkingTree, bzrdir.open_workingtree) |
|
2445.1.1
by Andrew Bennetts
Make RemoteBzrDir.open_workingtree raise NoWorkingTree rather than NotLocalUrl |
132 |
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
133 |
def test_destroy_branch(self): |
134 |
branch = self.make_branch('branch') |
|
135 |
bzrdir = branch.bzrdir |
|
136 |
try: |
|
137 |
bzrdir.destroy_branch() |
|
138 |
except (errors.UnsupportedOperation, errors.TransportNotPossible): |
|
5051.3.7
by Jelmer Vernooij
Review comments from Vincent. |
139 |
raise TestNotApplicable('Format does not support destroying branch') |
2796.2.6
by Aaron Bentley
Implement destroy_branch |
140 |
self.assertRaises(errors.NotBranchError, bzrdir.open_branch) |
141 |
bzrdir.create_branch() |
|
142 |
bzrdir.open_branch() |
|
143 |
||
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
144 |
def test_destroy_repository(self): |
145 |
repo = self.make_repository('repository') |
|
146 |
bzrdir = repo.bzrdir |
|
147 |
try: |
|
148 |
bzrdir.destroy_repository() |
|
149 |
except (errors.UnsupportedOperation, errors.TransportNotPossible): |
|
150 |
raise TestNotApplicable('Format does not support destroying' |
|
151 |
' repository') |
|
152 |
self.assertRaises(errors.NoRepositoryPresent, bzrdir.open_repository) |
|
153 |
bzrdir.create_repository() |
|
154 |
bzrdir.open_repository() |
|
155 |
||
2445.1.1
by Andrew Bennetts
Make RemoteBzrDir.open_workingtree raise NoWorkingTree rather than NotLocalUrl |
156 |
def test_open_workingtree_raises_no_working_tree(self): |
5363.2.22
by Jelmer Vernooij
Provide bzrlib.bzrdir.format_registry. |
157 |
"""ControlDir.open_workingtree() should raise NoWorkingTree (rather than
|
2445.1.1
by Andrew Bennetts
Make RemoteBzrDir.open_workingtree raise NoWorkingTree rather than NotLocalUrl |
158 |
e.g. NotLocalUrl) if there is no working tree.
|
159 |
"""
|
|
160 |
dir = self.make_bzrdir('source') |
|
161 |
vfs_dir = bzrdir.BzrDir.open(self.get_vfs_only_url('source')) |
|
162 |
if vfs_dir.has_workingtree(): |
|
5363.2.22
by Jelmer Vernooij
Provide bzrlib.bzrdir.format_registry. |
163 |
# This ControlDir format doesn't support ControlDirs without
|
164 |
# working trees, so this test is irrelevant.
|
|
2445.1.1
by Andrew Bennetts
Make RemoteBzrDir.open_workingtree raise NoWorkingTree rather than NotLocalUrl |
165 |
return
|
166 |
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree) |
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
167 |
|
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. |
168 |
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. |
169 |
tree = self.make_branch_and_tree('commit_tree') |
170 |
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..')) |
|
171 |
tree.add('foo') |
|
172 |
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. |
173 |
dir = self.make_bzrdir('source') |
174 |
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. |
175 |
repo.fetch(tree.branch.repository) |
176 |
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. |
177 |
try: |
178 |
self.make_repository('target', shared=True) |
|
179 |
except errors.IncompatibleFormat: |
|
180 |
return
|
|
181 |
target = dir.clone(self.get_url('target/child')) |
|
182 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
183 |
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. |
184 |
|
185 |
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. |
186 |
# Create a shared repository
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
187 |
try: |
188 |
shared_repo = self.make_repository('shared', shared=True) |
|
189 |
except errors.IncompatibleFormat: |
|
190 |
return
|
|
2018.5.168
by Andrew Bennetts
Add some comments to test_clone_bzrdir_repository_branch_both_under_shared. |
191 |
# Make a branch, 'commit_tree', and working tree outside of the shared
|
192 |
# 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. |
193 |
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. |
194 |
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. |
195 |
tree.add('foo') |
196 |
tree.commit('revision 1', rev_id='1') |
|
197 |
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. |
198 |
tree.set_parent_trees([]) |
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
199 |
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. |
200 |
# Copy the content (i.e. revisions) from the 'commit_tree' branch's
|
201 |
# repository into the shared repository.
|
|
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
202 |
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. |
203 |
# 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. |
204 |
dir = self.make_bzrdir('shared/source') |
205 |
dir.create_branch() |
|
2018.5.168
by Andrew Bennetts
Add some comments to test_clone_bzrdir_repository_branch_both_under_shared. |
206 |
# 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. |
207 |
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. |
208 |
# '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. |
209 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
210 |
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. |
211 |
# The shared repository will contain revisions from the 'commit_tree'
|
212 |
# repository, even revisions that are not part of the history of the
|
|
213 |
# 'commit_tree' branch.
|
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
214 |
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 |
215 |
|
216 |
def test_clone_bzrdir_repository_branch_only_source_under_shared(self): |
|
217 |
try: |
|
218 |
shared_repo = self.make_repository('shared', shared=True) |
|
219 |
except errors.IncompatibleFormat: |
|
220 |
return
|
|
221 |
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. |
222 |
self.build_tree(['commit_tree/foo']) |
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
223 |
tree.add('foo') |
224 |
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. |
225 |
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. |
226 |
tree.set_parent_trees([]) |
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
227 |
tree.commit('revision 2', rev_id='2') |
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
228 |
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. |
229 |
if shared_repo.make_working_trees(): |
230 |
shared_repo.set_make_working_trees(False) |
|
231 |
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 |
232 |
self.assertTrue(shared_repo.has_revision('1')) |
233 |
dir = self.make_bzrdir('shared/source') |
|
234 |
dir.create_branch() |
|
235 |
target = dir.clone(self.get_url('target')) |
|
236 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
237 |
self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base) |
|
238 |
branch = target.open_branch() |
|
239 |
self.assertTrue(branch.repository.has_revision('1')) |
|
240 |
self.assertFalse(branch.repository.make_working_trees()) |
|
241 |
self.assertTrue(branch.repository.is_shared()) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
242 |
|
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. |
243 |
def test_clone_bzrdir_repository_revision(self): |
244 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
245 |
# make a repository with some revisions,
|
|
246 |
# and clone it with a revision limit.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
247 |
#
|
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. |
248 |
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. |
249 |
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. |
250 |
tree.add('foo') |
251 |
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. |
252 |
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. |
253 |
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. |
254 |
tree.commit('revision 2', rev_id='2') |
255 |
source = self.make_repository('source') |
|
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
256 |
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. |
257 |
dir = source.bzrdir |
258 |
target = dir.clone(self.get_url('target'), revision_id='2') |
|
259 |
raise TestSkipped('revision limiting not strict yet') |
|
260 |
||
4695.2.2
by Vincent Ladeuil
There is no good reason for not writing a test. |
261 |
def test_clone_bzrdir_branch_and_repo_fixed_user_id(self): |
262 |
# Bug #430868 is about an email containing '.sig'
|
|
5570.3.9
by Vincent Ladeuil
More use cases for overrideEnv, _cleanEnvironment *may* contain too much variables now. |
263 |
self.overrideEnv('BZR_EMAIL', 'murphy@host.sighup.org') |
4695.2.2
by Vincent Ladeuil
There is no good reason for not writing a test. |
264 |
tree = self.make_branch_and_tree('commit_tree') |
265 |
self.build_tree(['commit_tree/foo']) |
|
266 |
tree.add('foo') |
|
267 |
rev1 = tree.commit('revision 1') |
|
268 |
tree_repo = tree.branch.repository |
|
269 |
tree_repo.lock_write() |
|
270 |
tree_repo.start_write_group() |
|
271 |
tree_repo.sign_revision(rev1, gpg.LoopbackGPGStrategy(None)) |
|
272 |
tree_repo.commit_write_group() |
|
273 |
tree_repo.unlock() |
|
274 |
target = self.make_branch('target') |
|
275 |
tree.branch.repository.copy_content_into(target.repository) |
|
276 |
tree.branch.copy_content_into(target) |
|
277 |
self.assertTrue(target.repository.has_revision(rev1)) |
|
278 |
self.assertEqual( |
|
279 |
tree_repo.get_signature_text(rev1), |
|
280 |
target.repository.get_signature_text(rev1)) |
|
281 |
||
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. |
282 |
def test_clone_bzrdir_branch_and_repo_into_shared_repo(self): |
283 |
# by default cloning into a shared repo uses the shared repo.
|
|
284 |
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. |
285 |
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. |
286 |
tree.add('foo') |
287 |
tree.commit('revision 1') |
|
288 |
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. |
289 |
tree.branch.repository.copy_content_into(source.repository) |
290 |
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. |
291 |
try: |
292 |
self.make_repository('target', shared=True) |
|
293 |
except errors.IncompatibleFormat: |
|
294 |
return
|
|
295 |
dir = source.bzrdir |
|
296 |
target = dir.clone(self.get_url('target/child')) |
|
297 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
|
298 |
self.assertRaises(errors.NoRepositoryPresent, target.open_repository) |
|
299 |
self.assertEqual(source.revision_history(), |
|
300 |
target.open_branch().revision_history()) |
|
301 |
||
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. |
302 |
def test_clone_bzrdir_branch_revision(self): |
303 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
304 |
# make a branch with some revisions,
|
|
305 |
# and clone it with a revision limit.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
306 |
#
|
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. |
307 |
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. |
308 |
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. |
309 |
tree.add('foo') |
310 |
tree.commit('revision 1', rev_id='1') |
|
311 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
312 |
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. |
313 |
tree.branch.repository.copy_content_into(source.repository) |
314 |
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. |
315 |
dir = source.bzrdir |
316 |
target = dir.clone(self.get_url('target'), revision_id='1') |
|
317 |
self.assertEqual('1', target.open_branch().last_revision()) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
318 |
|
3242.2.14
by Aaron Bentley
Update from review comments |
319 |
def test_clone_on_transport_preserves_repo_format(self): |
320 |
if self.bzrdir_format == bzrdir.format_registry.make_bzrdir('default'): |
|
321 |
format = 'knit' |
|
322 |
else: |
|
323 |
format = None |
|
324 |
source_branch = self.make_branch('source', format=format) |
|
325 |
# Ensure no format data is cached
|
|
326 |
a_dir = bzrlib.branch.Branch.open_from_transport( |
|
327 |
self.get_transport('source')).bzrdir |
|
4060.1.4
by Robert Collins
Streaming fetch from remote servers. |
328 |
target_transport = self.get_transport('target') |
3242.2.14
by Aaron Bentley
Update from review comments |
329 |
target_bzrdir = a_dir.clone_on_transport(target_transport) |
330 |
target_repo = target_bzrdir.open_repository() |
|
3242.3.29
by Aaron Bentley
Fix failing test |
331 |
source_branch = bzrlib.branch.Branch.open( |
332 |
self.get_vfs_only_url('source')) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
333 |
if isinstance(target_repo, RemoteRepository): |
334 |
target_repo._ensure_real() |
|
335 |
target_repo = target_repo._real_repository |
|
3242.2.14
by Aaron Bentley
Update from review comments |
336 |
self.assertEqual(target_repo._format, source_branch.repository._format) |
337 |
||
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. |
338 |
def test_clone_bzrdir_tree_revision(self): |
339 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
340 |
# make a tree with a revision with a last-revision
|
|
341 |
# and clone it with a revision limit.
|
|
342 |
# This smoke test just checks the revision-id is right. Tree specific
|
|
343 |
# tests will check corner cases.
|
|
344 |
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. |
345 |
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. |
346 |
tree.add('foo') |
347 |
tree.commit('revision 1', rev_id='1') |
|
348 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
349 |
dir = tree.bzrdir |
|
350 |
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. |
351 |
self.skipIfNoWorkingTree(target) |
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
352 |
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. |
353 |
|
2991.1.1
by Daniel Watkins
Added (failing) test to ensure that bzrdir.clone won't create a working tree in a no-trees repository. |
354 |
def test_clone_bzrdir_into_notrees_repo(self): |
355 |
"""Cloning into a no-trees repo should not create a working tree"""
|
|
356 |
tree = self.make_branch_and_tree('source') |
|
357 |
self.build_tree(['source/foo']) |
|
358 |
tree.add('foo') |
|
359 |
tree.commit('revision 1') |
|
360 |
||
361 |
try: |
|
362 |
repo = self.make_repository('repo', shared=True) |
|
363 |
except errors.IncompatibleFormat: |
|
2991.1.4
by Daniel Watkins
Modified tests as per comments on-list. |
364 |
raise TestNotApplicable('must support shared repositories') |
2991.1.1
by Daniel Watkins
Added (failing) test to ensure that bzrdir.clone won't create a working tree in a no-trees repository. |
365 |
if repo.make_working_trees(): |
366 |
repo.set_make_working_trees(False) |
|
367 |
self.assertFalse(repo.make_working_trees()) |
|
368 |
||
369 |
dir = tree.bzrdir |
|
370 |
a_dir = dir.clone(self.get_url('repo/a')) |
|
371 |
a_dir.open_branch() |
|
2991.1.4
by Daniel Watkins
Modified tests as per comments on-list. |
372 |
self.assertRaises(errors.NoWorkingTree, a_dir.open_workingtree) |
2991.1.1
by Daniel Watkins
Added (failing) test to ensure that bzrdir.clone won't create a working tree in a no-trees repository. |
373 |
|
3650.5.3
by Aaron Bentley
Add failing test of BzrDir.clone |
374 |
def test_clone_respects_stacked(self): |
375 |
branch = self.make_branch('parent') |
|
4060.1.4
by Robert Collins
Streaming fetch from remote servers. |
376 |
child_transport = self.get_transport('child') |
3650.5.3
by Aaron Bentley
Add failing test of BzrDir.clone |
377 |
child = branch.bzrdir.clone_on_transport(child_transport, |
378 |
stacked_on=branch.base) |
|
379 |
self.assertEqual(child.open_branch().get_stacked_on_url(), branch.base) |
|
380 |
||
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
381 |
def test_get_branch_reference_on_reference(self): |
382 |
"""get_branch_reference should return the right url."""
|
|
383 |
referenced_branch = self.make_branch('referenced') |
|
384 |
dir = self.make_bzrdir('source') |
|
385 |
try: |
|
386 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
387 |
target_branch=referenced_branch) |
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
388 |
except errors.IncompatibleFormat: |
389 |
# this is ok too, not all formats have to support references.
|
|
390 |
return
|
|
391 |
self.assertEqual(referenced_branch.bzrdir.root_transport.abspath('') + '/', |
|
392 |
dir.get_branch_reference()) |
|
393 |
||
394 |
def test_get_branch_reference_on_non_reference(self): |
|
395 |
"""get_branch_reference should return None for non-reference branches."""
|
|
396 |
branch = self.make_branch('referenced') |
|
397 |
self.assertEqual(None, branch.bzrdir.get_branch_reference()) |
|
398 |
||
399 |
def test_get_branch_reference_no_branch(self): |
|
400 |
"""get_branch_reference should not mask NotBranchErrors."""
|
|
401 |
dir = self.make_bzrdir('source') |
|
402 |
if dir.has_branch(): |
|
403 |
# this format does not support branchless bzrdirs.
|
|
404 |
return
|
|
405 |
self.assertRaises(errors.NotBranchError, dir.get_branch_reference) |
|
406 |
||
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. |
407 |
def test_sprout_bzrdir_empty(self): |
408 |
dir = self.make_bzrdir('source') |
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
409 |
target = dir.sprout(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. |
410 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
411 |
# creates a new repository branch and tree
|
|
412 |
target.open_repository() |
|
413 |
target.open_branch() |
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
414 |
self.openWorkingTreeIfLocal(target) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
415 |
|
416 |
def test_sprout_bzrdir_empty_under_shared_repo(self): |
|
417 |
# sprouting an empty dir into a repo uses the repo
|
|
418 |
dir = self.make_bzrdir('source') |
|
419 |
try: |
|
420 |
self.make_repository('target', shared=True) |
|
421 |
except errors.IncompatibleFormat: |
|
422 |
return
|
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
423 |
target = dir.sprout(self.get_url('target/child')) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
424 |
self.assertRaises(errors.NoRepositoryPresent, target.open_repository) |
425 |
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. |
426 |
try: |
427 |
target.open_workingtree() |
|
2445.1.1
by Andrew Bennetts
Make RemoteBzrDir.open_workingtree raise NoWorkingTree rather than NotLocalUrl |
428 |
except errors.NoWorkingTree: |
5393.4.1
by Jelmer Vernooij
Add ControlDirFormat.supports_workingtrees. |
429 |
# Some bzrdirs can never have working trees.
|
430 |
self.assertFalse(target._format.supports_workingtrees) |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
431 |
|
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. |
432 |
def test_sprout_bzrdir_empty_under_shared_repo_force_new(self): |
1534.6.9
by Robert Collins
sprouting into shared repositories |
433 |
# the force_new_repo parameter should force use of a new repo in an empty
|
434 |
# bzrdir's sprout logic
|
|
435 |
dir = self.make_bzrdir('source') |
|
436 |
try: |
|
437 |
self.make_repository('target', shared=True) |
|
438 |
except errors.IncompatibleFormat: |
|
439 |
return
|
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
440 |
target = dir.sprout(self.get_url('target/child'), force_new_repo=True) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
441 |
target.open_repository() |
442 |
target.open_branch() |
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
443 |
self.openWorkingTreeIfLocal(target) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
444 |
|
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
445 |
def test_sprout_bzrdir_with_repository_to_shared(self): |
1534.6.9
by Robert Collins
sprouting into shared repositories |
446 |
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. |
447 |
self.build_tree(['commit_tree/foo']) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
448 |
tree.add('foo') |
449 |
tree.commit('revision 1', rev_id='1') |
|
450 |
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. |
451 |
tree.set_parent_trees([]) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
452 |
tree.commit('revision 2', rev_id='2') |
453 |
source = self.make_repository('source') |
|
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
454 |
tree.branch.repository.copy_content_into(source) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
455 |
dir = source.bzrdir |
456 |
try: |
|
457 |
shared_repo = self.make_repository('target', shared=True) |
|
458 |
except errors.IncompatibleFormat: |
|
459 |
return
|
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
460 |
target = dir.sprout(self.get_url('target/child')) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
461 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
462 |
self.assertTrue(shared_repo.has_revision('1')) |
|
463 |
||
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
464 |
def test_sprout_bzrdir_repository_branch_both_under_shared(self): |
465 |
try: |
|
466 |
shared_repo = self.make_repository('shared', shared=True) |
|
467 |
except errors.IncompatibleFormat: |
|
468 |
return
|
|
469 |
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. |
470 |
self.build_tree(['commit_tree/foo']) |
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
471 |
tree.add('foo') |
472 |
tree.commit('revision 1', rev_id='1') |
|
473 |
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. |
474 |
tree.set_parent_trees([]) |
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
475 |
tree.commit('revision 2', rev_id='2') |
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
476 |
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. |
477 |
dir = self.make_bzrdir('shared/source') |
478 |
dir.create_branch() |
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
479 |
target = dir.sprout(self.get_url('shared/target')) |
1534.6.13
by Robert Collins
Allow push/pull and branch between branches in the same shared repository. |
480 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
481 |
self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base) |
|
482 |
self.assertTrue(shared_repo.has_revision('1')) |
|
483 |
||
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
484 |
def test_sprout_bzrdir_repository_branch_only_source_under_shared(self): |
485 |
try: |
|
486 |
shared_repo = self.make_repository('shared', shared=True) |
|
487 |
except errors.IncompatibleFormat: |
|
488 |
return
|
|
489 |
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. |
490 |
self.build_tree(['commit_tree/foo']) |
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
491 |
tree.add('foo') |
492 |
tree.commit('revision 1', rev_id='1') |
|
493 |
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. |
494 |
tree.set_parent_trees([]) |
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
495 |
tree.commit('revision 2', rev_id='2') |
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
496 |
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. |
497 |
if shared_repo.make_working_trees(): |
498 |
shared_repo.set_make_working_trees(False) |
|
499 |
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 |
500 |
self.assertTrue(shared_repo.has_revision('1')) |
501 |
dir = self.make_bzrdir('shared/source') |
|
502 |
dir.create_branch() |
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
503 |
target = dir.sprout(self.get_url('target')) |
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
504 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
505 |
self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base) |
|
506 |
branch = target.open_branch() |
|
5535.4.17
by Andrew Bennetts
Adjust failing assertion for new, more sensible behaviour. |
507 |
# The sprouted bzrdir has a branch, so only revisions referenced by
|
508 |
# that branch are copied, rather than the whole repository. It's an
|
|
509 |
# empty branch, so none are copied.
|
|
510 |
self.assertEqual([], branch.repository.all_revision_ids()) |
|
5393.4.1
by Jelmer Vernooij
Add ControlDirFormat.supports_workingtrees. |
511 |
if branch.bzrdir._format.supports_workingtrees: |
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. |
512 |
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 |
513 |
self.assertFalse(branch.repository.is_shared()) |
514 |
||
1534.6.9
by Robert Collins
sprouting into shared repositories |
515 |
def test_sprout_bzrdir_repository_under_shared_force_new_repo(self): |
516 |
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. |
517 |
self.build_tree(['commit_tree/foo']) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
518 |
tree.add('foo') |
519 |
tree.commit('revision 1', rev_id='1') |
|
520 |
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. |
521 |
tree.set_parent_trees([]) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
522 |
tree.commit('revision 2', rev_id='2') |
523 |
source = self.make_repository('source') |
|
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
524 |
tree.branch.repository.copy_content_into(source) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
525 |
dir = source.bzrdir |
526 |
try: |
|
527 |
shared_repo = self.make_repository('target', shared=True) |
|
528 |
except errors.IncompatibleFormat: |
|
529 |
return
|
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
530 |
target = dir.sprout(self.get_url('target/child'), force_new_repo=True) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
531 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
532 |
self.assertFalse(shared_repo.has_revision('1')) |
|
533 |
||
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. |
534 |
def test_sprout_bzrdir_repository_revision(self): |
535 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
536 |
# make a repository with some revisions,
|
|
537 |
# and sprout it with a revision limit.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
538 |
#
|
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. |
539 |
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. |
540 |
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. |
541 |
tree.add('foo') |
542 |
tree.commit('revision 1', rev_id='1') |
|
543 |
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. |
544 |
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. |
545 |
tree.commit('revision 2', rev_id='2') |
546 |
source = self.make_repository('source') |
|
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
547 |
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. |
548 |
dir = source.bzrdir |
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
549 |
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. |
550 |
raise TestSkipped('revision limiting not strict yet') |
551 |
||
1534.6.9
by Robert Collins
sprouting into shared repositories |
552 |
def test_sprout_bzrdir_branch_and_repo_shared(self): |
553 |
# sprouting a branch with a repo into a shared repo uses the shared
|
|
554 |
# repo
|
|
555 |
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. |
556 |
self.build_tree(['commit_tree/foo']) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
557 |
tree.add('foo') |
558 |
tree.commit('revision 1', rev_id='1') |
|
559 |
source = self.make_branch('source') |
|
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
560 |
tree.branch.repository.copy_content_into(source.repository) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
561 |
tree.bzrdir.open_branch().copy_content_into(source) |
562 |
dir = source.bzrdir |
|
563 |
try: |
|
564 |
shared_repo = self.make_repository('target', shared=True) |
|
565 |
except errors.IncompatibleFormat: |
|
566 |
return
|
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
567 |
target = dir.sprout(self.get_url('target/child')) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
568 |
self.assertTrue(shared_repo.has_revision('1')) |
569 |
||
570 |
def test_sprout_bzrdir_branch_and_repo_shared_force_new_repo(self): |
|
571 |
# sprouting a branch with a repo into a shared repo uses the shared
|
|
572 |
# repo
|
|
573 |
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. |
574 |
self.build_tree(['commit_tree/foo']) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
575 |
tree.add('foo') |
576 |
tree.commit('revision 1', rev_id='1') |
|
577 |
source = self.make_branch('source') |
|
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
578 |
tree.branch.repository.copy_content_into(source.repository) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
579 |
tree.bzrdir.open_branch().copy_content_into(source) |
580 |
dir = source.bzrdir |
|
581 |
try: |
|
582 |
shared_repo = self.make_repository('target', shared=True) |
|
583 |
except errors.IncompatibleFormat: |
|
584 |
return
|
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
585 |
target = dir.sprout(self.get_url('target/child'), force_new_repo=True) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
586 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
587 |
self.assertFalse(shared_repo.has_revision('1')) |
|
588 |
||
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 |
def test_sprout_bzrdir_branch_reference(self): |
590 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
4070.7.3
by Andrew Bennetts
Make the sprout_bzrdir_branch_reference tests pass by returning an error from the cloning_metadir RPC which triggers a VFS fallback on the client. |
591 |
referenced_branch = self.make_branch('referenced') |
592 |
dir = self.make_bzrdir('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. |
593 |
try: |
1508.1.25
by Robert Collins
Update per review comments. |
594 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
595 |
target_branch=referenced_branch) |
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. |
596 |
except errors.IncompatibleFormat: |
597 |
# this is ok too, not all formats have to support references.
|
|
598 |
return
|
|
599 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
600 |
target = dir.sprout(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. |
601 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
602 |
# we want target to have a branch that is in-place.
|
|
603 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
604 |
# and as we dont support repositories being detached yet, a repo in
|
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. |
605 |
# place
|
606 |
target.open_repository() |
|
607 |
||
1534.6.9
by Robert Collins
sprouting into shared repositories |
608 |
def test_sprout_bzrdir_branch_reference_shared(self): |
609 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
610 |
referenced_tree = self.make_branch_and_tree('referenced') |
|
611 |
referenced_tree.commit('1', rev_id='1', allow_pointless=True) |
|
4070.7.3
by Andrew Bennetts
Make the sprout_bzrdir_branch_reference tests pass by returning an error from the cloning_metadir RPC which triggers a VFS fallback on the client. |
612 |
dir = self.make_bzrdir('source') |
1534.6.9
by Robert Collins
sprouting into shared repositories |
613 |
try: |
614 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
615 |
target_branch=referenced_tree.branch) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
616 |
except errors.IncompatibleFormat: |
617 |
# this is ok too, not all formats have to support references.
|
|
618 |
return
|
|
619 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
620 |
try: |
|
621 |
shared_repo = self.make_repository('target', shared=True) |
|
622 |
except errors.IncompatibleFormat: |
|
623 |
return
|
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
624 |
target = dir.sprout(self.get_url('target/child')) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
625 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
626 |
# we want target to have a branch that is in-place.
|
|
627 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
628 |
# and we want no repository as the target is shared
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
629 |
self.assertRaises(errors.NoRepositoryPresent, |
1534.6.9
by Robert Collins
sprouting into shared repositories |
630 |
target.open_repository) |
631 |
# and we want revision '1' in the shared repo
|
|
632 |
self.assertTrue(shared_repo.has_revision('1')) |
|
633 |
||
634 |
def test_sprout_bzrdir_branch_reference_shared_force_new_repo(self): |
|
635 |
# sprouting should create a repository if needed and a sprouted branch.
|
|
636 |
referenced_tree = self.make_branch_and_tree('referenced') |
|
637 |
referenced_tree.commit('1', rev_id='1', allow_pointless=True) |
|
4070.7.3
by Andrew Bennetts
Make the sprout_bzrdir_branch_reference tests pass by returning an error from the cloning_metadir RPC which triggers a VFS fallback on the client. |
638 |
dir = self.make_bzrdir('source') |
1534.6.9
by Robert Collins
sprouting into shared repositories |
639 |
try: |
640 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
641 |
target_branch=referenced_tree.branch) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
642 |
except errors.IncompatibleFormat: |
643 |
# this is ok too, not all formats have to support references.
|
|
644 |
return
|
|
645 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
646 |
try: |
|
647 |
shared_repo = self.make_repository('target', shared=True) |
|
648 |
except errors.IncompatibleFormat: |
|
649 |
return
|
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
650 |
target = dir.sprout(self.get_url('target/child'), force_new_repo=True) |
1534.6.9
by Robert Collins
sprouting into shared repositories |
651 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
652 |
# we want target to have a branch that is in-place.
|
|
653 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
654 |
# and we want revision '1' in the new repo
|
|
655 |
self.assertTrue(target.open_repository().has_revision('1')) |
|
656 |
# but not the shared one
|
|
657 |
self.assertFalse(shared_repo.has_revision('1')) |
|
658 |
||
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. |
659 |
def test_sprout_bzrdir_branch_revision(self): |
660 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
661 |
# make a repository with some revisions,
|
|
662 |
# and sprout it with a revision limit.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
663 |
#
|
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. |
664 |
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. |
665 |
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. |
666 |
tree.add('foo') |
667 |
tree.commit('revision 1', rev_id='1') |
|
668 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
669 |
source = self.make_branch('source') |
|
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
670 |
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. |
671 |
tree.bzrdir.open_branch().copy_content_into(source) |
672 |
dir = source.bzrdir |
|
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
673 |
target = dir.sprout(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. |
674 |
self.assertEqual('1', target.open_branch().last_revision()) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
675 |
|
5535.3.26
by Andrew Bennetts
Add per_controldir test for sprout copying all tags. |
676 |
def test_sprout_bzrdir_branch_with_tags(self): |
677 |
# when sprouting a branch all revisions named in the tags are copied
|
|
678 |
# too.
|
|
679 |
builder = self.make_branch_builder('source') |
|
5651.5.3
by Andrew Bennetts
Use new fixture in more tests. |
680 |
source = fixtures.build_branch_with_non_ancestral_rev(builder) |
5535.3.26
by Andrew Bennetts
Add per_controldir test for sprout copying all tags. |
681 |
try: |
682 |
source.tags.set_tag('tag-a', 'rev-2') |
|
683 |
except errors.TagsNotSupported: |
|
684 |
raise TestNotApplicable('Branch format does not support tags.') |
|
685 |
# Now source has a tag not in its ancestry. Sprout its controldir.
|
|
686 |
dir = source.bzrdir |
|
687 |
target = dir.sprout(self.get_url('target')) |
|
688 |
# The tag is present, and so is its revision.
|
|
689 |
new_branch = target.open_branch() |
|
690 |
self.assertEqual('rev-2', new_branch.tags.lookup_tag('tag-a')) |
|
691 |
new_branch.repository.get_revision('rev-2') |
|
692 |
||
5535.4.1
by Andrew Bennetts
Add another test. |
693 |
def test_sprout_bzrdir_branch_with_absent_tag(self): |
694 |
# tags referencing absent revisions are copied (and those absent
|
|
695 |
# revisions do not prevent the sprout.)
|
|
696 |
builder = self.make_branch_builder('source') |
|
697 |
builder.build_commit(message="Rev 1", rev_id='rev-1') |
|
698 |
source = builder.get_branch() |
|
699 |
try: |
|
700 |
source.tags.set_tag('tag-a', 'missing-rev') |
|
701 |
except errors.TagsNotSupported: |
|
702 |
raise TestNotApplicable('Branch format does not support tags.') |
|
703 |
# Now source has a tag pointing to an absent revision. Sprout its
|
|
704 |
# controldir.
|
|
705 |
dir = source.bzrdir |
|
706 |
target = dir.sprout(self.get_url('target')) |
|
707 |
# The tag is present in the target
|
|
708 |
new_branch = target.open_branch() |
|
709 |
self.assertEqual('missing-rev', new_branch.tags.lookup_tag('tag-a')) |
|
710 |
||
5535.3.38
by Andrew Bennetts
Remove XXX, add some test coverage to prove it works. |
711 |
def test_sprout_bzrdir_passing_source_branch_with_absent_tag(self): |
712 |
# tags referencing absent revisions are copied (and those absent
|
|
713 |
# revisions do not prevent the sprout.)
|
|
714 |
builder = self.make_branch_builder('source') |
|
715 |
builder.build_commit(message="Rev 1", rev_id='rev-1') |
|
716 |
source = builder.get_branch() |
|
717 |
try: |
|
718 |
source.tags.set_tag('tag-a', 'missing-rev') |
|
719 |
except errors.TagsNotSupported: |
|
720 |
raise TestNotApplicable('Branch format does not support tags.') |
|
721 |
# Now source has a tag pointing to an absent revision. Sprout its
|
|
722 |
# controldir.
|
|
723 |
dir = source.bzrdir |
|
724 |
target = dir.sprout(self.get_url('target'), source_branch=source) |
|
725 |
# The tag is present in the target
|
|
726 |
new_branch = target.open_branch() |
|
727 |
self.assertEqual('missing-rev', new_branch.tags.lookup_tag('tag-a')) |
|
728 |
||
5535.4.10
by Andrew Bennetts
Add a test, fix a bug and XXX it covers. |
729 |
def test_sprout_bzrdir_passing_rev_not_source_branch_copies_tags(self): |
5535.4.12
by Andrew Bennetts
Adjust test and code to behave more intuitively -- make bzrdir.sprout(..., revision_id=R) stop fetching the branch history at R, as that will be the new branch's tip. |
730 |
# dir.sprout(..., revision_id='rev1') copies rev1, and all the tags of
|
731 |
# the branch at that bzrdir, the ancestry of all of those, but no other
|
|
732 |
# revs (not even the tip of the source branch).
|
|
5535.4.10
by Andrew Bennetts
Add a test, fix a bug and XXX it covers. |
733 |
builder = self.make_branch_builder('source') |
734 |
builder.build_commit(message="Base", rev_id='base-rev') |
|
735 |
# Make three parallel lines of ancestry off this base.
|
|
736 |
source = builder.get_branch() |
|
737 |
builder.build_commit(message="Rev A1", rev_id='rev-a1') |
|
738 |
builder.build_commit(message="Rev A2", rev_id='rev-a2') |
|
739 |
builder.build_commit(message="Rev A3", rev_id='rev-a3') |
|
740 |
source.set_last_revision_info(1, 'base-rev') |
|
741 |
builder.build_commit(message="Rev B1", rev_id='rev-b1') |
|
742 |
builder.build_commit(message="Rev B2", rev_id='rev-b2') |
|
743 |
builder.build_commit(message="Rev B3", rev_id='rev-b3') |
|
744 |
source.set_last_revision_info(1, 'base-rev') |
|
745 |
builder.build_commit(message="Rev C1", rev_id='rev-c1') |
|
746 |
builder.build_commit(message="Rev C2", rev_id='rev-c2') |
|
747 |
builder.build_commit(message="Rev C3", rev_id='rev-c3') |
|
748 |
# Set the branch tip to A2
|
|
749 |
source.set_last_revision_info(3, 'rev-a2') |
|
750 |
try: |
|
751 |
# Create a tag for B2, and for an absent rev
|
|
752 |
source.tags.set_tag('tag-non-ancestry', 'rev-b2') |
|
753 |
source.tags.set_tag('tag-absent', 'absent-rev') |
|
754 |
except errors.TagsNotSupported: |
|
755 |
raise TestNotApplicable('Branch format does not support tags.') |
|
756 |
# And ask sprout for C2
|
|
757 |
dir = source.bzrdir |
|
758 |
target = dir.sprout(self.get_url('target'), revision_id='rev-c2') |
|
759 |
# The tags are present
|
|
760 |
new_branch = target.open_branch() |
|
761 |
self.assertEqual( |
|
762 |
{'tag-absent': 'absent-rev', 'tag-non-ancestry': 'rev-b2'}, |
|
763 |
new_branch.tags.get_tag_dict()) |
|
764 |
# And the revs for A2, B2 and C2's ancestries are present, but no
|
|
765 |
# others.
|
|
766 |
self.assertEqual( |
|
5535.4.12
by Andrew Bennetts
Adjust test and code to behave more intuitively -- make bzrdir.sprout(..., revision_id=R) stop fetching the branch history at R, as that will be the new branch's tip. |
767 |
['base-rev', 'rev-b1', 'rev-b2', 'rev-c1', 'rev-c2'], |
768 |
sorted(new_branch.repository.all_revision_ids())) |
|
5535.4.10
by Andrew Bennetts
Add a test, fix a bug and XXX it covers. |
769 |
|
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. |
770 |
def test_sprout_bzrdir_tree_branch_reference(self): |
771 |
# 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. |
772 |
# 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. |
773 |
referenced_branch = self.make_branch('referencced') |
774 |
dir = self.make_bzrdir('source') |
|
775 |
try: |
|
1508.1.25
by Robert Collins
Update per review comments. |
776 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
777 |
target_branch=referenced_branch) |
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. |
778 |
except errors.IncompatibleFormat: |
779 |
# this is ok too, not all formats have to support references.
|
|
780 |
return
|
|
781 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
1910.4.13
by Andrew Bennetts
Slightly more consistent names. |
782 |
tree = self.createWorkingTreeOrSkip(dir) |
2381.1.3
by Robert Collins
Review feedback. |
783 |
self.build_tree(['source/subdir/']) |
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
784 |
tree.add('subdir') |
4070.7.1
by Andrew Bennetts
Cause 32 less test skips in bzrdir_implementations.test_bzrdir. |
785 |
target = dir.sprout(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. |
786 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
787 |
# we want target to have a branch that is in-place.
|
|
788 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
789 |
# and as we dont support repositories being detached yet, a repo in
|
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. |
790 |
# place
|
791 |
target.open_repository() |
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
792 |
result_tree = target.open_workingtree() |
793 |
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. |
794 |
|
795 |
def test_sprout_bzrdir_tree_branch_reference_revision(self): |
|
796 |
# 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. |
797 |
# 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. |
798 |
# and the likewise the new branch should be truncated too
|
799 |
referenced_branch = self.make_branch('referencced') |
|
800 |
dir = self.make_bzrdir('source') |
|
801 |
try: |
|
1508.1.25
by Robert Collins
Update per review comments. |
802 |
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir, |
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
803 |
target_branch=referenced_branch) |
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. |
804 |
except errors.IncompatibleFormat: |
805 |
# this is ok too, not all formats have to support references.
|
|
806 |
return
|
|
807 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
1910.4.13
by Andrew Bennetts
Slightly more consistent names. |
808 |
tree = self.createWorkingTreeOrSkip(dir) |
2381.1.3
by Robert Collins
Review feedback. |
809 |
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. |
810 |
tree.add('foo') |
811 |
tree.commit('revision 1', rev_id='1') |
|
812 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
813 |
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. |
814 |
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. |
815 |
self.assertNotEqual(dir.transport.base, target.transport.base) |
816 |
# we want target to have a branch that is in-place.
|
|
817 |
self.assertEqual(target, target.open_branch().bzrdir) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
818 |
# and as we dont support repositories being detached yet, a repo in
|
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. |
819 |
# place
|
820 |
target.open_repository() |
|
821 |
# we trust that the working tree sprouting works via the other tests.
|
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
822 |
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. |
823 |
self.assertEqual('1', target.open_branch().last_revision()) |
824 |
||
825 |
def test_sprout_bzrdir_tree_revision(self): |
|
826 |
# test for revision limiting, [smoke test, not corner case checks].
|
|
827 |
# make a tree with a revision with a last-revision
|
|
828 |
# and sprout it with a revision limit.
|
|
829 |
# This smoke test just checks the revision-id is right. Tree specific
|
|
830 |
# tests will check corner cases.
|
|
831 |
tree = self.make_branch_and_tree('source') |
|
2381.1.3
by Robert Collins
Review feedback. |
832 |
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. |
833 |
tree.add('foo') |
834 |
tree.commit('revision 1', rev_id='1') |
|
835 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
836 |
dir = tree.bzrdir |
|
1910.4.14
by Andrew Bennetts
Add a sproutOrSkip test helper. |
837 |
target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='1') |
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
838 |
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. |
839 |
|
3123.5.8
by Aaron Bentley
Work around double-opening lock issue |
840 |
def test_sprout_takes_accelerator(self): |
841 |
tree = self.make_branch_and_tree('source') |
|
842 |
self.build_tree(['source/foo']) |
|
843 |
tree.add('foo') |
|
844 |
tree.commit('revision 1', rev_id='1') |
|
845 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
846 |
dir = tree.bzrdir |
|
847 |
target = self.sproutOrSkip(dir, self.get_url('target'), |
|
848 |
accelerator_tree=tree) |
|
849 |
self.assertEqual(['2'], target.open_workingtree().get_parent_ids()) |
|
850 |
||
3983.1.3
by Daniel Watkins
Added test to ensure BzrDirs accept the 'no_tree' argument. |
851 |
def test_sprout_branch_no_tree(self): |
852 |
tree = self.make_branch_and_tree('source') |
|
853 |
self.build_tree(['source/foo']) |
|
854 |
tree.add('foo') |
|
855 |
tree.commit('revision 1', rev_id='1') |
|
856 |
tree.commit('revision 2', rev_id='2', allow_pointless=True) |
|
857 |
dir = tree.bzrdir |
|
5582.9.6
by Jelmer Vernooij
More cleanups, remove more dependencies on specific formats. |
858 |
try: |
859 |
target = dir.sprout(self.get_url('target'), |
|
860 |
create_tree_if_local=False) |
|
861 |
except errors.MustHaveWorkingTree: |
|
862 |
raise TestNotApplicable("control dir format requires working tree") |
|
3983.1.3
by Daniel Watkins
Added test to ensure BzrDirs accept the 'no_tree' argument. |
863 |
self.failIfExists('target/foo') |
3983.1.9
by Daniel Watkins
Wrapped long line. |
864 |
self.assertEqual(tree.branch.last_revision(), |
865 |
target.open_branch().last_revision()) |
|
3983.1.3
by Daniel Watkins
Added test to ensure BzrDirs accept the 'no_tree' argument. |
866 |
|
5316.1.1
by Andrew Bennetts
Fix BzrDir.sprout to respect default stacking policy. |
867 |
def test_sprout_with_revision_id_uses_default_stack_on(self): |
868 |
# Make a branch with three commits to stack on.
|
|
869 |
builder = self.make_branch_builder('stack-on') |
|
870 |
builder.start_series() |
|
871 |
builder.build_commit(message='Rev 1.', rev_id='rev-1') |
|
872 |
builder.build_commit(message='Rev 2.', rev_id='rev-2') |
|
873 |
builder.build_commit(message='Rev 3.', rev_id='rev-3') |
|
874 |
builder.finish_series() |
|
875 |
stack_on = builder.get_branch() |
|
876 |
# Make a bzrdir with a default stacking policy to stack on that branch.
|
|
877 |
config = self.make_bzrdir('policy-dir').get_config() |
|
878 |
try: |
|
879 |
config.set_default_stack_on(self.get_url('stack-on')) |
|
880 |
except errors.BzrError: |
|
881 |
raise TestNotApplicable('Only relevant for stackable formats.') |
|
882 |
# Sprout the stacked-on branch into the bzrdir.
|
|
883 |
sprouted = stack_on.bzrdir.sprout( |
|
884 |
self.get_url('policy-dir/sprouted'), revision_id='rev-3') |
|
885 |
# Not all revisions are copied into the sprouted repository.
|
|
886 |
repo = sprouted.open_repository() |
|
887 |
self.addCleanup(repo.lock_read().unlock) |
|
888 |
self.assertEqual(None, repo.get_parent_map(['rev-1']).get('rev-1')) |
|
889 |
||
1534.4.39
by Robert Collins
Basic BzrDir support. |
890 |
def test_format_initialize_find_open(self): |
891 |
# loopback test to check the current format initializes to itself.
|
|
892 |
if not self.bzrdir_format.is_supported(): |
|
893 |
# unsupported formats are not loopback testable
|
|
894 |
# because the default open will not open them and
|
|
895 |
# they may not be initializable.
|
|
896 |
return
|
|
4934.4.2
by Martin Pool
Check RemoteBzrDirFormat._network_name is none before running tests that rely on this (for bug 504102) |
897 |
# for remote formats, there must be no prior assumption about the
|
898 |
# network name to use - it's possible that this may somehow have got
|
|
899 |
# in through an unisolated test though - see
|
|
5243.1.2
by Martin
Point launchpad links in comments at production server rather than edge |
900 |
# <https://bugs.launchpad.net/bzr/+bug/504102>
|
4934.4.2
by Martin Pool
Check RemoteBzrDirFormat._network_name is none before running tests that rely on this (for bug 504102) |
901 |
self.assertEquals(getattr(self.bzrdir_format, |
902 |
'_network_name', None), |
|
903 |
None) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
904 |
# supported formats must be able to init and open
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
905 |
t = self.get_transport() |
906 |
readonly_t = self.get_readonly_transport() |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
907 |
made_control = self.bzrdir_format.initialize(t.base) |
5363.2.22
by Jelmer Vernooij
Provide bzrlib.bzrdir.format_registry. |
908 |
self.failUnless(isinstance(made_control, controldir.ControlDir)) |
5712.3.18
by Jelmer Vernooij
Some more test fixes. |
909 |
if isinstance(self.bzrdir_format, RemoteBzrDirFormat): |
910 |
return
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
911 |
self.assertEqual(self.bzrdir_format, |
5363.2.3
by Jelmer Vernooij
Add ControlDirFormat. |
912 |
controldir.ControlDirFormat.find_format(readonly_t)) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
913 |
direct_opened_dir = self.bzrdir_format.open(readonly_t) |
914 |
opened_dir = bzrdir.BzrDir.open(t.base) |
|
915 |
self.assertEqual(made_control._format, |
|
916 |
opened_dir._format) |
|
917 |
self.assertEqual(direct_opened_dir._format, |
|
918 |
opened_dir._format) |
|
5363.2.22
by Jelmer Vernooij
Provide bzrlib.bzrdir.format_registry. |
919 |
self.failUnless(isinstance(opened_dir, controldir.ControlDir)) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
920 |
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
921 |
def test_format_initialize_on_transport_ex(self): |
922 |
t = self.get_transport('dir') |
|
923 |
self.assertInitializeEx(t) |
|
924 |
||
925 |
def test_format_initialize_on_transport_ex_use_existing_dir_True(self): |
|
926 |
t = self.get_transport('dir') |
|
927 |
t.ensure_base() |
|
928 |
self.assertInitializeEx(t, use_existing_dir=True) |
|
929 |
||
930 |
def test_format_initialize_on_transport_ex_use_existing_dir_False(self): |
|
931 |
if not self.bzrdir_format.is_supported(): |
|
932 |
# Not initializable - not a failure either.
|
|
933 |
return
|
|
934 |
t = self.get_transport('dir') |
|
935 |
t.ensure_base() |
|
4294.2.10
by Robert Collins
Review feedback. |
936 |
self.assertRaises(errors.FileExists, |
937 |
self.bzrdir_format.initialize_on_transport_ex, t, |
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
938 |
use_existing_dir=False) |
939 |
||
940 |
def test_format_initialize_on_transport_ex_create_prefix_True(self): |
|
941 |
t = self.get_transport('missing/dir') |
|
942 |
self.assertInitializeEx(t, create_prefix=True) |
|
943 |
||
944 |
def test_format_initialize_on_transport_ex_create_prefix_False(self): |
|
945 |
if not self.bzrdir_format.is_supported(): |
|
946 |
# Not initializable - not a failure either.
|
|
947 |
return
|
|
948 |
t = self.get_transport('missing/dir') |
|
949 |
self.assertRaises(errors.NoSuchFile, self.assertInitializeEx, t, |
|
950 |
create_prefix=False) |
|
951 |
||
952 |
def test_format_initialize_on_transport_ex_force_new_repo_True(self): |
|
953 |
t = self.get_transport('repo') |
|
954 |
repo_fmt = bzrdir.format_registry.make_bzrdir('1.9') |
|
955 |
repo_name = repo_fmt.repository_format.network_name() |
|
956 |
repo = repo_fmt.initialize_on_transport_ex(t, |
|
957 |
repo_format_name=repo_name, shared_repo=True)[0] |
|
958 |
made_repo, control = self.assertInitializeEx(t.clone('branch'), |
|
959 |
force_new_repo=True, repo_format_name=repo_name) |
|
960 |
if control is None: |
|
961 |
# uninitialisable format
|
|
962 |
return
|
|
963 |
self.assertNotEqual(repo.bzrdir.root_transport.base, |
|
964 |
made_repo.bzrdir.root_transport.base) |
|
965 |
||
966 |
def test_format_initialize_on_transport_ex_force_new_repo_False(self): |
|
967 |
t = self.get_transport('repo') |
|
968 |
repo_fmt = bzrdir.format_registry.make_bzrdir('1.9') |
|
969 |
repo_name = repo_fmt.repository_format.network_name() |
|
970 |
repo = repo_fmt.initialize_on_transport_ex(t, |
|
971 |
repo_format_name=repo_name, shared_repo=True)[0] |
|
972 |
made_repo, control = self.assertInitializeEx(t.clone('branch'), |
|
973 |
force_new_repo=False, repo_format_name=repo_name) |
|
974 |
if control is None: |
|
975 |
# uninitialisable format
|
|
976 |
return
|
|
5673.1.3
by Jelmer Vernooij
Change flexible_components to fixed_components. |
977 |
if not control._format.fixed_components: |
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
978 |
self.assertEqual(repo.bzrdir.root_transport.base, |
979 |
made_repo.bzrdir.root_transport.base) |
|
980 |
||
981 |
def test_format_initialize_on_transport_ex_stacked_on(self): |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
982 |
# trunk is a stackable format. Note that its in the same server area
|
983 |
# which is what launchpad does, but not sufficient to exercise the
|
|
984 |
# general case.
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
985 |
trunk = self.make_branch('trunk', format='1.9') |
986 |
t = self.get_transport('stacked') |
|
987 |
old_fmt = bzrdir.format_registry.make_bzrdir('pack-0.92') |
|
988 |
repo_name = old_fmt.repository_format.network_name() |
|
989 |
# Should end up with a 1.9 format (stackable)
|
|
990 |
repo, control = self.assertInitializeEx(t, need_meta=True, |
|
991 |
repo_format_name=repo_name, stacked_on='../trunk', stack_on_pwd=t.base) |
|
992 |
if control is None: |
|
993 |
# uninitialisable format
|
|
994 |
return
|
|
995 |
self.assertLength(1, repo._fallback_repositories) |
|
996 |
||
4416.3.6
by Jonathan Lange
Failing test that reproduces the error at a low level. |
997 |
def test_format_initialize_on_transport_ex_default_stack_on(self): |
998 |
# When initialize_on_transport_ex uses a stacked-on branch because of
|
|
999 |
# a stacking policy on the target, the location of the fallback
|
|
1000 |
# repository is the same as the external location of the stacked-on
|
|
1001 |
# branch.
|
|
1002 |
balloon = self.make_bzrdir('balloon') |
|
4617.6.1
by Robert Collins
Fix a broken check in per_bzr tests that causes failures when the default format is rich roots. |
1003 |
if isinstance(balloon._format, bzrdir.BzrDirMetaFormat1): |
4416.3.6
by Jonathan Lange
Failing test that reproduces the error at a low level. |
1004 |
stack_on = self.make_branch('stack-on', format='1.9') |
1005 |
else: |
|
1006 |
stack_on = self.make_branch('stack-on') |
|
1007 |
config = self.make_bzrdir('.').get_config() |
|
1008 |
try: |
|
1009 |
config.set_default_stack_on('stack-on') |
|
1010 |
except errors.BzrError: |
|
1011 |
raise TestNotApplicable('Only relevant for stackable formats.') |
|
1012 |
# Initialize a bzrdir subject to the policy.
|
|
1013 |
t = self.get_transport('stacked') |
|
1014 |
repo_fmt = bzrdir.format_registry.make_bzrdir('1.9') |
|
1015 |
repo_name = repo_fmt.repository_format.network_name() |
|
1016 |
repo, control = self.assertInitializeEx( |
|
1017 |
t, need_meta=True, repo_format_name=repo_name, stacked_on=None) |
|
4807.3.2
by John Arbash Meinel
Some tests *did* know that the repo was write locked |
1018 |
# self.addCleanup(repo.unlock)
|
4416.3.6
by Jonathan Lange
Failing test that reproduces the error at a low level. |
1019 |
if control is None: |
1020 |
# uninitialisable format
|
|
1021 |
return
|
|
1022 |
# There's one fallback repo, with a public location.
|
|
1023 |
self.assertLength(1, repo._fallback_repositories) |
|
1024 |
fallback_repo = repo._fallback_repositories[0] |
|
1025 |
self.assertEqual( |
|
1026 |
stack_on.base, fallback_repo.bzrdir.root_transport.base) |
|
4456.2.1
by Andrew Bennetts
Fix automatic branch format upgrades triggered by a default stacking policy on a 1.16rc1 (or later) smart server. |
1027 |
# The bzrdir creates a branch in stacking-capable format.
|
1028 |
new_branch = control.create_branch() |
|
1029 |
self.assertTrue(new_branch._format.supports_stacking()) |
|
4416.3.6
by Jonathan Lange
Failing test that reproduces the error at a low level. |
1030 |
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1031 |
def test_format_initialize_on_transport_ex_repo_fmt_name_None(self): |
1032 |
t = self.get_transport('dir') |
|
1033 |
repo, control = self.assertInitializeEx(t) |
|
1034 |
self.assertEqual(None, repo) |
|
1035 |
||
1036 |
def test_format_initialize_on_transport_ex_repo_fmt_name_followed(self): |
|
1037 |
t = self.get_transport('dir') |
|
4294.2.10
by Robert Collins
Review feedback. |
1038 |
# 1.6 is likely to never be default
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1039 |
fmt = bzrdir.format_registry.make_bzrdir('1.6') |
1040 |
repo_name = fmt.repository_format.network_name() |
|
1041 |
repo, control = self.assertInitializeEx(t, repo_format_name=repo_name) |
|
1042 |
if control is None: |
|
1043 |
# uninitialisable format
|
|
1044 |
return
|
|
5673.1.3
by Jelmer Vernooij
Change flexible_components to fixed_components. |
1045 |
if self.bzrdir_format.fixed_components: |
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1046 |
# must stay with the all-in-one-format.
|
1047 |
repo_name = self.bzrdir_format.network_name() |
|
1048 |
self.assertEqual(repo_name, repo._format.network_name()) |
|
1049 |
||
1050 |
def assertInitializeEx(self, t, need_meta=False, **kwargs): |
|
1051 |
"""Execute initialize_on_transport_ex and check it succeeded correctly.
|
|
1052 |
||
4294.2.10
by Robert Collins
Review feedback. |
1053 |
This involves checking that the disk objects were created, open with
|
1054 |
the same format returned, and had the expected disk format.
|
|
1055 |
||
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1056 |
:param t: The transport to initialize on.
|
1057 |
:param **kwargs: Additional arguments to pass to
|
|
1058 |
initialize_on_transport_ex.
|
|
1059 |
:return: the resulting repo, control dir tuple.
|
|
1060 |
"""
|
|
1061 |
if not self.bzrdir_format.is_supported(): |
|
1062 |
# Not initializable - not a failure either.
|
|
1063 |
return None, None |
|
1064 |
repo, control, require_stacking, repo_policy = \ |
|
1065 |
self.bzrdir_format.initialize_on_transport_ex(t, **kwargs) |
|
4807.3.2
by John Arbash Meinel
Some tests *did* know that the repo was write locked |
1066 |
if repo is not None: |
1067 |
# Repositories are open write-locked
|
|
1068 |
self.assertTrue(repo.is_write_locked()) |
|
1069 |
self.addCleanup(repo.unlock) |
|
5699.1.1
by Jelmer Vernooij
Require ControlDirFormat.initialize_on_transport_ex to return a ControlDir instance, not a BzrDir instance. |
1070 |
self.assertIsInstance(control, controldir.ControlDir) |
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1071 |
opened = bzrdir.BzrDir.open(t.base) |
1072 |
expected_format = self.bzrdir_format |
|
5712.3.18
by Jelmer Vernooij
Some more test fixes. |
1073 |
if need_meta and expected_format.fixed_components: |
1074 |
# Pre-metadir formats change when we are making something that
|
|
1075 |
# needs a metaformat, because clone is used for push.
|
|
1076 |
expected_format = bzrdir.BzrDirMetaFormat1() |
|
1077 |
if not isinstance(expected_format, RemoteBzrDirFormat): |
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1078 |
self.assertEqual(control._format.network_name(), |
1079 |
expected_format.network_name()) |
|
1080 |
self.assertEqual(control._format.network_name(), |
|
1081 |
opened._format.network_name()) |
|
1082 |
self.assertEqual(control.__class__, opened.__class__) |
|
1083 |
return repo, control |
|
1084 |
||
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
1085 |
def test_format_network_name(self): |
1086 |
# All control formats must have a network name.
|
|
1087 |
dir = self.make_bzrdir('.') |
|
1088 |
format = dir._format |
|
1089 |
# We want to test that the network_name matches the actual format on
|
|
1090 |
# disk. For local control dirsthat means that using network_name as a
|
|
1091 |
# key in the registry gives back the same format. For remote obects
|
|
1092 |
# we check that the network_name of the RemoteBzrDirFormat we have
|
|
1093 |
# locally matches the actual format present on disk.
|
|
5712.3.15
by Jelmer Vernooij
Remove unused register format functions. |
1094 |
if isinstance(format, RemoteBzrDirFormat): |
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
1095 |
dir._ensure_real() |
1096 |
real_dir = dir._real_bzrdir |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
1097 |
network_name = format.network_name() |
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
1098 |
self.assertEqual(real_dir._format.network_name(), network_name) |
1099 |
else: |
|
5363.2.23
by Jelmer Vernooij
Move network_format_registry to bzrlib.controldir. |
1100 |
registry = controldir.network_format_registry |
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
1101 |
network_name = format.network_name() |
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
1102 |
looked_up_format = registry.get(network_name) |
5418.3.1
by Jelmer Vernooij
Cope with control directories that are local but can't have working trees. |
1103 |
self.assertTrue( |
1104 |
issubclass(format.__class__, looked_up_format.__class__)) |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
1105 |
# The network name must be a byte string.
|
1106 |
self.assertIsInstance(network_name, str) |
|
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
1107 |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1108 |
def test_open_not_bzrdir(self): |
1109 |
# test the formats specific behaviour for no-content or similar dirs.
|
|
5363.2.29
by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir. |
1110 |
self.assertRaises(errors.NotBranchError, |
1534.4.39
by Robert Collins
Basic BzrDir support. |
1111 |
self.bzrdir_format.open, |
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
1112 |
transport.get_transport(self.get_readonly_url())) |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1113 |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1114 |
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. |
1115 |
# a bzrdir can construct a branch and repository for itself.
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1116 |
if not self.bzrdir_format.is_supported(): |
1117 |
# unsupported formats are not loopback testable
|
|
1118 |
# because the default open will not open them and
|
|
1119 |
# they may not be initializable.
|
|
1120 |
return
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1121 |
t = self.get_transport() |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1122 |
made_control = self.bzrdir_format.initialize(t.base) |
1123 |
made_repo = made_control.create_repository() |
|
1124 |
made_branch = made_control.create_branch() |
|
1508.1.25
by Robert Collins
Update per review comments. |
1125 |
self.failUnless(isinstance(made_branch, bzrlib.branch.Branch)) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1126 |
self.assertEqual(made_control, made_branch.bzrdir) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1127 |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1128 |
def test_open_branch(self): |
1129 |
if not self.bzrdir_format.is_supported(): |
|
1130 |
# unsupported formats are not loopback testable
|
|
1131 |
# because the default open will not open them and
|
|
1132 |
# they may not be initializable.
|
|
1133 |
return
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1134 |
t = self.get_transport() |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1135 |
made_control = self.bzrdir_format.initialize(t.base) |
1136 |
made_repo = made_control.create_repository() |
|
1137 |
made_branch = made_control.create_branch() |
|
1138 |
opened_branch = made_control.open_branch() |
|
1139 |
self.assertEqual(made_control, opened_branch.bzrdir) |
|
1140 |
self.failUnless(isinstance(opened_branch, made_branch.__class__)) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1141 |
self.failUnless(isinstance(opened_branch._format, made_branch._format.__class__)) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1142 |
|
4997.1.1
by Jelmer Vernooij
Add BzrDir.list_branches(). |
1143 |
def test_list_branches(self): |
1144 |
if not self.bzrdir_format.is_supported(): |
|
1145 |
# unsupported formats are not loopback testable
|
|
1146 |
# because the default open will not open them and
|
|
1147 |
# they may not be initializable.
|
|
1148 |
return
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1149 |
t = self.get_transport() |
4997.1.1
by Jelmer Vernooij
Add BzrDir.list_branches(). |
1150 |
made_control = self.bzrdir_format.initialize(t.base) |
1151 |
made_repo = made_control.create_repository() |
|
1152 |
made_branch = made_control.create_branch() |
|
1153 |
branches = made_control.list_branches() |
|
1154 |
self.assertEquals(1, len(branches)) |
|
1155 |
self.assertEquals(made_branch.base, branches[0].base) |
|
1156 |
try: |
|
1157 |
made_control.destroy_branch() |
|
1158 |
except errors.UnsupportedOperation: |
|
1159 |
pass # Not all bzrdirs support destroying directories |
|
1160 |
else: |
|
1161 |
self.assertEquals([], made_control.list_branches()) |
|
1162 |
||
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1163 |
def test_create_repository(self): |
1164 |
# a bzrdir can construct a repository for itself.
|
|
1165 |
if not self.bzrdir_format.is_supported(): |
|
1166 |
# unsupported formats are not loopback testable
|
|
1167 |
# because the default open will not open them and
|
|
1168 |
# they may not be initializable.
|
|
1169 |
return
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1170 |
t = self.get_transport() |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1171 |
made_control = self.bzrdir_format.initialize(t.base) |
1172 |
made_repo = made_control.create_repository() |
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
1173 |
# Check that we have a repository object.
|
1174 |
made_repo.has_revision('foo') |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1175 |
self.assertEqual(made_control, made_repo.bzrdir) |
1841.2.2
by Jelmer Vernooij
Add more tests for create_repository(). |
1176 |
|
1177 |
def test_create_repository_shared(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1178 |
# a bzrdir can create a shared repository or
|
1841.2.2
by Jelmer Vernooij
Add more tests for create_repository(). |
1179 |
# fail appropriately
|
1180 |
if not self.bzrdir_format.is_supported(): |
|
1181 |
# unsupported formats are not loopback testable
|
|
1182 |
# because the default open will not open them and
|
|
1183 |
# they may not be initializable.
|
|
1184 |
return
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1185 |
t = self.get_transport() |
1841.2.2
by Jelmer Vernooij
Add more tests for create_repository(). |
1186 |
made_control = self.bzrdir_format.initialize(t.base) |
1187 |
try: |
|
1188 |
made_repo = made_control.create_repository(shared=True) |
|
1189 |
except errors.IncompatibleFormat: |
|
1190 |
# Old bzrdir formats don't support shared repositories
|
|
1191 |
# and should raise IncompatibleFormat
|
|
1192 |
return
|
|
1193 |
self.assertTrue(made_repo.is_shared()) |
|
1194 |
||
1195 |
def test_create_repository_nonshared(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1196 |
# a bzrdir can create a non-shared repository
|
1841.2.2
by Jelmer Vernooij
Add more tests for create_repository(). |
1197 |
if not self.bzrdir_format.is_supported(): |
1198 |
# unsupported formats are not loopback testable
|
|
1199 |
# because the default open will not open them and
|
|
1200 |
# they may not be initializable.
|
|
1201 |
return
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1202 |
t = self.get_transport() |
1841.2.2
by Jelmer Vernooij
Add more tests for create_repository(). |
1203 |
made_control = self.bzrdir_format.initialize(t.base) |
1204 |
made_repo = made_control.create_repository(shared=False) |
|
1205 |
self.assertFalse(made_repo.is_shared()) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1206 |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1207 |
def test_open_repository(self): |
1208 |
if not self.bzrdir_format.is_supported(): |
|
1209 |
# unsupported formats are not loopback testable
|
|
1210 |
# because the default open will not open them and
|
|
1211 |
# they may not be initializable.
|
|
1212 |
return
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1213 |
t = self.get_transport() |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1214 |
made_control = self.bzrdir_format.initialize(t.base) |
1215 |
made_repo = made_control.create_repository() |
|
1216 |
opened_repo = made_control.open_repository() |
|
1217 |
self.assertEqual(made_control, opened_repo.bzrdir) |
|
1218 |
self.failUnless(isinstance(opened_repo, made_repo.__class__)) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1219 |
self.failUnless(isinstance(opened_repo._format, made_repo._format.__class__)) |
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1220 |
|
1221 |
def test_create_workingtree(self): |
|
1222 |
# a bzrdir can construct a working tree for itself.
|
|
1223 |
if not self.bzrdir_format.is_supported(): |
|
1224 |
# unsupported formats are not loopback testable
|
|
1225 |
# because the default open will not open them and
|
|
1226 |
# they may not be initializable.
|
|
1227 |
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. |
1228 |
t = self.get_transport() |
1910.5.9
by Andrew Bennetts
Move stuff out of a try block that doesn't need to be there. |
1229 |
made_control = self.bzrdir_format.initialize(t.base) |
1230 |
made_repo = made_control.create_repository() |
|
1231 |
made_branch = made_control.create_branch() |
|
1910.5.11
by Andrew Bennetts
Use createWorkingTreeOrSkip helper in test_create_workingtree. |
1232 |
made_tree = self.createWorkingTreeOrSkip(made_control) |
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1233 |
self.failUnless(isinstance(made_tree, workingtree.WorkingTree)) |
1234 |
self.assertEqual(made_control, made_tree.bzrdir) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1235 |
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1236 |
def test_create_workingtree_revision(self): |
1237 |
# 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. |
1238 |
t = self.get_transport() |
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1239 |
source = self.make_branch_and_tree('source') |
1240 |
source.commit('a', rev_id='a', allow_pointless=True) |
|
1241 |
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. |
1242 |
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. |
1243 |
t_new = t.clone('new') |
1244 |
made_control = self.bzrdir_format.initialize_on_transport(t_new) |
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1245 |
source.branch.repository.clone(made_control) |
1246 |
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. |
1247 |
try: |
1248 |
made_tree = made_control.create_workingtree(revision_id='a') |
|
5418.3.1
by Jelmer Vernooij
Cope with control directories that are local but can't have working trees. |
1249 |
except (errors.NotLocalUrl, errors.UnsupportedOperation): |
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. |
1250 |
raise TestSkipped("Can't make working tree on transport %r" % t) |
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
1251 |
self.assertEqual(['a'], made_tree.get_parent_ids()) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1252 |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1253 |
def test_open_workingtree(self): |
1254 |
if not self.bzrdir_format.is_supported(): |
|
1255 |
# unsupported formats are not loopback testable
|
|
1256 |
# because the default open will not open them and
|
|
1257 |
# they may not be initializable.
|
|
1258 |
return
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
1259 |
# 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. |
1260 |
# format 6 bzrdirs
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
1261 |
t = self.get_transport() |
1262 |
try: |
|
1263 |
made_control = self.bzrdir_format.initialize(t.base) |
|
1264 |
made_repo = made_control.create_repository() |
|
1265 |
made_branch = made_control.create_branch() |
|
1266 |
made_tree = made_control.create_workingtree() |
|
5418.3.1
by Jelmer Vernooij
Cope with control directories that are local but can't have working trees. |
1267 |
except (errors.NotLocalUrl, errors.UnsupportedOperation): |
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
1268 |
raise TestSkipped("Can't initialize %r on transport %r" |
1269 |
% (self.bzrdir_format, t)) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1270 |
opened_tree = made_control.open_workingtree() |
1271 |
self.assertEqual(made_control, opened_tree.bzrdir) |
|
1272 |
self.failUnless(isinstance(opened_tree, made_tree.__class__)) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1273 |
self.failUnless(isinstance(opened_tree._format, made_tree._format.__class__)) |
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1274 |
|
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. |
1275 |
def test_root_transport(self): |
1276 |
dir = self.make_bzrdir('.') |
|
1277 |
self.assertEqual(dir.root_transport.base, |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1278 |
self.get_transport().base) |
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. |
1279 |
|
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. |
1280 |
def test_find_repository_no_repo_under_standalone_branch(self): |
1281 |
# finding a repo stops at standalone branches even if there is a
|
|
1282 |
# higher repository available.
|
|
1283 |
try: |
|
1284 |
repo = self.make_repository('.', shared=True) |
|
1285 |
except errors.IncompatibleFormat: |
|
1286 |
# need a shared repository to test this.
|
|
1287 |
return
|
|
1288 |
url = self.get_url('intermediate') |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1289 |
t = self.get_transport() |
1290 |
t.mkdir('intermediate') |
|
1291 |
t.mkdir('intermediate/child') |
|
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. |
1292 |
made_control = self.bzrdir_format.initialize(url) |
1293 |
made_control.create_repository() |
|
1294 |
innermost_control = self.bzrdir_format.initialize( |
|
1295 |
self.get_url('intermediate/child')) |
|
1296 |
try: |
|
1297 |
child_repo = innermost_control.open_repository() |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1298 |
# if there is a repository, then the format cannot ever hit this
|
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. |
1299 |
# code path.
|
1300 |
return
|
|
1301 |
except errors.NoRepositoryPresent: |
|
1302 |
pass
|
|
1303 |
self.assertRaises(errors.NoRepositoryPresent, |
|
1304 |
innermost_control.find_repository) |
|
1305 |
||
1306 |
def test_find_repository_containing_shared_repository(self): |
|
1307 |
# find repo inside a shared repo with an empty control dir
|
|
1308 |
# returns the shared repo.
|
|
1309 |
try: |
|
1310 |
repo = self.make_repository('.', shared=True) |
|
1311 |
except errors.IncompatibleFormat: |
|
1312 |
# need a shared repository to test this.
|
|
1313 |
return
|
|
1314 |
url = self.get_url('childbzrdir') |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1315 |
self.get_transport().mkdir('childbzrdir') |
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 |
made_control = self.bzrdir_format.initialize(url) |
1317 |
try: |
|
1318 |
child_repo = made_control.open_repository() |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1319 |
# if there is a repository, then the format cannot ever hit this
|
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. |
1320 |
# code path.
|
1321 |
return
|
|
1322 |
except errors.NoRepositoryPresent: |
|
1323 |
pass
|
|
1324 |
found_repo = made_control.find_repository() |
|
1325 |
self.assertEqual(repo.bzrdir.root_transport.base, |
|
1326 |
found_repo.bzrdir.root_transport.base) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1327 |
|
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. |
1328 |
def test_find_repository_standalone_with_containing_shared_repository(self): |
1329 |
# find repo inside a standalone repo inside a shared repo finds the standalone repo
|
|
1330 |
try: |
|
1331 |
containing_repo = self.make_repository('.', shared=True) |
|
1332 |
except errors.IncompatibleFormat: |
|
1333 |
# need a shared repository to test this.
|
|
1334 |
return
|
|
1335 |
child_repo = self.make_repository('childrepo') |
|
1336 |
opened_control = bzrdir.BzrDir.open(self.get_url('childrepo')) |
|
1337 |
found_repo = opened_control.find_repository() |
|
1338 |
self.assertEqual(child_repo.bzrdir.root_transport.base, |
|
1339 |
found_repo.bzrdir.root_transport.base) |
|
1340 |
||
1341 |
def test_find_repository_shared_within_shared_repository(self): |
|
1342 |
# find repo at a shared repo inside a shared repo finds the inner repo
|
|
1343 |
try: |
|
1344 |
containing_repo = self.make_repository('.', shared=True) |
|
1345 |
except errors.IncompatibleFormat: |
|
1346 |
# need a shared repository to test this.
|
|
1347 |
return
|
|
1348 |
url = self.get_url('childrepo') |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1349 |
self.get_transport().mkdir('childrepo') |
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. |
1350 |
child_control = self.bzrdir_format.initialize(url) |
1351 |
child_repo = child_control.create_repository(shared=True) |
|
1352 |
opened_control = bzrdir.BzrDir.open(self.get_url('childrepo')) |
|
1353 |
found_repo = opened_control.find_repository() |
|
1354 |
self.assertEqual(child_repo.bzrdir.root_transport.base, |
|
1355 |
found_repo.bzrdir.root_transport.base) |
|
1356 |
self.assertNotEqual(child_repo.bzrdir.root_transport.base, |
|
1357 |
containing_repo.bzrdir.root_transport.base) |
|
1358 |
||
1359 |
def test_find_repository_with_nested_dirs_works(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1360 |
# find repo inside a bzrdir inside a bzrdir inside a shared repo
|
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. |
1361 |
# finds the outer shared repo.
|
1362 |
try: |
|
1363 |
repo = self.make_repository('.', shared=True) |
|
1364 |
except errors.IncompatibleFormat: |
|
1365 |
# need a shared repository to test this.
|
|
1366 |
return
|
|
1367 |
url = self.get_url('intermediate') |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1368 |
t = self.get_transport() |
1369 |
t.mkdir('intermediate') |
|
1370 |
t.mkdir('intermediate/child') |
|
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. |
1371 |
made_control = self.bzrdir_format.initialize(url) |
1372 |
try: |
|
1373 |
child_repo = made_control.open_repository() |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1374 |
# if there is a repository, then the format cannot ever hit this
|
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. |
1375 |
# code path.
|
1376 |
return
|
|
1377 |
except errors.NoRepositoryPresent: |
|
1378 |
pass
|
|
1379 |
innermost_control = self.bzrdir_format.initialize( |
|
1380 |
self.get_url('intermediate/child')) |
|
1381 |
try: |
|
1382 |
child_repo = innermost_control.open_repository() |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1383 |
# if there is a repository, then the format cannot ever hit this
|
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. |
1384 |
# code path.
|
1385 |
return
|
|
1386 |
except errors.NoRepositoryPresent: |
|
1387 |
pass
|
|
1388 |
found_repo = innermost_control.find_repository() |
|
1389 |
self.assertEqual(repo.bzrdir.root_transport.base, |
|
1390 |
found_repo.bzrdir.root_transport.base) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1391 |
|
1534.5.16
by Robert Collins
Review feedback. |
1392 |
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. |
1393 |
# check that we can ask an instance if its upgradable
|
1394 |
dir = self.make_bzrdir('.') |
|
1534.5.16
by Robert Collins
Review feedback. |
1395 |
if dir.can_convert_format(): |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1396 |
# if its default updatable there must be an updater
|
2204.4.14
by Aaron Bentley
lastest -> latest |
1397 |
# (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 |
1398 |
# available
|
1399 |
self.assertTrue(isinstance(dir._format.get_converter( |
|
5692.1.1
by Jelmer Vernooij
Move Converter (which is generic) from bzrlib.bzrdir to bzrlib.controldir. |
1400 |
format=dir._format), controldir.Converter)) |
3943.2.5
by Martin Pool
deprecate needs_format_conversion(format=None) |
1401 |
dir.needs_format_conversion( |
5363.2.22
by Jelmer Vernooij
Provide bzrlib.bzrdir.format_registry. |
1402 |
controldir.ControlDirFormat.get_default_format()) |
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. |
1403 |
|
3872.3.3
by Jelmer Vernooij
Add test for backup_bzrdir. |
1404 |
def test_backup_copies_existing(self): |
1405 |
tree = self.make_branch_and_tree('test') |
|
1406 |
self.build_tree(['test/a']) |
|
1407 |
tree.add(['a'], ['a-id']) |
|
1408 |
tree.commit('some data to be copied.') |
|
1409 |
old_url, new_url = tree.bzrdir.backup_bzrdir() |
|
1410 |
old_path = urlutils.local_path_from_url(old_url) |
|
1411 |
new_path = urlutils.local_path_from_url(new_url) |
|
1412 |
self.failUnlessExists(old_path) |
|
1413 |
self.failUnlessExists(new_path) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1414 |
for (((dir_relpath1, _), entries1), |
3872.3.3
by Jelmer Vernooij
Add test for backup_bzrdir. |
1415 |
((dir_relpath2, _), entries2)) in izip( |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1416 |
osutils.walkdirs(old_path), |
3872.3.3
by Jelmer Vernooij
Add test for backup_bzrdir. |
1417 |
osutils.walkdirs(new_path)): |
1418 |
self.assertEquals(dir_relpath1, dir_relpath2) |
|
1419 |
for f1, f2 in zip(entries1, entries2): |
|
1420 |
self.assertEquals(f1[0], f2[0]) |
|
1421 |
self.assertEquals(f1[2], f2[2]) |
|
1422 |
if f1[2] == "file": |
|
1423 |
osutils.compare_files(open(f1[4]), open(f2[4])) |
|
1424 |
||
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
1425 |
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. |
1426 |
"""Does an available updater work?"""
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
1427 |
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. |
1428 |
# 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. |
1429 |
dir.create_repository() |
1430 |
dir.create_branch() |
|
1910.4.13
by Andrew Bennetts
Slightly more consistent names. |
1431 |
self.createWorkingTreeOrSkip(dir) |
1534.5.16
by Robert Collins
Review feedback. |
1432 |
if dir.can_convert_format(): |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1433 |
# if its default updatable there must be an updater
|
2204.4.14
by Aaron Bentley
lastest -> latest |
1434 |
# (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 |
1435 |
# available
|
1594.1.3
by Robert Collins
Fixup pb usage to use nested_progress_bar. |
1436 |
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. |
1437 |
try: |
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
1438 |
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. |
1439 |
finally: |
1594.1.3
by Robert Collins
Fixup pb usage to use nested_progress_bar. |
1440 |
pb.finished() |
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
1441 |
# and it should pass 'check' now.
|
4332.3.36
by Robert Collins
Silence a warning in test_bzrdir. |
1442 |
check.check_dwim(self.get_url('.'), False, True, True) |
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
1443 |
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1444 |
def test_format_description(self): |
1445 |
dir = self.make_bzrdir('.') |
|
1446 |
text = dir._format.get_format_description() |
|
1447 |
self.failUnless(len(text)) |
|
1448 |
||
2830.1.3
by Ian Clatworthy
test that bzrdir retiring fails as expected once limit reached |
1449 |
|
5363.2.18
by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir. |
1450 |
class TestBreakLock(TestCaseWithControlDir): |
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1451 |
|
1452 |
def test_break_lock_empty(self): |
|
1453 |
# break lock on an empty bzrdir should work silently.
|
|
1454 |
dir = self.make_bzrdir('.') |
|
1455 |
try: |
|
1456 |
dir.break_lock() |
|
1457 |
except NotImplementedError: |
|
1458 |
pass
|
|
1459 |
||
1460 |
def test_break_lock_repository(self): |
|
1461 |
# break lock with just a repo should unlock the repo.
|
|
1462 |
repo = self.make_repository('.') |
|
1463 |
repo.lock_write() |
|
3015.2.2
by Robert Collins
Make test_bzrdir work with packs - which always change the pack value during clone. |
1464 |
lock_repo = repo.bzrdir.open_repository() |
1465 |
if not lock_repo.get_physical_lock_status(): |
|
1466 |
# This bzrdir's default repository does not physically lock things
|
|
1467 |
# and thus this interaction cannot be tested at the interface
|
|
1468 |
# level.
|
|
1469 |
repo.unlock() |
|
1470 |
return
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1471 |
# only one yes needed here: it should only be unlocking
|
1472 |
# the repo
|
|
4449.3.24
by Martin Pool
Fix bzrdir break-lock tests that rely on SilentUIFactory reading stdin |
1473 |
bzrlib.ui.ui_factory = CannedInputUIFactory([True]) |
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1474 |
try: |
1475 |
repo.bzrdir.break_lock() |
|
1476 |
except NotImplementedError: |
|
1477 |
# this bzrdir does not implement break_lock - so we cant test it.
|
|
1478 |
repo.unlock() |
|
1479 |
return
|
|
1480 |
lock_repo.lock_write() |
|
1481 |
lock_repo.unlock() |
|
1482 |
self.assertRaises(errors.LockBroken, repo.unlock) |
|
1483 |
||
1484 |
def test_break_lock_branch(self): |
|
1485 |
# break lock with just a repo should unlock the branch.
|
|
1486 |
# and not directly try the repository.
|
|
1487 |
# we test this by making a branch reference to a branch
|
|
1488 |
# and repository in another bzrdir
|
|
1489 |
# for pre-metadir formats this will fail, thats ok.
|
|
1490 |
master = self.make_branch('branch') |
|
1491 |
thisdir = self.make_bzrdir('this') |
|
1492 |
try: |
|
1493 |
bzrlib.branch.BranchReferenceFormat().initialize( |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
1494 |
thisdir, target_branch=master) |
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1495 |
except errors.IncompatibleFormat: |
1496 |
return
|
|
1497 |
unused_repo = thisdir.create_repository() |
|
1498 |
master.lock_write() |
|
1499 |
unused_repo.lock_write() |
|
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
1500 |
try: |
1501 |
# two yes's : branch and repository. If the repo in this
|
|
1502 |
# dir is inappropriately accessed, 3 will be needed, and
|
|
1503 |
# we'll see that because the stream will be fully consumed
|
|
4449.3.24
by Martin Pool
Fix bzrdir break-lock tests that rely on SilentUIFactory reading stdin |
1504 |
bzrlib.ui.ui_factory = CannedInputUIFactory([True, True, True]) |
3015.2.2
by Robert Collins
Make test_bzrdir work with packs - which always change the pack value during clone. |
1505 |
# determine if the repository will have been locked;
|
1506 |
this_repo_locked = \ |
|
1507 |
thisdir.open_repository().get_physical_lock_status() |
|
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
1508 |
master.bzrdir.break_lock() |
3015.2.2
by Robert Collins
Make test_bzrdir work with packs - which always change the pack value during clone. |
1509 |
if this_repo_locked: |
1510 |
# only two ys should have been read
|
|
4449.3.24
by Martin Pool
Fix bzrdir break-lock tests that rely on SilentUIFactory reading stdin |
1511 |
self.assertEqual([True], |
1512 |
bzrlib.ui.ui_factory.responses) |
|
3015.2.2
by Robert Collins
Make test_bzrdir work with packs - which always change the pack value during clone. |
1513 |
else: |
1514 |
# only one y should have been read
|
|
4449.3.24
by Martin Pool
Fix bzrdir break-lock tests that rely on SilentUIFactory reading stdin |
1515 |
self.assertEqual([True, True], |
1516 |
bzrlib.ui.ui_factory.responses) |
|
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
1517 |
# we should be able to lock a newly opened branch now
|
1518 |
branch = master.bzrdir.open_branch() |
|
1519 |
branch.lock_write() |
|
1520 |
branch.unlock() |
|
3015.2.2
by Robert Collins
Make test_bzrdir work with packs - which always change the pack value during clone. |
1521 |
if this_repo_locked: |
1522 |
# we should not be able to lock the repository in thisdir as
|
|
1523 |
# its still held by the explicit lock we took, and the break
|
|
1524 |
# lock should not have touched it.
|
|
1525 |
repo = thisdir.open_repository() |
|
3287.4.2
by Martin Pool
Change more tests to use reduceLockdirTimeout |
1526 |
self.assertRaises(errors.LockContention, repo.lock_write) |
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
1527 |
finally: |
1528 |
unused_repo.unlock() |
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1529 |
self.assertRaises(errors.LockBroken, master.unlock) |
1530 |
||
1531 |
def test_break_lock_tree(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1532 |
# break lock with a tree should unlock the tree but not try the
|
1533 |
# branch explicitly. However this is very hard to test for as we
|
|
1534 |
# dont have a tree reference class, nor is one needed;
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1535 |
# the worst case if this code unlocks twice is an extra question
|
1536 |
# being asked.
|
|
1537 |
tree = self.make_branch_and_tree('.') |
|
1538 |
tree.lock_write() |
|
1539 |
# three yes's : tree, branch and repository.
|
|
4449.3.24
by Martin Pool
Fix bzrdir break-lock tests that rely on SilentUIFactory reading stdin |
1540 |
bzrlib.ui.ui_factory = CannedInputUIFactory([True, True, True]) |
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1541 |
try: |
1542 |
tree.bzrdir.break_lock() |
|
2255.2.145
by Robert Collins
Support unbreakable locks for trees. |
1543 |
except (NotImplementedError, errors.LockActive): |
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1544 |
# bzrdir does not support break_lock
|
2255.2.145
by Robert Collins
Support unbreakable locks for trees. |
1545 |
# or one of the locked objects (currently only tree does this)
|
1546 |
# raised a LockActive because we do still have a live locked
|
|
1547 |
# object.
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1548 |
tree.unlock() |
1549 |
return
|
|
4449.3.24
by Martin Pool
Fix bzrdir break-lock tests that rely on SilentUIFactory reading stdin |
1550 |
self.assertEqual([True], |
1551 |
bzrlib.ui.ui_factory.responses) |
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1552 |
lock_tree = tree.bzrdir.open_workingtree() |
1553 |
lock_tree.lock_write() |
|
1554 |
lock_tree.unlock() |
|
1555 |
self.assertRaises(errors.LockBroken, tree.unlock) |
|
1556 |
||
1557 |
||
5363.2.18
by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir. |
1558 |
class TestTransportConfig(TestCaseWithControlDir): |
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
1559 |
|
1560 |
def test_get_config(self): |
|
1561 |
my_dir = self.make_bzrdir('.') |
|
1562 |
config = my_dir.get_config() |
|
4288.1.6
by Robert Collins
Fix bzrdir implementation tests to handle read only bzrdir configs. |
1563 |
try: |
1564 |
config.set_default_stack_on('http://example.com') |
|
1565 |
except errors.BzrError, e: |
|
1566 |
if 'Cannot set config' in str(e): |
|
1567 |
self.assertFalse( |
|
1568 |
isinstance(my_dir, (bzrdir.BzrDirMeta1, RemoteBzrDir)), |
|
1569 |
"%r should support configs" % my_dir) |
|
1570 |
raise TestNotApplicable( |
|
1571 |
'This BzrDir format does not support configs.') |
|
1572 |
else: |
|
1573 |
raise
|
|
3242.3.14
by Aaron Bentley
Make BzrDirConfig use TransportConfig |
1574 |
self.assertEqual('http://example.com', config.get_default_stack_on()) |
3567.1.2
by Michael Hudson
fix test some more |
1575 |
my_dir2 = bzrdir.BzrDir.open(self.get_url('.')) |
3242.3.36
by Aaron Bentley
Updates from review comments |
1576 |
config2 = my_dir2.get_config() |
3242.3.14
by Aaron Bentley
Make BzrDirConfig use TransportConfig |
1577 |
self.assertEqual('http://example.com', config2.get_default_stack_on()) |
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
1578 |
|
1579 |
||
5363.2.22
by Jelmer Vernooij
Provide bzrlib.bzrdir.format_registry. |
1580 |
class ChrootedControlDirTests(ChrootedTestCase): |
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. |
1581 |
|
1582 |
def test_find_repository_no_repository(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1583 |
# loopback test to check the current format fails to find a
|
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. |
1584 |
# share repository correctly.
|
1585 |
if not self.bzrdir_format.is_supported(): |
|
1586 |
# unsupported formats are not loopback testable
|
|
1587 |
# because the default open will not open them and
|
|
1588 |
# they may not be initializable.
|
|
1589 |
return
|
|
1590 |
# 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 :). |
1591 |
# - do the vfs initialisation over the basic vfs transport
|
1592 |
# XXX: TODO this should become a 'bzrdirlocation' api call.
|
|
1593 |
url = self.get_vfs_only_url('subdir') |
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
1594 |
transport.get_transport(self.get_vfs_only_url()).mkdir('subdir') |
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
1595 |
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. |
1596 |
try: |
1597 |
repo = made_control.open_repository() |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1598 |
# if there is a repository, then the format cannot ever hit this
|
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. |
1599 |
# code path.
|
1600 |
return
|
|
1601 |
except errors.NoRepositoryPresent: |
|
1602 |
pass
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
1603 |
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. |
1604 |
self.assertRaises(errors.NoRepositoryPresent, |
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
1605 |
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. |
1606 |
|
5158.6.1
by Martin Pool
Add ControlComponent interface and make BzrDir implement it |
1607 |
|
5363.2.22
by Jelmer Vernooij
Provide bzrlib.bzrdir.format_registry. |
1608 |
class TestControlDirControlComponent(TestCaseWithControlDir): |
1609 |
"""ControlDir implementations adequately implement ControlComponent."""
|
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
1610 |
|
5158.6.1
by Martin Pool
Add ControlComponent interface and make BzrDir implement it |
1611 |
def test_urls(self): |
1612 |
bd = self.make_bzrdir('bd') |
|
1613 |
self.assertIsInstance(bd.user_url, str) |
|
1614 |
self.assertEqual(bd.user_url, bd.user_transport.base) |
|
1615 |
# for all current bzrdir implementations the user dir must be
|
|
1616 |
# above the control dir but we might need to relax that?
|
|
1617 |
self.assertEqual(bd.control_url.find(bd.user_url), 0) |
|
1618 |
self.assertEqual(bd.control_url, bd.control_transport.base) |