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