234
237
def make_merge_directive(self, revision_id, testament_sha1, time, timezone,
235
238
target_branch, patch=None, patch_type=None,
236
source_branch=None, message=None):
239
source_branch=None, message=None, base_revision_id='null:'):
237
240
if patch_type == 'bundle':
242
245
return merge_directive.MergeDirective2(revision_id, testament_sha1,
243
246
time, timezone, target_branch, patch, source_branch, message,
247
bundle, base_revision_id)
247
250
def set_bundle(md, value):
312
315
tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
313
316
branch_c = tree_a.bzrdir.sprout('branch_c').open_branch()
314
317
tree_b.commit('message', rev_id='rev2b')
315
self.build_tree_contents([('tree_a/file', 'content_a\ncontent_c\n')])
318
self.build_tree_contents([('tree_a/file', 'content_a\ncontent_c \n')])
316
319
tree_a.commit('Commit of rev2a', rev_id='rev2a')
317
320
return tree_a, tree_b, branch_c
494
497
def make_merge_directive(self, revision_id, testament_sha1, time, timezone,
495
498
target_branch, patch=None, patch_type=None,
496
source_branch=None, message=None):
499
source_branch=None, message=None, base_revision_id='null:'):
497
500
if patch_type == 'bundle':
502
505
return merge_directive.MergeDirective2(revision_id, testament_sha1,
503
506
time, timezone, target_branch, patch, source_branch, message,
507
bundle, base_revision_id)
509
def test_base_revision(self):
510
tree_a, tree_b, branch_c = self.make_trees()
511
md = self.from_objects(tree_a.branch.repository, 'rev2a', 500, 60,
512
tree_b.branch.base, patch_type='bundle',
513
public_branch=tree_a.branch.base)
514
self.assertEqual('rev1', md.base_revision_id)
515
lines = md.to_lines()
516
md2 = merge_directive.MergeDirective.from_lines(lines)
517
self.assertEqual(md2.base_revision_id, md.base_revision_id)
519
def test_patch_verification(self):
520
tree_a, tree_b, branch_c = self.make_trees()
521
md = self.from_objects(tree_a.branch.repository, 'rev2a', 500, 60,
522
tree_b.branch.base, patch_type='bundle',
523
public_branch=tree_a.branch.base)
524
lines = md.to_lines()
525
md2 = merge_directive.MergeDirective.from_lines(lines)
526
md2._verify_patch(tree_a.branch.repository)
527
# Stript trailing whitespace
528
md2.patch = md2.patch.replace(' \n', '\n')
529
md2._verify_patch(tree_a.branch.repository)
530
# Convert to Mac line-endings
531
md2.patch = md2.patch.replace('\n', '\r')
532
md2._verify_patch(tree_a.branch.repository)
533
# Convert to DOS line-endings
534
md2.patch = md2.patch.replace('\r', '\r\n')
535
md2._verify_patch(tree_a.branch.repository)
536
md2.patch = md2.patch.replace('content_c', 'content_d')
537
self.assertRaises(errors.PatchVerificationFailed, md2._verify_patch,
538
tree_a.branch.repository)
539
self.assertRaises(errors.PatchVerificationFailed,
540
md2.install_revisions, tree_a.branch.repository)