60
60
reconfiguration.apply()
61
61
self.assertIs(None, checkout.branch.get_bound_location())
63
def prepare_lightweight_checkout_to_branch(self):
64
branch = self.make_branch('branch')
65
checkout = branch.create_checkout('checkout', lightweight=True)
66
checkout.commit('first commit', rev_id='rev1')
67
reconfiguration = reconfigure.Reconfigure.to_branch(checkout.bzrdir)
68
return reconfiguration, checkout
63
70
def test_lightweight_checkout_to_branch(self):
64
branch = self.make_branch('branch')
65
checkout = branch.create_checkout('checkout', lightweight=True)
66
checkout.commit('first commit', rev_id='rev1')
67
reconfiguration = reconfigure.Reconfigure.to_branch(checkout.bzrdir)
71
reconfiguration, checkout = \
72
self.prepare_lightweight_checkout_to_branch()
68
73
reconfiguration.apply()
69
74
checkout_branch = checkout.bzrdir.open_branch()
70
75
self.assertEqual(checkout_branch.bzrdir.root_transport.base,
73
78
repo = checkout.bzrdir.open_repository()
74
79
repo.get_revision('rev1')
81
def test_lightweight_checkout_to_branch_tags(self):
82
reconfiguration, checkout = \
83
self.prepare_lightweight_checkout_to_branch()
84
checkout.branch.tags.set_tag('foo', 'bar')
85
reconfiguration.apply()
86
checkout_branch = checkout.bzrdir.open_branch()
87
self.assertEqual('bar', checkout_branch.tags.lookup_tag('foo'))
89
def prepare_lightweight_checkout_to_checkout(self):
90
branch = self.make_branch('branch')
91
checkout = branch.create_checkout('checkout', lightweight=True)
92
reconfiguration = reconfigure.Reconfigure.to_checkout(checkout.bzrdir)
93
return reconfiguration, checkout
76
95
def test_lightweight_checkout_to_checkout(self):
77
branch = self.make_branch('branch')
78
checkout = branch.create_checkout('checkout', lightweight=True)
79
reconfiguration = reconfigure.Reconfigure.to_checkout(checkout.bzrdir)
96
reconfiguration, checkout = \
97
self.prepare_lightweight_checkout_to_checkout()
80
98
reconfiguration.apply()
81
99
checkout_branch = checkout.bzrdir.open_branch()
82
100
self.assertIsNot(checkout_branch.get_bound_location(), None)
102
def test_lightweight_checkout_to_checkout_tags(self):
103
reconfiguration, checkout = \
104
self.prepare_lightweight_checkout_to_checkout()
105
checkout.branch.tags.set_tag('foo', 'bar')
106
reconfiguration.apply()
107
checkout_branch = checkout.bzrdir.open_branch()
108
self.assertEqual('bar', checkout_branch.tags.lookup_tag('foo'))
84
110
def test_lightweight_conversion_uses_shared_repo(self):
85
111
parent = self.make_branch('parent')
86
112
shared_repo = self.make_repository('repo', shared=True)
185
211
self.assertRaises(errors.NoRepositoryPresent,
186
212
checkout.bzrdir.open_repository)
214
def prepare_branch_to_lightweight_checkout(self):
215
parent = self.make_branch('parent')
216
child = parent.bzrdir.sprout('child').open_workingtree()
217
child.commit('test', rev_id='new-commit')
218
child.bzrdir.destroy_workingtree()
219
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
221
return parent, child, reconfiguration
188
223
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(
224
parent, child, reconfiguration = \
225
self.prepare_branch_to_lightweight_checkout()
195
226
reconfiguration.apply()
227
self.assertTrue(reconfiguration._destroy_branch)
196
228
wt = child.bzrdir.open_workingtree()
197
229
self.assertTrue(parent.repository.has_same_location(
198
230
wt.branch.repository))
201
233
child.bzrdir.open_repository)
203
235
def test_branch_to_lightweight_checkout_failure(self):
204
parent = self.make_branch('parent')
205
child = parent.bzrdir.sprout('child').open_workingtree()
206
child.commit('test', rev_id='new-commit')
207
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
236
parent, child, reconfiguration = \
237
self.prepare_branch_to_lightweight_checkout()
209
238
old_Repository_fetch = repository.Repository.fetch
210
239
repository.Repository.fetch = None
215
244
child = _mod_branch.Branch.open('child')
216
245
self.assertContainsRe(child.base, 'child/$')
247
def test_branch_to_lightweight_checkout_fetch_tags(self):
248
parent, child, reconfiguration = \
249
self.prepare_branch_to_lightweight_checkout()
250
child.branch.tags.set_tag('foo', 'bar')
251
reconfiguration.apply()
252
child = _mod_branch.Branch.open('child')
253
self.assertEqual('bar', parent.tags.lookup_tag('foo'))
218
255
def test_lightweight_checkout_to_lightweight_checkout(self):
219
256
parent = self.make_branch('parent')
220
257
checkout = parent.create_checkout('checkout', lightweight=True)