73
73
def test_checkout_to_branch(self):
74
74
branch = self.make_branch('branch')
75
75
checkout = branch.create_checkout('checkout')
76
reconfiguration = reconfigure.Reconfigure.to_branch(checkout.controldir)
76
reconfiguration = reconfigure.Reconfigure.to_branch(
77
78
reconfiguration.apply()
78
79
reconfigured = controldir.ControlDir.open('checkout').open_branch()
79
80
self.assertIs(None, reconfigured.get_bound_location())
82
83
branch = self.make_branch('branch')
83
84
checkout = branch.create_checkout('checkout', lightweight=True)
84
85
checkout.commit('first commit', rev_id=b'rev1')
85
reconfiguration = reconfigure.Reconfigure.to_branch(checkout.controldir)
86
reconfiguration = reconfigure.Reconfigure.to_branch(
86
88
return reconfiguration, checkout
88
90
def test_lightweight_checkout_to_branch(self):
107
109
def prepare_lightweight_checkout_to_checkout(self):
108
110
branch = self.make_branch('branch')
109
111
checkout = branch.create_checkout('checkout', lightweight=True)
110
reconfiguration = reconfigure.Reconfigure.to_checkout(checkout.controldir)
112
reconfiguration = reconfigure.Reconfigure.to_checkout(
111
114
return reconfiguration, checkout
113
116
def test_lightweight_checkout_to_checkout(self):
137
140
def test_branch_to_tree(self):
138
141
branch = self.make_branch('branch')
139
reconfiguration=reconfigure.Reconfigure.to_tree(branch.controldir)
142
reconfiguration = reconfigure.Reconfigure.to_tree(branch.controldir)
140
143
reconfiguration.apply()
141
144
branch.controldir.open_workingtree()
309
312
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
311
314
self.assertRaises(reconfigure.NoBindLocation, reconfiguration.apply)
312
branch = self.make_branch('branch')
315
self.make_branch('branch')
313
316
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
314
317
repo.controldir, 'branch')
315
318
reconfiguration.apply()
319
322
def test_unshared_repo_to_lightweight_checkout(self):
320
323
repo = self.make_repository('repo', shared=False)
321
branch = self.make_branch('branch')
324
self.make_branch('branch')
322
325
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
323
326
repo.controldir, 'branch')
324
327
reconfiguration.apply()
331
334
tree = self.make_branch_and_tree('root/tree')
332
335
tree.commit('Hello', rev_id=b'hello-id')
333
336
repo = self.make_repository('root', shared=True)
334
reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.controldir)
337
reconfiguration = reconfigure.Reconfigure.to_use_shared(
335
339
reconfiguration.apply()
336
340
tree = workingtree.WorkingTree.open('root/tree')
337
341
self.assertTrue(repo.has_same_location(tree.branch.repository))
349
353
self.add_dead_head(tree)
350
354
tree.commit('Hello', rev_id=b'hello-id')
351
355
repo = self.make_repository('root', shared=True)
352
reconfiguration = reconfigure.Reconfigure.to_use_shared(tree.controldir)
356
reconfiguration = reconfigure.Reconfigure.to_use_shared(
353
358
reconfiguration.apply()
354
359
tree = workingtree.WorkingTree.open('root/tree')
355
360
message = repo.get_revision(b'dead-head-id').message
358
363
def make_repository_tree(self):
359
364
self.build_tree(['root/'])
360
repo = self.make_repository('root', shared=True)
365
self.make_repository('root', shared=True)
361
366
tree = self.make_branch_and_tree('root/tree')
362
367
reconfigure.Reconfigure.to_use_shared(tree.controldir).apply()
363
368
return workingtree.WorkingTree.open('root/tree')
429
434
def test_make_with_trees_already_with_trees(self):
430
435
repo = self.make_repository_with_without_trees(True)
431
436
e = self.assertRaises(reconfigure.AlreadyWithTrees,
432
reconfigure.Reconfigure.set_repository_trees, repo.controldir, True)
437
reconfigure.Reconfigure.set_repository_trees, repo.controldir, True)
433
438
self.assertContainsRe(str(e),
434
r"Shared repository '.*' already creates working trees.")
439
r"Shared repository '.*' already creates working trees.")
436
441
def test_make_without_trees_already_no_trees(self):
437
442
repo = self.make_repository_with_without_trees(False)
438
e = self.assertRaises(reconfigure.AlreadyWithNoTrees,
439
reconfigure.Reconfigure.set_repository_trees, repo.controldir, False)
440
self.assertContainsRe(str(e),
443
e = self.assertRaises(
444
reconfigure.AlreadyWithNoTrees,
445
reconfigure.Reconfigure.set_repository_trees, repo.controldir,
447
self.assertContainsRe(
441
449
r"Shared repository '.*' already doesn't create working trees.")
443
451
def test_repository_tree_reconfiguration_not_supported(self):
444
452
tree = self.make_branch_and_tree('tree')
445
e = self.assertRaises(reconfigure.ReconfigurationNotSupported,
446
reconfigure.Reconfigure.set_repository_trees, tree.controldir, None)
447
self.assertContainsRe(str(e),
448
r"Requested reconfiguration of '.*' is not supported.")
453
e = self.assertRaises(
454
reconfigure.ReconfigurationNotSupported,
455
reconfigure.Reconfigure.set_repository_trees, tree.controldir,
457
self.assertContainsRe(
458
str(e), r"Requested reconfiguration of '.*' is not supported.")
450
460
def test_lightweight_checkout_to_tree_preserves_reference_locations(self):
451
461
format = controldir.format_registry.make_controldir('1.9')