~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_pull.py

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
 
from cStringIO import StringIO
19
18
 
 
19
from bzrlib import tests
20
20
from bzrlib.tests import per_workingtree
21
21
 
22
22
 
62
62
        tree.commit('second')
63
63
        to_tree.pull(tree.branch)
64
64
        self.assertEqual('second_root_id', to_tree.get_root_id())
 
65
 
 
66
 
 
67
class TestPullWithOrphans(per_workingtree.TestCaseWithWorkingTree):
 
68
 
 
69
    def make_branch_deleting_dir(self, relpath=None):
 
70
        if relpath is None:
 
71
            relpath = 'trunk'
 
72
        builder = self.make_branch_builder(relpath)
 
73
        builder.start_series()
 
74
 
 
75
        # Create an empty trunk
 
76
        builder.build_snapshot('1', None, [
 
77
                ('add', ('', 'root-id', 'directory', ''))])
 
78
        builder.build_snapshot('2', ['1'], [
 
79
                ('add', ('dir', 'dir-id', 'directory', '')),
 
80
                ('add', ('file', 'file-id', 'file', 'trunk content\n')),])
 
81
        builder.build_snapshot('3', ['2'], [
 
82
                ('unversion', 'dir-id'),])
 
83
        builder.finish_series()
 
84
        return builder.get_branch()
 
85
 
 
86
    def test_pull_orphans(self):
 
87
        if not self.workingtree_format.missing_parent_conflicts:
 
88
            raise tests.TestSkipped(
 
89
                '%r does not support missing parent conflicts' %
 
90
                    self.workingtree_format)
 
91
        trunk = self.make_branch_deleting_dir('trunk')
 
92
        work = trunk.bzrdir.sprout('work', revision_id='2').open_workingtree()
 
93
        work.branch.get_config().set_user_option(
 
94
            'bzr.transform.orphan_policy', 'move')
 
95
        # Add some unversioned files in dir
 
96
        self.build_tree(['work/dir/foo',
 
97
                         'work/dir/subdir/',
 
98
                         'work/dir/subdir/foo'])
 
99
        work.pull(trunk)
 
100
        self.assertLength(0, work.conflicts())
 
101
        # The directory removal should succeed
 
102
        self.failIfExists('work/dir')