197
197
self.assertRaises(errors.AlreadyCheckout,
198
198
reconfigure.Reconfigure.to_checkout, checkout.bzrdir)
200
def make_unsynced_checkout(self):
200
def test_checkout_to_lightweight(self):
201
201
parent = self.make_branch('parent')
202
202
checkout = parent.create_checkout('checkout')
203
203
checkout.commit('test', rev_id='new-commit', local=True)
204
204
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
206
return checkout, parent, reconfiguration
208
def test_unsynced_checkout_to_lightweight(self):
209
checkout, parent, reconfiguration = self.make_unsynced_checkout()
210
self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply)
212
def test_synced_checkout_to_lightweight(self):
213
checkout, parent, reconfiguration = self.make_unsynced_checkout()
214
parent.pull(checkout.branch)
215
206
reconfiguration.apply()
216
207
wt = checkout.bzrdir.open_workingtree()
217
208
self.assertTrue(parent.repository.has_same_location(
296
286
workingtree.WorkingTree.open('repo')
297
287
self.assertRaises(errors.NoRepositoryPresent,
298
288
repository.Repository.open, 'repo')
300
def test_standalone_to_use_shared(self):
301
self.build_tree(['root/'])
302
tree = self.make_branch_and_tree('root/tree')
303
tree.commit('Hello', rev_id='hello-id')
304
repo = self.make_repository('root', shared=True)
305
reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.bzrdir)
306
reconfiguration.apply()
307
tree = workingtree.WorkingTree.open('root/tree')
308
self.assertTrue(repo.has_same_location(tree.branch.repository))
309
self.assertEqual('Hello', repo.get_revision('hello-id').message)
311
def add_dead_head(self, tree):
312
revno, revision_id = tree.branch.last_revision_info()
313
tree.commit('Dead head', rev_id='dead-head-id')
314
tree.branch.set_last_revision_info(revno, revision_id)
315
tree.set_last_revision(revision_id)
317
def test_standalone_to_use_shared_preserves_dead_heads(self):
318
self.build_tree(['root/'])
319
tree = self.make_branch_and_tree('root/tree')
320
self.add_dead_head(tree)
321
tree.commit('Hello', rev_id='hello-id')
322
repo = self.make_repository('root', shared=True)
323
reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.bzrdir)
324
reconfiguration.apply()
325
tree = workingtree.WorkingTree.open('root/tree')
326
message = repo.get_revision('dead-head-id').message
327
self.assertEqual('Dead head', message)
329
def make_repository_tree(self):
330
self.build_tree(['root/'])
331
repo = self.make_repository('root', shared=True)
332
tree = self.make_branch_and_tree('root/tree')
333
reconfigure.Reconfigure.to_use_shared(tree.bzrdir).apply()
334
return workingtree.WorkingTree.open('root/tree')
336
def test_use_shared_to_use_shared(self):
337
tree = self.make_repository_tree()
338
self.assertRaises(errors.AlreadyUsingShared,
339
reconfigure.Reconfigure.to_use_shared, tree.bzrdir)
341
def test_use_shared_to_standalone(self):
342
tree = self.make_repository_tree()
343
tree.commit('Hello', rev_id='hello-id')
344
reconfigure.Reconfigure.to_standalone(tree.bzrdir).apply()
345
tree = workingtree.WorkingTree.open('root/tree')
346
repo = tree.branch.repository
347
self.assertEqual(repo.bzrdir.root_transport.base,
348
tree.bzrdir.root_transport.base)
349
self.assertEqual('Hello', repo.get_revision('hello-id').message)
351
def test_use_shared_to_standalone_preserves_dead_heads(self):
352
tree = self.make_repository_tree()
353
self.add_dead_head(tree)
354
tree.commit('Hello', rev_id='hello-id')
355
reconfigure.Reconfigure.to_standalone(tree.bzrdir).apply()
356
tree = workingtree.WorkingTree.open('root/tree')
357
repo = tree.branch.repository
358
self.assertRaises(errors.NoSuchRevision, repo.get_revision,
361
def test_standalone_to_standalone(self):
362
tree = self.make_branch_and_tree('tree')
363
self.assertRaises(errors.AlreadyStandalone,
364
reconfigure.Reconfigure.to_standalone, tree.bzrdir)
366
def make_unsynced_branch_reconfiguration(self):
367
parent = self.make_branch_and_tree('parent')
368
parent.commit('commit 1')
369
child = parent.bzrdir.sprout('child').open_workingtree()
370
child.commit('commit 2')
371
return reconfigure.Reconfigure.to_lightweight_checkout(child.bzrdir)
373
def test_unsynced_branch_to_lightweight_checkout_unforced(self):
374
reconfiguration = self.make_unsynced_branch_reconfiguration()
375
self.assertRaises(errors.UnsyncedBranches, reconfiguration.apply)
377
def test_unsynced_branch_to_lightweight_checkout_forced(self):
378
reconfiguration = self.make_unsynced_branch_reconfiguration()
379
reconfiguration.apply(force=True)