60
60
reconfiguration.apply()
61
61
self.assertIs(None, checkout.branch.get_bound_location())
63
def prepare_lightweight_checkout_to_branch(self):
63
def test_lightweight_checkout_to_branch(self):
64
64
branch = self.make_branch('branch')
65
65
checkout = branch.create_checkout('checkout', lightweight=True)
66
66
checkout.commit('first commit', rev_id='rev1')
67
67
reconfiguration = reconfigure.Reconfigure.to_branch(checkout.bzrdir)
68
return reconfiguration, checkout
70
def test_lightweight_checkout_to_branch(self):
71
reconfiguration, checkout = \
72
self.prepare_lightweight_checkout_to_branch()
73
68
reconfiguration.apply()
74
69
checkout_branch = checkout.bzrdir.open_branch()
75
70
self.assertEqual(checkout_branch.bzrdir.root_transport.base,
78
73
repo = checkout.bzrdir.open_repository()
79
74
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):
76
def test_lightweight_checkout_to_checkout(self):
90
77
branch = self.make_branch('branch')
91
78
checkout = branch.create_checkout('checkout', lightweight=True)
92
79
reconfiguration = reconfigure.Reconfigure.to_checkout(checkout.bzrdir)
93
return reconfiguration, checkout
95
def test_lightweight_checkout_to_checkout(self):
96
reconfiguration, checkout = \
97
self.prepare_lightweight_checkout_to_checkout()
98
80
reconfiguration.apply()
99
81
checkout_branch = checkout.bzrdir.open_branch()
100
82
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'))
110
84
def test_lightweight_conversion_uses_shared_repo(self):
111
85
parent = self.make_branch('parent')
112
86
shared_repo = self.make_repository('repo', shared=True)
211
185
self.assertRaises(errors.NoRepositoryPresent,
212
186
checkout.bzrdir.open_repository)
214
def prepare_branch_to_lightweight_checkout(self):
188
def test_branch_to_lightweight_checkout(self):
215
189
parent = self.make_branch('parent')
216
190
child = parent.bzrdir.sprout('child').open_workingtree()
217
191
child.commit('test', rev_id='new-commit')
218
192
child.bzrdir.destroy_workingtree()
219
193
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
221
return parent, child, reconfiguration
223
def test_branch_to_lightweight_checkout(self):
224
parent, child, reconfiguration = \
225
self.prepare_branch_to_lightweight_checkout()
226
195
reconfiguration.apply()
227
self.assertTrue(reconfiguration._destroy_branch)
228
196
wt = child.bzrdir.open_workingtree()
229
197
self.assertTrue(parent.repository.has_same_location(
230
198
wt.branch.repository))
233
201
child.bzrdir.open_repository)
235
203
def test_branch_to_lightweight_checkout_failure(self):
236
parent, child, reconfiguration = \
237
self.prepare_branch_to_lightweight_checkout()
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(
238
209
old_Repository_fetch = repository.Repository.fetch
239
210
repository.Repository.fetch = None
244
215
child = _mod_branch.Branch.open('child')
245
216
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'))
255
218
def test_lightweight_checkout_to_lightweight_checkout(self):
256
219
parent = self.make_branch('parent')
257
220
checkout = parent.create_checkout('checkout', lightweight=True)