/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/branch_implementations/test_branch.py

  • Committer: Robert Collins
  • Date: 2008-02-13 03:30:01 UTC
  • mfrom: (3221 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3224.
  • Revision ID: robertc@robertcollins.net-20080213033001-rw70ul0zb02ph856
Merge to fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    transactions,
29
29
    remote,
30
30
    repository,
 
31
    tests,
31
32
    )
32
33
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
33
34
from bzrlib.delta import TreeDelta
41
42
import bzrlib.revision
42
43
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
43
44
from bzrlib.tests.branch_implementations import TestCaseWithBranch
44
 
from bzrlib.tests.HttpServer import HttpServer
 
45
from bzrlib.tests.http_server import HttpServer
45
46
from bzrlib.trace import mutter
46
47
from bzrlib.transport import get_transport
47
48
from bzrlib.transport.memory import MemoryServer
97
98
 
98
99
        rev = b2.repository.get_revision('revision-1')
99
100
        tree = b2.repository.revision_tree('revision-1')
 
101
        tree.lock_read()
 
102
        self.addCleanup(tree.unlock)
100
103
        self.assertEqual(tree.get_file_text('foo-id'), 'hello')
101
104
 
102
105
    def test_get_revision_delta(self):
262
265
    def test_store_signature(self):
263
266
        wt = self.make_branch_and_tree('.')
264
267
        branch = wt.branch
265
 
        branch.repository.store_revision_signature(
266
 
            gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
 
268
        branch.lock_write()
 
269
        try:
 
270
            branch.repository.start_write_group()
 
271
            try:
 
272
                branch.repository.store_revision_signature(
 
273
                    gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
 
274
            except:
 
275
                branch.repository.abort_write_group()
 
276
                raise
 
277
            else:
 
278
                branch.repository.commit_write_group()
 
279
        finally:
 
280
            branch.unlock()
267
281
        self.assertRaises(errors.NoSuchRevision,
268
282
                          branch.repository.has_signature_for_revision_id,
269
283
                          'A')
564
578
        self.assertEqual(None,
565
579
            made_branch._format.get_reference(made_branch.bzrdir))
566
580
 
 
581
    def test_set_reference(self):
 
582
        """set_reference on all regular branches should be callable."""
 
583
        if not self.branch_format.is_supported():
 
584
            # unsupported formats are not loopback testable
 
585
            # because the default open will not open them and
 
586
            # they may not be initializable.
 
587
            return
 
588
        this_branch = self.make_branch('this')
 
589
        other_branch = self.make_branch('other')
 
590
        try:
 
591
            this_branch._format.set_reference(this_branch.bzrdir, other_branch)
 
592
        except NotImplementedError:
 
593
            # that's ok
 
594
            pass
 
595
        else:
 
596
            ref = this_branch._format.get_reference(this_branch.bzrdir)
 
597
            self.assertEqual(ref, other_branch.base)
 
598
 
567
599
    def test_format_initialize_find_open(self):
568
600
        # loopback test to check the current format initializes to itself.
569
601
        if not self.branch_format.is_supported():
607
639
        try:
608
640
            branch.bind(branch2)
609
641
        except errors.UpgradeRequired:
610
 
            raise TestSkipped('Format does not support binding')
 
642
            raise tests.TestNotApplicable('Format does not support binding')
611
643
        self.assertTrue(branch.unbind())
612
644
        self.assertFalse(branch.unbind())
613
645
        self.assertIs(None, branch.get_bound_location())
617
649
        try:
618
650
            self.assertIs(None, branch.get_old_bound_location())
619
651
        except errors.UpgradeRequired:
620
 
            raise TestSkipped('Format does not store old bound locations')
 
652
            raise tests.TestNotApplicable(
 
653
                    'Format does not store old bound locations')
621
654
        branch2 = self.make_branch('branch2')
622
655
        branch.bind(branch2)
623
656
        self.assertIs(None, branch.get_old_bound_location())
624
657
        branch.unbind()
625
658
        self.assertContainsRe(branch.get_old_bound_location(), '\/branch2\/$')
626
659
 
 
660
    def test_bind_diverged(self):
 
661
        tree_a = self.make_branch_and_tree('tree_a')
 
662
        tree_a.commit('rev1a')
 
663
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
 
664
        tree_a.commit('rev2a')
 
665
        tree_b.commit('rev2b')
 
666
        try:
 
667
            tree_b.branch.bind(tree_a.branch)
 
668
        except errors.UpgradeRequired:
 
669
            raise tests.TestNotApplicable('Format does not support binding')
 
670
 
627
671
 
628
672
class TestStrict(TestCaseWithBranch):
629
673