Exemplo n.º 1
0
 def test_lca_merge_criss_cross(self):
     tree_a = self.make_branch_and_tree('a')
     self.build_tree_contents([('a/file', 'base-contents\n')])
     tree_a.add('file')
     tree_a.commit('', rev_id='rev1')
     tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
     self.build_tree_contents([('a/file', 'base-contents\nthis-contents\n')
                               ])
     tree_a.commit('', rev_id='rev2a')
     self.build_tree_contents([('b/file', 'base-contents\nother-contents\n')
                               ])
     tree_b.commit('', rev_id='rev2b')
     tree_a.merge_from_branch(tree_b.branch)
     self.build_tree_contents([('a/file', 'base-contents\nthis-contents\n')
                               ])
     tree_a.set_conflicts(ConflictList())
     tree_b.merge_from_branch(tree_a.branch)
     self.build_tree_contents([('b/file', 'base-contents\nother-contents\n')
                               ])
     tree_b.set_conflicts(ConflictList())
     tree_a.commit('', rev_id='rev3a')
     tree_b.commit('', rev_id='rev3b')
     out, err = self.run_bzr(['merge', '-d', 'a', 'b', '--lca'], retcode=1)
     self.assertFileEqual(
         'base-contents\n<<<<<<< TREE\nthis-contents\n'
         '=======\nother-contents\n>>>>>>> MERGE-SOURCE\n', 'a/file')
Exemplo n.º 2
0
 def test_clear_merge_conflicts(self):
     tree = self.make_merge_conflicts()
     self.assertEqual(len(tree.conflicts()), 1)
     try:
         tree.set_conflicts(ConflictList())
     except UnsupportedOperation:
         raise TestSkipped('unsupported operation')
     self.assertEqual(tree.conflicts(), ConflictList())
Exemplo n.º 3
0
 def test_resolve_conflict_dir(self):
     tree = self.make_branch_and_tree('.')
     b = tree.branch
     file('hello', 'w').write('hello world4')
     tree.add('hello', 'q')
     file('hello.THIS', 'w').write('hello world2')
     file('hello.BASE', 'w').write('hello world1')
     os.mkdir('hello.OTHER')
     l = ConflictList([TextConflict('hello')])
     l.remove_files(tree)
Exemplo n.º 4
0
 def test_resolve_conflicts_recursive(self):
     tree = self.make_branch_and_tree('.')
     self.build_tree(['dir/', 'dir/hello'])
     tree.add(['dir', 'dir/hello'])
     tree.set_conflicts(ConflictList([TextConflict('dir/hello')]))
     resolve(tree, ['dir'], recursive=False, ignore_misses=True)
     self.assertEqual(ConflictList([TextConflict('dir/hello')]),
                      tree.conflicts())
     resolve(tree, ['dir'], recursive=True, ignore_misses=True)
     self.assertEqual(ConflictList([]), tree.conflicts())
Exemplo n.º 5
0
 def test_resolve_conflict_dir(self):
     tree = self.make_branch_and_tree('.')
     b = tree.branch
     file('hello', 'w').write('hello world4')
     tree.add('hello', 'q')
     file('hello.THIS', 'w').write('hello world2')
     file('hello.BASE', 'w').write('hello world1')
     os.mkdir('hello.OTHER')
     l = ConflictList([TextConflict('hello')])
     l.remove_files(tree)
Exemplo n.º 6
0
 def test_select_conflicts(self):
     tree = self.make_branch_and_tree('.')
     tree_conflicts = ConflictList([ContentsConflict('foo'),
                                    ContentsConflict('bar')])
     self.assertEqual((ConflictList([ContentsConflict('bar')]),
                       ConflictList([ContentsConflict('foo')])),
                      tree_conflicts.select_conflicts(tree, ['foo']))
     self.assertEqual((ConflictList(), tree_conflicts),
                      tree_conflicts.select_conflicts(tree, [''],
                      ignore_misses=True, recurse=True))
     tree_conflicts = ConflictList([ContentsConflict('foo/baz'),
                                    ContentsConflict('bar')])
     self.assertEqual((ConflictList([ContentsConflict('bar')]),
                       ConflictList([ContentsConflict('foo/baz')])),
                      tree_conflicts.select_conflicts(tree, ['foo'],
                                                      recurse=True,
                                                      ignore_misses=True))
     tree_conflicts = ConflictList([PathConflict('qux', 'foo/baz')])
     self.assertEqual((ConflictList(), tree_conflicts),
                      tree_conflicts.select_conflicts(tree, ['foo'],
                                                      recurse=True,
                                                      ignore_misses=True))
     self.assertEqual((tree_conflicts, ConflictList()),
                      tree_conflicts.select_conflicts(tree, ['foo'],
                                                      ignore_misses=True))
Exemplo n.º 7
0
    def test_merge_bundle(self):
        from bzrlib.testament import Testament
        tree_a = self.make_branch_and_tree('branch_a')
        self.build_tree_contents([('branch_a/a', 'hello')])
        tree_a.add('a')
        tree_a.commit('message')

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

        self.build_tree_contents([('branch_b/a', 'goodbye')])
        tree_b.commit('message')
        os.chdir('branch_b')
        self.run_bzr('bundle ../branch_a -o ../bundle')
        os.chdir('../branch_a')
        self.run_bzr('merge ../bundle', retcode=1)
        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(ConflictList())
        tree_a.commit('message')
        # it is legal to attempt to merge an already-merged bundle
        output = self.run_bzr('merge ../bundle')[1]
        # but it does nothing
        self.assertFalse(
            tree_a.changes_from(tree_a.basis_tree()).has_changed())
        self.assertEqual('Nothing to do.\n', output)
Exemplo n.º 8
0
 def test_add_conflicts(self):
     tree = self.make_branch_and_tree('tree')
     try:
         tree.add_conflicts([TextConflict('path_a')])
     except UnsupportedOperation:
         raise TestSkipped('unsupported operation')
     self.assertEqual(ConflictList([TextConflict('path_a')]),
                      tree.conflicts())
     tree.add_conflicts([TextConflict('path_a')])
     self.assertEqual(ConflictList([TextConflict('path_a')]),
                      tree.conflicts())
     tree.add_conflicts([ContentsConflict('path_a')])
     self.assertEqual(
         ConflictList([ContentsConflict('path_a'),
                       TextConflict('path_a')]), tree.conflicts())
     tree.add_conflicts([TextConflict('path_b')])
     self.assertEqual(
         ConflictList([
             ContentsConflict('path_a'),
             TextConflict('path_a'),
             TextConflict('path_b')
         ]), tree.conflicts())
Exemplo n.º 9
0
    def test_stanza_roundtrip(self):
        # write and read our example stanza.
        stanza_iter = example_conflicts.to_stanzas()
        processed = ConflictList.from_stanzas(stanza_iter)
        for o, p in zip(processed, example_conflicts):
            self.assertEqual(o, p)

            self.assertIsInstance(o.path, unicode)

            if o.file_id is not None:
                self.assertIsInstance(o.file_id, str)

            conflict_path = getattr(o, 'conflict_path', None)
            if conflict_path is not None:
                self.assertIsInstance(conflict_path, unicode)

            conflict_file_id = getattr(o, 'conflict_file_id', None)
            if conflict_file_id is not None:
                self.assertIsInstance(conflict_file_id, str)
Exemplo n.º 10
0
    def test_stanza_roundtrip(self):
        # write and read our example stanza.
        stanza_iter = example_conflicts.to_stanzas()
        processed = ConflictList.from_stanzas(stanza_iter)
        for o, p in zip(processed, example_conflicts):
            self.assertEqual(o, p)

            self.assertIsInstance(o.path, unicode)

            if o.file_id is not None:
                self.assertIsInstance(o.file_id, str)

            conflict_path = getattr(o, 'conflict_path', None)
            if conflict_path is not None:
                self.assertIsInstance(conflict_path, unicode)

            conflict_file_id = getattr(o, 'conflict_file_id', None)
            if conflict_file_id is not None:
                self.assertIsInstance(conflict_file_id, str)
Exemplo n.º 11
0
 def test_select_conflicts(self):
     tree = self.make_branch_and_tree('.')
     tree_conflicts = ConflictList(
         [ContentsConflict('foo'),
          ContentsConflict('bar')])
     self.assertEqual(
         (ConflictList([ContentsConflict('bar')
                        ]), ConflictList([ContentsConflict('foo')])),
         tree_conflicts.select_conflicts(tree, ['foo']))
     self.assertEqual((ConflictList(), tree_conflicts),
                      tree_conflicts.select_conflicts(tree, [''],
                                                      ignore_misses=True,
                                                      recurse=True))
     tree_conflicts = ConflictList(
         [ContentsConflict('foo/baz'),
          ContentsConflict('bar')])
     self.assertEqual(
         (ConflictList([ContentsConflict('bar')
                        ]), ConflictList([ContentsConflict('foo/baz')])),
         tree_conflicts.select_conflicts(tree, ['foo'],
                                         recurse=True,
                                         ignore_misses=True))
     tree_conflicts = ConflictList([PathConflict('qux', 'foo/baz')])
     self.assertEqual((ConflictList(), tree_conflicts),
                      tree_conflicts.select_conflicts(tree, ['foo'],
                                                      recurse=True,
                                                      ignore_misses=True))
     self.assertEqual((tree_conflicts, ConflictList()),
                      tree_conflicts.select_conflicts(tree, ['foo'],
                                                      ignore_misses=True))
Exemplo n.º 12
0
# TODO: Test commit with some added, and added-but-missing files
# RBC 20060124 is that not tested in test_commit.py ?

# The order of 'path' here is important - do not let it
# be a sorted list.
# u'\xe5' == a with circle
# '\xc3\xae' == u'\xee' == i with hat
# So these are u'pathg' and 'idg' only with a circle and a hat. (shappo?)
example_conflicts = ConflictList([
    MissingParent('Not deleting', u'p\xe5thg', '\xc3\xaedg'),
    ContentsConflict(u'p\xe5tha', None, '\xc3\xaeda'),
    TextConflict(u'p\xe5tha'),
    PathConflict(u'p\xe5thb', u'p\xe5thc', '\xc3\xaedb'),
    DuplicateID('Unversioned existing file', u'p\xe5thc', u'p\xe5thc2',
                '\xc3\xaedc', '\xc3\xaedc'),
    DuplicateEntry('Moved existing file to', u'p\xe5thdd.moved', u'p\xe5thd',
                   '\xc3\xaedd', None),
    ParentLoop('Cancelled move', u'p\xe5the', u'p\xe5th2e', None,
               '\xc3\xaed2e'),
    UnversionedParent('Versioned directory', u'p\xe5thf', '\xc3\xaedf'),
    NonDirectoryParent('Created directory', u'p\xe5thg', '\xc3\xaedg'),
])


class TestConflicts(TestCaseWithTransport):
    def test_conflicts(self):
        """Conflicts are detected properly"""
        tree = self.make_branch_and_tree('.', format=bzrdir.BzrDirFormat6())
        b = tree.branch
        file('hello', 'w').write('hello world4')
        file('hello.THIS', 'w').write('hello world2')
Exemplo n.º 13
0
 def test_merge_inner_conflicts(self):
     tree_a = self.make_branch_and_tree('a')
     tree_a.set_conflicts(ConflictList([TextConflict('patha')]))
     merge_inner(tree_a.branch, tree_a, tree_a, this_tree=tree_a)
     self.assertEqual(1, len(tree_a.conflicts()))