24
24
rather than in tests/branch_implementations/*.py.
27
31
from bzrlib.branch import (BranchFormat,
28
32
BranchTestProviderAdapter,
31
from bzrlib.tests import (
35
from bzrlib.remote import RemoteBranchFormat, RemoteBzrDirFormat
36
from bzrlib.smart.server import (
37
SmartTCPServer_for_testing,
38
ReadonlySmartTCPServer_for_testing,
40
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
41
from bzrlib.transport.memory import MemoryServer
44
class TestCaseWithBranch(TestCaseWithBzrDir):
45
"""This helper will be adapted for each branch_implementation test."""
48
super(TestCaseWithBranch, self).setUp()
52
if self.branch is None:
53
self.branch = self.make_branch('')
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.
61
return self.branch_format.initialize(repo.bzrdir)
62
except errors.UninitializableFormat:
63
raise tests.TestSkipped('Uninitializable branch format')
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)
69
def create_tree_with_merge(self):
70
"""Create a branch with a simple ancestry.
72
The graph should look like:
74
"rev-1" -> "rev-2" -> "rev-3";
75
"rev-1" -> "rev-1.1.1" -> "rev-3";
85
tree = self.make_branch_and_memory_tree('tree')
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')
104
result = tests.TestSuite()
41
105
test_branch_implementations = [
42
106
'bzrlib.tests.branch_implementations.test_bound_sftp',
43
107
'bzrlib.tests.branch_implementations.test_branch',
44
108
'bzrlib.tests.branch_implementations.test_break_lock',
109
'bzrlib.tests.branch_implementations.test_create_checkout',
110
'bzrlib.tests.branch_implementations.test_commit',
111
'bzrlib.tests.branch_implementations.test_get_revision_id_to_revno_map',
112
'bzrlib.tests.branch_implementations.test_hooks',
45
113
'bzrlib.tests.branch_implementations.test_http',
114
'bzrlib.tests.branch_implementations.test_last_revision_info',
46
115
'bzrlib.tests.branch_implementations.test_locking',
47
116
'bzrlib.tests.branch_implementations.test_parent',
48
117
'bzrlib.tests.branch_implementations.test_permissions',
49
118
'bzrlib.tests.branch_implementations.test_pull',
119
'bzrlib.tests.branch_implementations.test_push',
120
'bzrlib.tests.branch_implementations.test_revision_history',
121
'bzrlib.tests.branch_implementations.test_revision_id_to_revno',
122
'bzrlib.tests.branch_implementations.test_tags',
123
'bzrlib.tests.branch_implementations.test_uncommit',
50
124
'bzrlib.tests.branch_implementations.test_update',
126
# Generate a list of branch formats and their associated bzrdir formats to
128
combinations = [(format, format._matchingbzrdir) for format in
129
BranchFormat._formats.values() + _legacy_formats]
52
130
adapter = BranchTestProviderAdapter(
131
# None here will cause the default vfs transport server to be used.
54
133
# None here will cause a readonly decorator to be created
55
134
# by the TestCaseWithTransport.get_readonly_transport method.
57
[(format, format._matchingbzrdir) for format in
58
BranchFormat._formats.values() + _legacy_formats])
60
adapt_modules(test_branch_implementations, adapter, loader, result)
137
loader = tests.TestLoader()
138
tests.adapt_modules(test_branch_implementations, adapter, loader, result)
140
adapt_to_smart_server = BranchTestProviderAdapter(
141
SmartTCPServer_for_testing,
142
ReadonlySmartTCPServer_for_testing,
143
[(RemoteBranchFormat(), RemoteBzrDirFormat())],
146
tests.adapt_modules(test_branch_implementations,
147
adapt_to_smart_server,