Esempio n. 1
0
    def test_unversion_renamed(self):
        tree = self.make_branch_and_tree('a')
        self.build_tree(['a/dir/', 'a/dir/f1', 'a/dir/f2', 'a/dir/f3',
                         'a/dir2/'])
        tree.add(['dir', 'dir/f1', 'dir/f2', 'dir/f3', 'dir2'])
        rev_id1 = tree.commit('init')
        revtree = tree.branch.repository.revision_tree(rev_id1)
        # Start off by renaming entries, and then unversion a bunch of entries
        # https://bugs.launchpad.net/bzr/+bug/114615
        tree.rename_one('dir/f1', 'dir/a')
        tree.rename_one('dir/f2', 'dir/z')
        tree.move(['dir/f3'], 'dir2')

        self.assertThat(
            tree, HasPathRelations(
                revtree,
                [('', ''), ('dir/', 'dir/'), ('dir2/', 'dir2/'),
                 ('dir/a', 'dir/f1'), ('dir/z', 'dir/f2'),
                 ('dir2/f3', 'dir/f3')]))

        tree.unversion({'dir'})
        self.assertThat(
            tree,
            HasPathRelations(
                revtree,
                [('', ''), ('dir2/', 'dir2/'), ('dir2/f3', 'dir/f3')]))
Esempio n. 2
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.
        conflicts = tree_b.merge_from_branch(tree_a.branch)
        if tree_b.has_versioned_directories():
            self.assertEqual(3, len(conflicts))
        else:
            self.assertEqual(2, len(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([])
        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')]))
Esempio n. 3
0
    def test_unversion_after_conflicted_merge(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')
        tree_b.unversion(['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
        # and removed, so 'a' needs to be restored. We also have a conflict
        # because 'a' is still an existing directory
        conflicts = tree_b.merge_from_branch(tree_a.branch)
        if tree_b.has_versioned_directories():
            self.assertEqual(4, len(conflicts))
        else:
            self.assertEqual(1, len(conflicts))

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

        tree_b.unversion(['a'])
        self.assertThat(
            tree_b,
            HasPathRelations(
                tree_a,
                [('', ''), ('xyz/', None), ('xyz/m', 'a/m')]))
Esempio n. 4
0
 def test_unversion_parent_and_child_renamed_bug_187207(self):
     # When unversioning dirstate trees show a bug in dealing with
     # unversioning children of reparented children of unversioned
     # paths when relocation entries are present and the relocation
     # points later into the dirstate.
     tree = self.make_branch_and_tree('.')
     self.build_tree(['del/', 'del/sub/', 'del/sub/b'])
     tree.add(['del', 'del/sub', 'del/sub/b'])
     revid = tree.commit('setup')
     revtree = tree.branch.repository.revision_tree(revid)
     tree.rename_one('del/sub', 'sub')
     self.assertThat(
         tree,
         HasPathRelations(revtree, [('', ''), ('del/', 'del/'), ('sub/', 'del/sub/'), ('sub/b', 'del/sub/b')]))
     if tree.has_versioned_directories():
         tree.unversion(['del', 'sub/b'])
     else:
         tree.unversion(['sub/b'])
     self.assertThat(
         tree,
         HasPathRelations(revtree, [('', ''), ('sub/', 'del/sub/')]))
Esempio n. 5
0
    def test_no_autodelete_renamed_away(self):
        tree_a = self.make_branch_and_tree('a')
        self.build_tree(['a/dir/', 'a/dir/f1', 'a/dir/f2', 'a/dir2/'])
        tree_a.add(['dir', 'dir/f1', 'dir/f2', 'dir2'])
        rev_id1 = tree_a.commit('init')
        revtree = tree_a.branch.repository.revision_tree(rev_id1)
        # Rename one entry out of this directory
        tree_a.rename_one('dir/f1', 'dir2/a')
        osutils.rmtree('a/dir')
        tree_a.commit('autoremoved')

        # The only paths left should be the root
        self.assertThat(
            tree_a,
            HasPathRelations(revtree, [('', ''), ('dir2/', 'dir2/'),
                                       ('dir2/a', 'dir/f1')]))
Esempio n. 6
0
 def assertPathRelations(self, previous_tree, tree, relations):
     self.assertThat(tree, HasPathRelations(previous_tree, relations))