~toddy/bzr/bzr.i18n

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_reconfigure.py

  • Committer: Tobias Toedter
  • Date: 2008-02-10 08:01:48 UTC
  • mfrom: (2438.1.783 +trunk)
  • Revision ID: t.toedter@gmx.net-20080210080148-bg5rh61oq2zk2xw3
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
        reconfiguration.apply()
61
61
        self.assertIs(None, checkout.branch.get_bound_location())
62
62
 
 
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
 
69
 
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')
75
80
 
 
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'))
 
88
 
 
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
 
94
 
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)
83
101
 
 
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'))
 
109
 
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)
187
213
 
188
 
    def test_branch_to_lightweight_checkout(self):
 
214
    def prepare_branch_to_lightweight_checkout(self):
189
215
        parent = self.make_branch('parent')
190
216
        child = parent.bzrdir.sprout('child').open_workingtree()
191
217
        child.commit('test', rev_id='new-commit')
192
218
        child.bzrdir.destroy_workingtree()
193
219
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
194
220
            child.bzrdir)
 
221
        return parent, child, reconfiguration
 
222
 
 
223
    def test_branch_to_lightweight_checkout(self):
 
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))
200
232
        self.assertRaises(errors.NoRepositoryPresent,
201
233
                          child.bzrdir.open_repository)
202
234
 
 
235
    def test_branch_to_lightweight_checkout_failure(self):
 
236
        parent, child, reconfiguration = \
 
237
            self.prepare_branch_to_lightweight_checkout()
 
238
        old_Repository_fetch = repository.Repository.fetch
 
239
        repository.Repository.fetch = None
 
240
        try:
 
241
            self.assertRaises(TypeError, reconfiguration.apply)
 
242
        finally:
 
243
            repository.Repository.fetch = old_Repository_fetch
 
244
        child = _mod_branch.Branch.open('child')
 
245
        self.assertContainsRe(child.base, 'child/$')
 
246
 
 
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'))
 
254
 
203
255
    def test_lightweight_checkout_to_lightweight_checkout(self):
204
256
        parent = self.make_branch('parent')
205
257
        checkout = parent.create_checkout('checkout', lightweight=True)