86
76
class TestCaseWithInterBranch(TestCaseWithTransport):
88
78
def make_from_branch(self, relpath):
89
repo = self.make_repository(relpath)
90
return self.branch_format_from.initialize(repo.bzrdir)
79
return self.make_branch(relpath, format=self.branch_format_from._matchingbzrdir)
92
81
def make_from_branch_and_memory_tree(self, relpath):
93
82
"""Create a branch on the default transport and a MemoryTree for it."""
94
b = self.make_from_branch(relpath)
95
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)
97
89
def make_from_branch_and_tree(self, relpath):
98
90
"""Create a branch on the default transport and a working tree for it."""
99
b = self.make_from_branch(relpath)
100
return b.bzrdir.create_workingtree()
92
self.branch_format_from._matchingbzrdir.get_branch_format(),
93
self.branch_format_from)
94
return self.make_branch_and_tree(relpath,
95
format=self.branch_format_from._matchingbzrdir)
102
97
def make_from_branch_builder(self, relpath):
103
default_format = BzrDirFormat.get_default_format()
104
format = BzrDirMetaFormat1()
105
format.set_branch_format(self.branch_format_from)
106
format.repository_format = default_format.repository_format
107
format.workingtree_format = default_format.workingtree_format
99
self.branch_format_from._matchingbzrdir.get_branch_format(),
100
self.branch_format_from)
108
101
return branchbuilder.BranchBuilder(self.get_transport(relpath),
102
format=self.branch_format_from._matchingbzrdir)
111
104
def make_to_branch(self, relpath):
112
repo = self.make_repository(relpath)
113
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)
115
110
def make_to_branch_and_memory_tree(self, relpath):
116
111
"""Create a branch on the default transport and a MemoryTree for it."""
117
b = self.make_to_branch(relpath)
118
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)
120
118
def make_to_branch_and_tree(self, relpath):
121
119
"""Create a branch on the default transport and a working tree for it."""
122
b = self.make_to_branch(relpath)
123
return b.bzrdir.create_workingtree()
121
self.branch_format_to._matchingbzrdir.get_branch_format(),
122
self.branch_format_to)
123
return self.make_branch_and_tree(relpath,
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)
125
140
def sprout_to(self, origdir, to_url):
126
141
"""Sprout a bzrdir, using to_format for the new branch."""
127
newbranch = self.make_to_branch(to_url)
128
origbranch = origdir.open_branch()
129
newbranch.repository.fetch(origbranch.repository)
130
origbranch.copy_content_into(newbranch)
131
newbranch.bzrdir.create_workingtree()
132
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)
134
146
def sprout_from(self, origdir, to_url):
135
147
"""Sprout a bzrdir, using from_format for the new bzrdir."""
136
newbranch = self.make_from_branch(to_url)
137
origbranch = origdir.open_branch()
138
newbranch.repository.fetch(origbranch.repository)
139
origbranch.copy_content_into(newbranch)
140
newbranch.bzrdir.create_workingtree()
141
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)
144
154
class StubWithFormat(object):