111
112
branch.set_push_location('sftp://push')
112
113
self.assertEqual('sftp://push',
113
114
reconfiguration._select_bind_location())
114
branch.set_bound_location('bzr:old-bound')
115
branch.set_bound_location('bzr://foo/old-bound')
115
116
branch.set_bound_location(None)
116
self.assertEqual('bzr:old-bound',
117
self.assertEqual('bzr://foo/old-bound',
118
reconfiguration._select_bind_location())
119
branch.set_bound_location('bzr://foo/cur-bound')
120
self.assertEqual('bzr://foo/cur-bound',
117
121
reconfiguration._select_bind_location())
118
122
reconfiguration.new_bound_location = 'ftp://user-specified'
119
123
self.assertEqual('ftp://user-specified',
144
148
reconfiguration.apply()
150
def test_tree_to_lightweight_checkout(self):
151
# A tree with no related branches and no supplied bind location cannot
153
parent = self.make_branch('parent')
155
tree = self.make_branch_and_tree('tree')
156
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
158
self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
159
# setting a parent allows it to become a checkout
160
tree.branch.set_parent(parent.base)
161
reconfiguration.apply()
162
# supplying a location allows it to become a checkout
163
tree2 = self.make_branch_and_tree('tree2')
164
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
165
tree2.bzrdir, parent.base)
166
reconfiguration.apply()
146
168
def test_checkout_to_checkout(self):
147
169
parent = self.make_branch('parent')
148
170
checkout = parent.create_checkout('checkout')
149
171
self.assertRaises(errors.AlreadyCheckout,
150
172
reconfigure.Reconfigure.to_checkout, checkout.bzrdir)
174
def test_checkout_to_lightweight(self):
175
parent = self.make_branch('parent')
176
checkout = parent.create_checkout('checkout')
177
checkout.commit('test', rev_id='new-commit', local=True)
178
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
180
reconfiguration.apply()
181
wt = checkout.bzrdir.open_workingtree()
182
self.assertTrue(parent.repository.has_same_location(
183
wt.branch.repository))
184
parent.repository.get_revision('new-commit')
185
self.assertRaises(errors.NoRepositoryPresent,
186
checkout.bzrdir.open_repository)
188
def test_branch_to_lightweight_checkout(self):
189
parent = self.make_branch('parent')
190
child = parent.bzrdir.sprout('child').open_workingtree()
191
child.commit('test', rev_id='new-commit')
192
child.bzrdir.destroy_workingtree()
193
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
195
reconfiguration.apply()
196
wt = child.bzrdir.open_workingtree()
197
self.assertTrue(parent.repository.has_same_location(
198
wt.branch.repository))
199
parent.repository.get_revision('new-commit')
200
self.assertRaises(errors.NoRepositoryPresent,
201
child.bzrdir.open_repository)
203
def test_lightweight_checkout_to_lightweight_checkout(self):
204
parent = self.make_branch('parent')
205
checkout = parent.create_checkout('checkout', lightweight=True)
206
self.assertRaises(errors.AlreadyLightweightCheckout,
207
reconfigure.Reconfigure.to_lightweight_checkout,
210
def test_repo_to_tree(self):
211
repo = self.make_repository('repo')
212
reconfiguration = reconfigure.Reconfigure.to_tree(repo.bzrdir)
213
reconfiguration.apply()
214
workingtree.WorkingTree.open('repo')
216
def test_shared_repo_to_lightweight_checkout(self):
217
repo = self.make_repository('repo', shared=True)
218
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
220
self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
221
branch = self.make_branch('branch')
222
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
223
repo.bzrdir, 'branch')
224
reconfiguration.apply()
225
workingtree.WorkingTree.open('repo')
226
repository.Repository.open('repo')
228
def test_unshared_repo_to_lightweight_checkout(self):
229
repo = self.make_repository('repo', shared=False)
230
branch = self.make_branch('branch')
231
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
232
repo.bzrdir, 'branch')
233
reconfiguration.apply()
234
workingtree.WorkingTree.open('repo')
235
self.assertRaises(errors.NoRepositoryPresent,
236
repository.Repository.open, 'repo')