/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_workingtree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-03-06 00:49:26 UTC
  • mfrom: (1587.1.14 bound-branches)
  • Revision ID: pqm@pqm.ubuntu.com-20060306004926-6d7a10c990bc17d1
Merge in bound branches core support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
327
327
        tree.commit('foo', rev_id='foo', allow_pointless=True)
328
328
        self.assertEqual('foo', tree.last_revision())
329
329
 
 
330
    def test_commit_local_unbound(self):
 
331
        # using the library api to do a local commit on unbound branches is 
 
332
        # also an error
 
333
        tree = self.make_branch_and_tree('tree')
 
334
        self.assertRaises(errors.LocalRequiresBoundBranch,
 
335
                          tree.commit,
 
336
                          'foo',
 
337
                          local=True)
 
338
 
 
339
    def test_local_commit_ignores_master(self):
 
340
        # a --local commit does not require access to the master branch
 
341
        # at all, or even for it to exist.
 
342
        # we test this by setting up a bound branch and then corrupting
 
343
        # the master.
 
344
        master = self.make_branch('master')
 
345
        tree = self.make_branch_and_tree('tree')
 
346
        try:
 
347
            tree.branch.bind(master)
 
348
        except errors.UpgradeRequired:
 
349
            # older format.
 
350
            return
 
351
        master.bzrdir.transport.put('branch-format', StringIO('garbage'))
 
352
        del master
 
353
        # check its corrupted.
 
354
        self.assertRaises(errors.UnknownFormatError,
 
355
                          bzrdir.BzrDir.open,
 
356
                          'master')
 
357
        tree.commit('foo', rev_id='foo', local=True)
 
358
 
 
359
    def test_local_commit_does_not_push_to_master(self):
 
360
        # a --local commit does not require access to the master branch
 
361
        # at all, or even for it to exist.
 
362
        # we test that even when its available it does not push to it.
 
363
        master = self.make_branch('master')
 
364
        tree = self.make_branch_and_tree('tree')
 
365
        try:
 
366
            tree.branch.bind(master)
 
367
        except errors.UpgradeRequired:
 
368
            # older format.
 
369
            return
 
370
        tree.commit('foo', rev_id='foo', local=True)
 
371
        self.failIf(master.repository.has_revision('foo'))
 
372
        self.assertEqual(None, master.last_revision())
 
373
        
330
374
    def test_update_sets_last_revision(self):
331
375
        # working tree formats from the meta-dir format and newer support
332
376
        # setting the last revision on a tree independently of that on the 
391
435
        self.assertEqual(1, old_tree.update())
392
436
        self.assertEqual('A', old_tree.last_revision())
393
437
 
 
438
    def test_update_updates_bound_branch_no_local_commits(self):
 
439
        # doing an update in a tree updates the branch its bound to too.
 
440
        master_tree = self.make_branch_and_tree('master')
 
441
        tree = self.make_branch_and_tree('tree')
 
442
        try:
 
443
            tree.branch.bind(master_tree.branch)
 
444
        except errors.UpgradeRequired:
 
445
            # legacy branches cannot bind
 
446
            return
 
447
        master_tree.commit('foo', rev_id='foo', allow_pointless=True)
 
448
        tree.update()
 
449
        self.assertEqual('foo', tree.last_revision())
 
450
        self.assertEqual('foo', tree.branch.last_revision())
 
451
 
 
452
    def test_update_turns_local_commit_into_merge(self):
 
453
        # doing an update with a few local commits and no master commits
 
454
        # makes pending-merges. 
 
455
        # this is done so that 'bzr update; bzr revert' will always produce
 
456
        # an exact copy of the 'logical branch' - the referenced branch for
 
457
        # a checkout, and the master for a bound branch.
 
458
        # its possible that we should instead have 'bzr update' when there
 
459
        # is nothing new on the master leave the current commits intact and
 
460
        # alter 'revert' to revert to the master always. But for now, its
 
461
        # good.
 
462
        master_tree = self.make_branch_and_tree('master')
 
463
        tree = self.make_branch_and_tree('tree')
 
464
        try:
 
465
            tree.branch.bind(master_tree.branch)
 
466
        except errors.UpgradeRequired:
 
467
            # legacy branches cannot bind
 
468
            return
 
469
        tree.commit('foo', rev_id='foo', allow_pointless=True, local=True)
 
470
        tree.commit('bar', rev_id='bar', allow_pointless=True, local=True)
 
471
        tree.update()
 
472
        self.assertEqual(None, tree.last_revision())
 
473
        self.assertEqual([], tree.branch.revision_history())
 
474
        self.assertEqual(['bar'], tree.pending_merges())
 
475