177
179
source.branch.push(target, stop_revision='rev-2', overwrite=True)
178
180
self.assertEqual('rev-2', target.last_revision())
182
def test_push_with_default_stacking_does_not_create_broken_branch(self):
183
"""Pushing a new standalone branch works even when there's a default
184
stacking policy at the destination.
186
The new branch will preserve the repo format (even if it isn't the
187
default for the branch), and will be stacked when the repo format
188
allows (which means that the branch format isn't necessarly preserved).
190
if isinstance(self.branch_format, branch.BzrBranchFormat4):
191
raise tests.TestNotApplicable('Not a metadir format.')
192
if isinstance(self.branch_format, branch.BranchReferenceFormat):
193
# This test could in principle apply to BranchReferenceFormat, but
194
# make_branch_builder doesn't support it.
195
raise tests.TestSkipped(
196
"BranchBuilder can't make reference branches.")
197
# Make a branch called "local" in a stackable repository
198
# The branch has 3 revisions:
199
# - rev-1, adds a file
200
# - rev-2, no changes
201
# - rev-3, modifies the file.
202
repo = self.make_repository('repo', shared=True, format='1.6')
203
builder = self.make_branch_builder('repo/local')
204
builder.start_series()
205
builder.build_snapshot('rev-1', None, [
206
('add', ('', 'root-id', 'directory', '')),
207
('add', ('filename', 'f-id', 'file', 'content\n'))])
208
builder.build_snapshot('rev-2', ['rev-1'], [])
209
builder.build_snapshot('rev-3', ['rev-2'],
210
[('modify', ('f-id', 'new-content\n'))])
211
builder.finish_series()
212
trunk = builder.get_branch()
213
# Sprout rev-1 to "trunk", so that we can stack on it.
214
trunk.bzrdir.sprout(self.get_url('trunk'), revision_id='rev-1')
215
# Set a default stacking policy so that new branches will automatically
217
self.make_bzrdir('.').get_config().set_default_stack_on('trunk')
218
# Push rev-2 to a new branch "remote". It will be stacked on "trunk".
220
push._show_push_branch(trunk, 'rev-2', self.get_url('remote'), output)
221
# Push rev-3 onto "remote". If "remote" not stacked and is missing the
222
# fulltext record for f-id @ rev-1, then this will fail.
223
remote_branch = Branch.open(self.get_url('remote'))
224
trunk.push(remote_branch)
225
remote_branch.check()
181
228
class TestPushHook(TestCaseWithBranch):