~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-09 13:58:59 UTC
  • mfrom: (3533.2.1 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080709135859-wq3r1d1fjcafelgw
(jam) (bug #243536) tsort.merge_sorted() can ignore ghosts in the
        mainline history passed in.

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
        self.make_branch_and_tree('bar')
202
202
 
203
203
 
204
 
class TestBranch67(object):
205
 
    """Common tests for both branch 6 and 7 which are mostly the same."""
206
 
 
207
 
    def get_format_name(self):
208
 
        raise NotImplementedError(self.get_format_name)
209
 
 
210
 
    def get_format_name_subtree(self):
211
 
        raise NotImplementedError(self.get_format_name)
212
 
 
213
 
    def get_class(self):
214
 
        raise NotImplementedError(self.get_class)
 
204
class TestBranch6(TestCaseWithTransport):
215
205
 
216
206
    def test_creation(self):
217
207
        format = BzrDirMetaFormat1()
218
208
        format.set_branch_format(_mod_branch.BzrBranchFormat6())
219
209
        branch = self.make_branch('a', format=format)
220
 
        self.assertIsInstance(branch, self.get_class())
221
 
        branch = self.make_branch('b', format=self.get_format_name())
222
 
        self.assertIsInstance(branch, self.get_class())
 
210
        self.assertIsInstance(branch, _mod_branch.BzrBranch6)
 
211
        branch = self.make_branch('b', format='dirstate-tags')
 
212
        self.assertIsInstance(branch, _mod_branch.BzrBranch6)
223
213
        branch = _mod_branch.Branch.open('a')
224
 
        self.assertIsInstance(branch, self.get_class())
 
214
        self.assertIsInstance(branch, _mod_branch.BzrBranch6)
225
215
 
226
216
    def test_layout(self):
227
 
        branch = self.make_branch('a', format=self.get_format_name())
 
217
        branch = self.make_branch('a', format='dirstate-tags')
228
218
        self.failUnlessExists('a/.bzr/branch/last-revision')
229
219
        self.failIfExists('a/.bzr/branch/revision-history')
230
220
 
231
221
    def test_config(self):
232
222
        """Ensure that all configuration data is stored in the branch"""
233
 
        branch = self.make_branch('a', format=self.get_format_name())
 
223
        branch = self.make_branch('a', format='dirstate-tags')
234
224
        branch.set_parent('http://bazaar-vcs.org')
235
225
        self.failIfExists('a/.bzr/branch/parent')
236
226
        self.assertEqual('http://bazaar-vcs.org', branch.get_parent())
244
234
 
245
235
    def test_set_revision_history(self):
246
236
        tree = self.make_branch_and_memory_tree('.',
247
 
            format=self.get_format_name())
 
237
            format='dirstate-tags')
248
238
        tree.lock_write()
249
239
        try:
250
240
            tree.add('.')
258
248
            tree.unlock()
259
249
 
260
250
    def do_checkout_test(self, lightweight=False):
261
 
        tree = self.make_branch_and_tree('source',
262
 
            format=self.get_format_name_subtree())
 
251
        tree = self.make_branch_and_tree('source', format='dirstate-with-subtree')
263
252
        subtree = self.make_branch_and_tree('source/subtree',
264
 
            format=self.get_format_name_subtree())
 
253
            format='dirstate-with-subtree')
265
254
        subsubtree = self.make_branch_and_tree('source/subtree/subsubtree',
266
 
            format=self.get_format_name_subtree())
 
255
            format='dirstate-with-subtree')
267
256
        self.build_tree(['source/subtree/file',
268
257
                         'source/subtree/subsubtree/file'])
269
258
        subsubtree.add('file')
291
280
        self.do_checkout_test(lightweight=True)
292
281
 
293
282
    def test_set_push(self):
294
 
        branch = self.make_branch('source', format=self.get_format_name())
 
283
        branch = self.make_branch('source', format='dirstate-tags')
295
284
        branch.get_config().set_user_option('push_location', 'old',
296
285
            store=config.STORE_LOCATION)
297
286
        warnings = []
307
296
                         'locations.conf')
308
297
 
309
298
 
310
 
class TestBranch6(TestBranch67, TestCaseWithTransport):
311
 
 
312
 
    def get_class(self):
313
 
        return _mod_branch.BzrBranch6
314
 
 
315
 
    def get_format_name(self):
316
 
        return "dirstate-tags"
317
 
 
318
 
    def get_format_name_subtree(self):
319
 
        return "dirstate-with-subtree"
320
 
 
321
 
    def test_set_stacked_on_errors(self):
322
 
        branch = self.make_branch('a', format=self.get_format_name())
323
 
        self.assertRaises(errors.UnstackableBranchFormat,
324
 
            branch.set_stacked_on, None)
325
 
 
326
 
    def test_default_stacked_location(self):
327
 
        branch = self.make_branch('a', format=self.get_format_name())
328
 
        self.assertRaises(errors.UnstackableBranchFormat, branch.get_stacked_on)
329
 
 
330
 
 
331
 
class TestBranch7(TestBranch67, TestCaseWithTransport):
332
 
 
333
 
    def get_class(self):
334
 
        return _mod_branch.BzrBranch7
335
 
 
336
 
    def get_format_name(self):
337
 
        return "development"
338
 
 
339
 
    def get_format_name_subtree(self):
340
 
        return "development-subtree"
341
 
 
342
 
    def test_set_stacked_on_unstackable_repo(self):
343
 
        repo = self.make_repository('a', format='dirstate-tags')
344
 
        control = repo.bzrdir
345
 
        branch = _mod_branch.BzrBranchFormat7().initialize(control)
346
 
        target = self.make_branch('b')
347
 
        self.assertRaises(errors.UnstackableRepositoryFormat,
348
 
            branch.set_stacked_on, target.base)
349
 
 
350
 
    def _test_default_stacked_location(self):
351
 
        branch = self.make_branch('a', format=self.get_format_name())
352
 
        self.assertRaises(errors.NotStacked, branch.get_stacked_on)
353
 
 
354
 
    def test_stack_and_unstack(self):
355
 
        branch = self.make_branch('a', format=self.get_format_name())
356
 
        target = self.make_branch_and_tree('b', format=self.get_format_name())
357
 
        branch.set_stacked_on(target.branch.base)
358
 
        self.assertEqual(target.branch.base, branch.get_stacked_on())
359
 
        revid = target.commit('foo')
360
 
        self.assertTrue(branch.repository.has_revision(revid))
361
 
        branch.set_stacked_on(None)
362
 
        self.assertRaises(errors.NotStacked, branch.get_stacked_on)
363
 
        self.assertFalse(branch.repository.has_revision(revid))
364
 
 
365
 
    def test_open_opens_stacked_reference(self):
366
 
        branch = self.make_branch('a', format=self.get_format_name())
367
 
        target = self.make_branch_and_tree('b', format=self.get_format_name())
368
 
        branch.set_stacked_on(target.branch.base)
369
 
        branch = branch.bzrdir.open_branch()
370
 
        revid = target.commit('foo')
371
 
        self.assertTrue(branch.repository.has_revision(revid))
372
 
 
373
 
 
374
299
class TestBranchReference(TestCaseWithTransport):
375
300
    """Tests for the branch reference facility."""
376
301