~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge_directive.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-11-04 18:51:39 UTC
  • mfrom: (2961.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20071104185139-kaio3sneodg2kp71
Authentication ring implementation (read-only)

Show diffs side-by-side

added added

removed removed

Lines of Context:
372
372
            tree_d.branch.base, patch_type='diff',
373
373
            public_branch=tree_a.branch.base)
374
374
 
375
 
    def test_disk_name(self):
376
 
        tree_a, tree_b, branch_c = self.make_trees()
377
 
        tree_a.branch.nick = 'fancy <name>'
378
 
        md = self.from_objects(tree_a.branch.repository, 'rev2a', 500, 120,
379
 
            tree_b.branch.base)
380
 
        self.assertEqual('fancy-name-2', md.get_disk_name(tree_a.branch))
381
 
 
382
 
    def test_disk_name_old_revno(self):
383
 
        tree_a, tree_b, branch_c = self.make_trees()
384
 
        tree_a.branch.nick = 'fancy-name'
385
 
        md = self.from_objects(tree_a.branch.repository, 'rev1', 500, 120,
386
 
            tree_b.branch.base)
387
 
        self.assertEqual('fancy-name-1', md.get_disk_name(tree_a.branch))
388
 
 
389
375
    def test_generate_patch(self):
390
376
        tree_a, tree_b, branch_c = self.make_trees()
391
377
        md2 = self.from_objects(tree_a.branch.repository, 'rev2a', 500, 120,
567
553
        revision = md.install_revisions(tree_b.branch.repository)
568
554
        self.assertEqual('rev2a', revision)
569
555
 
570
 
    def test_use_submit_for_missing_dependency(self):
571
 
        tree_a, tree_b, branch_c = self.make_trees()
572
 
        branch_c.pull(tree_a.branch)
573
 
        self.build_tree_contents([('tree_a/file', 'content_q\ncontent_r\n')])
574
 
        tree_a.commit('rev3a', rev_id='rev3a')
575
 
        md = self.from_objects(tree_a.branch.repository, 'rev3a', 500, 36,
576
 
            branch_c.base, base_revision_id='rev2a')
577
 
        revision = md.install_revisions(tree_b.branch.repository)
578
 
 
579
 
    def test_handle_target_not_a_branch(self):
580
 
        tree_a, tree_b, branch_c = self.make_trees()
581
 
        branch_c.pull(tree_a.branch)
582
 
        self.build_tree_contents([('tree_a/file', 'content_q\ncontent_r\n')])
583
 
        tree_a.commit('rev3a', rev_id='rev3a')
584
 
        md = self.from_objects(tree_a.branch.repository, 'rev3a', 500, 36,
585
 
            branch_c.base, base_revision_id='rev2a')
586
 
        md.target_branch = self.get_url('not-a-branch')
587
 
        self.assertRaises(errors.TargetNotBranch, md.install_revisions,
588
 
                tree_b.branch.repository)
589
 
 
590
556
 
591
557
class TestMergeDirective1Branch(tests.TestCaseWithTransport,
592
558
    TestMergeDirectiveBranch):
598
564
 
599
565
    def from_objects(self, repository, revision_id, time, timezone,
600
566
        target_branch, patch_type='bundle', local_target_branch=None,
601
 
        public_branch=None, message=None, base_revision_id=None):
602
 
        if base_revision_id is not None:
603
 
            raise tests.TestNotApplicable('This format does not support'
604
 
                                          ' explicit bases.')
605
 
        repository.lock_write()
606
 
        try:
607
 
            return merge_directive.MergeDirective.from_objects( repository,
608
 
                revision_id, time, timezone, target_branch, patch_type,
609
 
                local_target_branch, public_branch, message)
610
 
        finally:
611
 
            repository.unlock()
 
567
        public_branch=None, message=None):
 
568
        return merge_directive.MergeDirective.from_objects(
 
569
            repository, revision_id, time, timezone, target_branch,
 
570
            patch_type, local_target_branch, public_branch, message)
612
571
 
613
572
    def make_merge_directive(self, revision_id, testament_sha1, time, timezone,
614
573
                 target_branch, patch=None, patch_type=None,
631
590
        public_branch=None, message=None, base_revision_id=None):
632
591
        include_patch = (patch_type in ('bundle', 'diff'))
633
592
        include_bundle = (patch_type == 'bundle')
634
 
        self.assertTrue(patch_type in ('bundle', 'diff', None))
 
593
        assert patch_type in ('bundle', 'diff', None)
635
594
        return merge_directive.MergeDirective2.from_objects(
636
595
            repository, revision_id, time, timezone, target_branch,
637
596
            include_patch, include_bundle, local_target_branch, public_branch,