/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/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2007-04-26 18:53:33 UTC
  • mfrom: (2465 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2466.
  • Revision ID: john@arbash-meinel.com-20070426185333-i1xlyaeyf049kdxc
[merge] bzr.dev 2465

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
rather than in tests/branch_implementations/*.py.
25
25
"""
26
26
 
 
27
from bzrlib import (
 
28
    errors,
 
29
    tests,
 
30
    )
27
31
from bzrlib.branch import (BranchFormat,
28
32
                           BranchTestProviderAdapter,
29
33
                           _legacy_formats,
30
34
                           )
 
35
from bzrlib.remote import RemoteBranchFormat, RemoteBzrDirFormat
31
36
from bzrlib.smart.server import (
32
37
    SmartTCPServer_for_testing,
33
38
    ReadonlySmartTCPServer_for_testing,
34
39
    )
35
 
from bzrlib.tests import (
36
 
                          adapt_modules,
37
 
                          TestLoader,
38
 
                          TestSuite,
39
 
                          )
40
 
from bzrlib.remote import RemoteBranchFormat, RemoteBzrDirFormat
 
40
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
41
41
from bzrlib.transport.memory import MemoryServer
42
42
 
43
43
 
 
44
class TestCaseWithBranch(TestCaseWithBzrDir):
 
45
    """This helper will be adapted for each branch_implementation test."""
 
46
 
 
47
    def setUp(self):
 
48
        super(TestCaseWithBranch, self).setUp()
 
49
        self.branch = None
 
50
 
 
51
    def get_branch(self):
 
52
        if self.branch is None:
 
53
            self.branch = self.make_branch('')
 
54
        return self.branch
 
55
 
 
56
    def make_branch(self, relpath, format=None):
 
57
        repo = self.make_repository(relpath, format=format)
 
58
        # fixme RBC 20060210 this isnt necessarily a fixable thing,
 
59
        # Skipped is the wrong exception to raise.
 
60
        try:
 
61
            return self.branch_format.initialize(repo.bzrdir)
 
62
        except errors.UninitializableFormat:
 
63
            raise tests.TestSkipped('Uninitializable branch format')
 
64
 
 
65
    def make_repository(self, relpath, shared=False, format=None):
 
66
        made_control = self.make_bzrdir(relpath, format=format)
 
67
        return made_control.create_repository(shared=shared)
 
68
 
 
69
    def create_tree_with_merge(self):
 
70
        """Create a branch with a simple ancestry.
 
71
 
 
72
        The graph should look like:
 
73
            digraph H {
 
74
                "rev-1" -> "rev-2" -> "rev-3";
 
75
                "rev-1" -> "rev-1.1.1" -> "rev-3";
 
76
            }
 
77
 
 
78
        Or in ASCII:
 
79
            1
 
80
            |\
 
81
            2 1.1.1
 
82
            |/
 
83
            3
 
84
        """
 
85
        tree = self.make_branch_and_memory_tree('tree')
 
86
        tree.lock_write()
 
87
        try:
 
88
            tree.add('')
 
89
            tree.commit('first', rev_id='rev-1')
 
90
            tree.commit('second', rev_id='rev-1.1.1')
 
91
            # Uncommit that last commit and switch to the other line
 
92
            tree.branch.set_last_revision_info(1, 'rev-1')
 
93
            tree.set_parent_ids(['rev-1'])
 
94
            tree.commit('alt-second', rev_id='rev-2')
 
95
            tree.set_parent_ids(['rev-2', 'rev-1.1.1'])
 
96
            tree.commit('third', rev_id='rev-3')
 
97
        finally:
 
98
            tree.unlock()
 
99
 
 
100
        return tree
 
101
 
 
102
 
44
103
def test_suite():
45
 
    result = TestSuite()
 
104
    result = tests.TestSuite()
46
105
    test_branch_implementations = [
47
106
        'bzrlib.tests.branch_implementations.test_bound_sftp',
48
107
        'bzrlib.tests.branch_implementations.test_branch',
49
108
        'bzrlib.tests.branch_implementations.test_break_lock',
50
109
        'bzrlib.tests.branch_implementations.test_create_checkout',
51
110
        'bzrlib.tests.branch_implementations.test_commit',
 
111
        'bzrlib.tests.branch_implementations.test_get_revision_id_to_revno_map',
52
112
        'bzrlib.tests.branch_implementations.test_hooks',
53
113
        'bzrlib.tests.branch_implementations.test_http',
54
114
        'bzrlib.tests.branch_implementations.test_last_revision_info',
58
118
        'bzrlib.tests.branch_implementations.test_pull',
59
119
        'bzrlib.tests.branch_implementations.test_push',
60
120
        'bzrlib.tests.branch_implementations.test_revision_history',
 
121
        'bzrlib.tests.branch_implementations.test_revision_id_to_revno',
61
122
        'bzrlib.tests.branch_implementations.test_tags',
62
123
        'bzrlib.tests.branch_implementations.test_uncommit',
63
124
        'bzrlib.tests.branch_implementations.test_update',
73
134
        # by the TestCaseWithTransport.get_readonly_transport method.
74
135
        None,
75
136
        combinations)
76
 
    loader = TestLoader()
77
 
    adapt_modules(test_branch_implementations, adapter, loader, result)
78
 
 
 
137
    loader = tests.TestLoader()
 
138
    tests.adapt_modules(test_branch_implementations, adapter, loader, result)
79
139
 
80
140
    adapt_to_smart_server = BranchTestProviderAdapter(
81
141
        SmartTCPServer_for_testing,
83
143
        [(RemoteBranchFormat(), RemoteBzrDirFormat())],
84
144
        MemoryServer
85
145
        )
86
 
    adapt_modules(test_branch_implementations,
87
 
                  adapt_to_smart_server,
88
 
                  loader,
89
 
                  result)
 
146
    tests.adapt_modules(test_branch_implementations,
 
147
                        adapt_to_smart_server,
 
148
                        loader,
 
149
                        result)
90
150
 
91
151
    return result