示例#1
0
 def test_lca_merge_criss_cross(self):
     tree_a = self.make_branch_and_tree('a')
     self.build_tree_contents([('a/file', b'base-contents\n')])
     tree_a.add('file')
     tree_a.commit('', rev_id=b'rev1')
     tree_b = tree_a.controldir.sprout('b').open_workingtree()
     self.build_tree_contents([('a/file',
                                b'base-contents\nthis-contents\n')])
     tree_a.commit('', rev_id=b'rev2a')
     self.build_tree_contents([('b/file',
                                b'base-contents\nother-contents\n')])
     tree_b.commit('', rev_id=b'rev2b')
     tree_a.merge_from_branch(tree_b.branch)
     self.build_tree_contents([('a/file',
                                b'base-contents\nthis-contents\n')])
     tree_a.set_conflicts(conflicts.ConflictList())
     tree_b.merge_from_branch(tree_a.branch)
     self.build_tree_contents([('b/file',
                                b'base-contents\nother-contents\n')])
     tree_b.set_conflicts(conflicts.ConflictList())
     tree_a.commit('', rev_id=b'rev3a')
     tree_b.commit('', rev_id=b'rev3b')
     out, err = self.run_bzr(['merge', '-d', 'a', 'b', '--lca'], retcode=1)
     self.assertFileEqual(b'base-contents\n<<<<<<< TREE\nthis-contents\n'
                          b'=======\nother-contents\n>>>>>>> MERGE-SOURCE\n',
                          'a/file')
示例#2
0
    def test_merge_bundle(self):
        from breezy.bzr.testament import Testament
        tree_a = self.make_branch_and_tree('branch_a')
        self.build_tree_contents([('branch_a/a', b'hello')])
        tree_a.add('a')
        tree_a.commit('message')

        tree_b = tree_a.controldir.sprout('branch_b').open_workingtree()
        self.build_tree_contents([('branch_a/a', b'hey there')])
        tree_a.commit('message')

        self.build_tree_contents([('branch_b/a', b'goodbye')])
        tree_b.commit('message')
        self.run_bzr('bundle ../branch_a -o ../bundle', working_dir='branch_b')
        self.run_bzr('merge ../bundle', retcode=1, working_dir='branch_a')
        testament_a = Testament.from_revision(tree_a.branch.repository,
                                              tree_b.get_parent_ids()[0])
        testament_b = Testament.from_revision(tree_b.branch.repository,
                                              tree_b.get_parent_ids()[0])
        self.assertEqualDiff(testament_a.as_text(),
                             testament_b.as_text())
        tree_a.set_conflicts(conflicts.ConflictList())
        tree_a.commit('message')
        # it is legal to attempt to merge an already-merged bundle
        err = self.run_bzr('merge ../bundle', working_dir='branch_a')[1]
        # but it does nothing
        self.assertFalse(tree_a.changes_from(
            tree_a.basis_tree()).has_changed())
        self.assertEqual('Nothing to do.\n', err)
示例#3
0
 def test_file4_added_then_renamed(self):
     outer, inner, revs = self.make_outer_tree()
     # 1 conflict, because file4 can't be put into the old root
     nb_conflicts = outer.merge_from_branch(inner, to_revision=revs[3])
     if outer.supports_rename_tracking():
         self.assertEqual(1, nb_conflicts)
     else:
         self.assertEqual(0, nb_conflicts)
     try:
         outer.set_conflicts(conflicts.ConflictList())
     except errors.UnsupportedOperation:
         # WT2 doesn't have a separate list of conflicts to clear. It
         # actually says there is a conflict, but happily forgets all about
         # it.
         pass
     outer.commit('added file4')
     # And now file4 gets renamed into an existing dir
     nb_conflicts = outer.merge_from_branch(inner, to_revision=revs[4])
     if outer.supports_rename_tracking():
         self.assertEqual(1, nb_conflicts)
         self.assertTreeLayout([
             'dir-outer', 'dir-outer/dir', 'dir-outer/dir/file1',
             'dir-outer/dir/file4', 'dir-outer/file3', 'foo'
         ], outer)
     else:
         self.assertEqual(2, nb_conflicts)
         self.assertTreeLayout([
             'dir', 'dir-outer', 'dir-outer/dir', 'dir-outer/dir/file1',
             'dir-outer/file3', 'dir/file4', 'foo'
         ], outer)
示例#4
0
    def create_merged_trees(self):
        """create 2 trees with merges between them.

        rev-1 --+
         |      |
        rev-2  rev-1_1_1
         |      |
         +------+
         |
        rev-3
        """

        tree1 = self.make_branch_and_tree('tree1')
        self.build_tree_contents([('tree1/a', b'first\n')])
        tree1.add(['a'], [b'a-id'])
        tree1.commit('a',
                     rev_id=b'rev-1',
                     committer="*****@*****.**",
                     timestamp=1166046000.00,
                     timezone=0)

        tree2 = tree1.controldir.sprout('tree2').open_workingtree()

        self.build_tree_contents([('tree1/a', b'first\nsecond\n')])
        tree1.commit('b',
                     rev_id=b'rev-2',
                     committer='*****@*****.**',
                     timestamp=1166046001.00,
                     timezone=0)

        self.build_tree_contents([('tree2/a', b'first\nthird\n')])
        tree2.commit('c',
                     rev_id=b'rev-1_1_1',
                     committer="*****@*****.**",
                     timestamp=1166046002.00,
                     timezone=0)

        num_conflicts = tree1.merge_from_branch(tree2.branch)
        self.assertEqual(1, num_conflicts)

        self.build_tree_contents([('tree1/a', b'first\nsecond\nthird\n')])
        tree1.set_conflicts(conflicts.ConflictList())
        tree1.commit('merge 2',
                     rev_id=b'rev-3',
                     committer='*****@*****.**',
                     timestamp=1166046003.00,
                     timezone=0)
        return tree1, tree2
示例#5
0
    def test_no_autodelete_alternate_renamed(self):
        # Test for bug #114615
        tree_a = self.make_branch_and_tree('A')
        self.build_tree(['A/a/', 'A/a/m', 'A/a/n'])
        tree_a.add(['a', 'a/m', 'a/n'])
        tree_a.commit('init')

        tree_b = tree_a.controldir.sprout('B').open_workingtree()
        self.build_tree(['B/xyz/'])
        tree_b.add(['xyz'])
        tree_b.rename_one('a/m', 'xyz/m')
        osutils.rmtree('B/a')
        tree_b.commit('delete in B')

        self.assertThat(
            tree_b,
            HasPathRelations(
                tree_a, [('', ''), ('xyz/', None), ('xyz/m', 'a/m')]))

        self.build_tree_contents([('A/a/n', b'new contents for n\n')])
        tree_a.commit('change n in A')

        # Merging from A should introduce conflicts because 'n' was modified
        # (in A) and removed (in B), so 'a' needs to be restored.
        num_conflicts = tree_b.merge_from_branch(tree_a.branch)
        self.assertEqual(3, num_conflicts)

        self.assertThat(
            tree_b, HasPathRelations(
                tree_a,
                [('', ''), ('a/', 'a/'), ('xyz/', None),
                 ('a/n.OTHER', 'a/n'), ('xyz/m', 'a/m')]))

        osutils.rmtree('B/a')
        try:
            # bzr resolve --all
            tree_b.set_conflicts(conflicts.ConflictList())
        except errors.UnsupportedOperation:
            # On WT2, set_conflicts is unsupported, but the rmtree has the same
            # effect.
            pass
        tree_b.commit('autoremove a, without touching xyz/m')

        self.assertThat(
            tree_b, HasPathRelations(
                tree_a,
                [('', ''), ('xyz/', None), ('xyz/m', 'a/m')]))
示例#6
0
 def conflicts(self):
     return _mod_conflicts.ConflictList()