78
class TestCaseWithInterBranch(TestCaseWithBzrDir):
81
super(TestCaseWithInterBranch, self).setUp()
83
def make_branch(self, relpath, format=None):
84
repo = self.make_repository(relpath, format=format)
85
return repo.bzrdir.create_branch()
87
def make_bzrdir(self, relpath, format=None):
89
url = self.get_url(relpath)
90
segments = url.split('/')
91
if segments and segments[-1] not in ('', '.'):
92
parent = '/'.join(segments[:-1])
93
t = get_transport(parent)
99
format = self.branch_format_from._matchingbzrdir
100
return format.initialize(url)
101
except UninitializableFormat:
102
raise TestSkipped("Format %s is not initializable." % format)
104
def make_repository(self, relpath, format=None):
105
made_control = self.make_bzrdir(relpath, format=format)
106
return made_control.create_repository()
108
def make_to_bzrdir(self, relpath):
109
return self.make_bzrdir(relpath,
110
self.branch_format_to._matchingbzrdir)
89
class TestCaseWithInterBranch(TestCaseWithTransport):
91
def make_from_branch(self, relpath):
92
repo = self.make_repository(relpath)
93
return self.branch_format_from.initialize(repo.bzrdir)
95
def make_from_branch_and_memory_tree(self, relpath):
96
"""Create a branch on the default transport and a MemoryTree for it."""
97
b = self.make_from_branch(relpath)
98
return memorytree.MemoryTree.create_on_branch(b)
100
def make_from_branch_and_tree(self, relpath):
101
"""Create a branch on the default transport and a working tree for it."""
102
b = self.make_from_branch(relpath)
103
return b.bzrdir.create_workingtree()
105
def make_from_branch_builder(self, relpath):
106
default_format = BzrDirFormat.get_default_format()
107
format = BzrDirMetaFormat1()
108
format.set_branch_format(self.branch_format_from)
109
format.repository_format = default_format.repository_format
110
format.workingtree_format = default_format.workingtree_format
111
return branchbuilder.BranchBuilder(self.get_transport(relpath),
112
114
def make_to_branch(self, relpath):
113
made_control = self.make_to_bzrdir(relpath)
114
return self.branch_format_to.initialize(made_control)
115
repo = self.make_repository(relpath)
116
return self.branch_format_to.initialize(repo.bzrdir)
118
def make_to_branch_and_memory_tree(self, relpath):
119
"""Create a branch on the default transport and a MemoryTree for it."""
120
b = self.make_to_branch(relpath)
121
return memorytree.MemoryTree.create_on_branch(b)
123
def make_to_branch_and_tree(self, relpath):
124
"""Create a branch on the default transport and a working tree for it."""
125
b = self.make_to_branch(relpath)
126
return b.bzrdir.create_workingtree()
128
def sprout_to(self, origdir, to_url):
129
"""Sprout a bzrdir, using to_format for the new branch."""
130
newbranch = self.make_to_branch(to_url)
131
origbranch = origdir.open_branch()
132
newbranch.repository.fetch(origbranch.repository)
133
origbranch.copy_content_into(newbranch)
134
newbranch.bzrdir.create_workingtree()
135
return newbranch.bzrdir
137
def sprout_from(self, origdir, to_url):
138
"""Sprout a bzrdir, using from_format for the new bzrdir."""
139
newbranch = self.make_from_branch(to_url)
140
origbranch = origdir.open_branch()
141
newbranch.repository.fetch(origbranch.repository)
142
origbranch.copy_content_into(newbranch)
143
newbranch.bzrdir.create_workingtree()
144
return newbranch.bzrdir
117
149
def load_tests(standard_tests, module, loader):
118
150
submod_tests = loader.loadTestsFromModuleNames([
151
'bzrlib.tests.per_interbranch.test_push',
119
152
'bzrlib.tests.per_interbranch.test_update_revisions',
121
154
scenarios = make_scenarios(default_test_list())