81
76
class TestCaseWithInterBranch(TestCaseWithTransport):
83
78
def make_from_branch(self, relpath):
84
repo = self.make_repository(relpath, format=self.branch_format_from._matchingbzrdir)
85
return self.branch_format_from.initialize(repo.bzrdir)
79
return self.make_branch(relpath, format=self.branch_format_from._matchingbzrdir)
87
81
def make_from_branch_and_memory_tree(self, relpath):
88
82
"""Create a branch on the default transport and a MemoryTree for it."""
89
b = self.make_from_branch(relpath)
90
return memorytree.MemoryTree.create_on_branch(b)
84
self.branch_format_from._matchingbzrdir.get_branch_format(),
85
self.branch_format_from)
86
return self.make_branch_and_memory_tree(
87
relpath, format=self.branch_format_from._matchingbzrdir)
92
89
def make_from_branch_and_tree(self, relpath):
93
90
"""Create a branch on the default transport and a working tree for it."""
92
self.branch_format_from._matchingbzrdir.get_branch_format(),
93
self.branch_format_from)
94
94
return self.make_branch_and_tree(relpath,
95
95
format=self.branch_format_from._matchingbzrdir)
97
97
def make_from_branch_builder(self, relpath):
99
self.branch_format_from._matchingbzrdir.get_branch_format(),
100
self.branch_format_from)
98
101
return branchbuilder.BranchBuilder(self.get_transport(relpath),
99
102
format=self.branch_format_from._matchingbzrdir)
101
104
def make_to_branch(self, relpath):
102
repo = self.make_repository(relpath, format=self.branch_format_to._matchingbzrdir)
103
return self.branch_format_to.initialize(repo.bzrdir)
106
self.branch_format_to._matchingbzrdir.get_branch_format(),
107
self.branch_format_to)
108
return self.make_branch(relpath, format=self.branch_format_to._matchingbzrdir)
105
110
def make_to_branch_and_memory_tree(self, relpath):
106
111
"""Create a branch on the default transport and a MemoryTree for it."""
107
b = self.make_to_branch(relpath)
108
return memorytree.MemoryTree.create_on_branch(b)
113
self.branch_format_to._matchingbzrdir.get_branch_format(),
114
self.branch_format_to)
115
return self.make_branch_and_memory_tree(
116
relpath, format=self.branch_format_to._matchingbzrdir)
110
118
def make_to_branch_and_tree(self, relpath):
111
119
"""Create a branch on the default transport and a working tree for it."""
121
self.branch_format_to._matchingbzrdir.get_branch_format(),
122
self.branch_format_to)
112
123
return self.make_branch_and_tree(relpath,
113
124
format=self.branch_format_to._matchingbzrdir)
126
def _sprout(self, origdir, to_url, format):
127
if format.supports_workingtrees:
128
newbranch = self.make_branch(to_url, format=format)
130
newbranch = self.make_branch(to_url+".branch", format=format)
131
origbranch = origdir.open_branch()
132
newbranch.repository.fetch(origbranch.repository)
133
origbranch.copy_content_into(newbranch)
134
if format.supports_workingtrees:
135
wt = newbranch.bzrdir.create_workingtree()
137
wt = newbranch.create_checkout(to_url, lightweight=True)
115
140
def sprout_to(self, origdir, to_url):
116
141
"""Sprout a bzrdir, using to_format for the new branch."""
117
newbranch = self.make_to_branch(to_url)
118
origbranch = origdir.open_branch()
119
newbranch.repository.fetch(origbranch.repository)
120
origbranch.copy_content_into(newbranch)
121
newbranch.bzrdir.create_workingtree()
122
return newbranch.bzrdir
142
wt = self._sprout(origdir, to_url, self.branch_format_to._matchingbzrdir)
143
self.assertEquals(wt.branch._format, self.branch_format_to)
124
146
def sprout_from(self, origdir, to_url):
125
147
"""Sprout a bzrdir, using from_format for the new bzrdir."""
126
newbranch = self.make_from_branch(to_url)
127
origbranch = origdir.open_branch()
128
newbranch.repository.fetch(origbranch.repository)
129
origbranch.copy_content_into(newbranch)
130
newbranch.bzrdir.create_workingtree()
131
return newbranch.bzrdir
148
wt = self._sprout(origdir, to_url,
149
self.branch_format_from._matchingbzrdir)
150
self.assertEquals(wt.branch._format, self.branch_format_from)
134
154
class StubWithFormat(object):