~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge bzr.dev, update to use new hooks.

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
from bzrlib.revision import NULL_REVISION
20
21
from bzrlib.tests import per_workingtree
21
22
 
22
23
 
30
31
        tree_b = self.make_branch_and_tree('to')
31
32
        return tree, tree_b
32
33
 
 
34
    def test_pull_null(self):
 
35
        tree_a, tree_b = self.get_pullable_trees()
 
36
        root_id = tree_a.get_root_id()
 
37
        tree_a.pull(tree_b.branch, stop_revision=NULL_REVISION, overwrite=True)
 
38
        self.assertEquals(root_id, tree_a.get_root_id())
 
39
 
33
40
    def test_pull(self):
34
41
        tree_a, tree_b = self.get_pullable_trees()
35
42
        tree_b.pull(tree_a.branch)
36
 
        self.failUnless(tree_b.branch.repository.has_revision('A'))
 
43
        self.assertTrue(tree_b.branch.repository.has_revision('A'))
37
44
        self.assertEqual(['A'], tree_b.get_parent_ids())
38
45
 
39
46
    def test_pull_overwrites(self):
40
47
        tree_a, tree_b = self.get_pullable_trees()
41
48
        tree_b.commit('foo', rev_id='B')
42
 
        self.assertEqual(['B'], tree_b.branch.revision_history())
 
49
        self.assertEqual('B', tree_b.branch.last_revision())
43
50
        tree_b.pull(tree_a.branch, overwrite=True)
44
 
        self.failUnless(tree_b.branch.repository.has_revision('A'))
45
 
        self.failUnless(tree_b.branch.repository.has_revision('B'))
 
51
        self.assertTrue(tree_b.branch.repository.has_revision('A'))
 
52
        self.assertTrue(tree_b.branch.repository.has_revision('B'))
46
53
        self.assertEqual(['A'], tree_b.get_parent_ids())
47
54
 
48
55
    def test_pull_merges_tree_content(self):
62
69
        tree.commit('second')
63
70
        to_tree.pull(tree.branch)
64
71
        self.assertEqual('second_root_id', to_tree.get_root_id())
 
72
 
 
73
 
 
74
class TestPullWithOrphans(per_workingtree.TestCaseWithWorkingTree):
 
75
 
 
76
    def make_branch_deleting_dir(self, relpath=None):
 
77
        if relpath is None:
 
78
            relpath = 'trunk'
 
79
        builder = self.make_branch_builder(relpath)
 
80
        builder.start_series()
 
81
 
 
82
        # Create an empty trunk
 
83
        builder.build_snapshot('1', None, [
 
84
                ('add', ('', 'root-id', 'directory', ''))])
 
85
        builder.build_snapshot('2', ['1'], [
 
86
                ('add', ('dir', 'dir-id', 'directory', '')),
 
87
                ('add', ('file', 'file-id', 'file', 'trunk content\n')),])
 
88
        builder.build_snapshot('3', ['2'], [
 
89
                ('unversion', 'dir-id'),])
 
90
        builder.finish_series()
 
91
        return builder.get_branch()
 
92
 
 
93
    def test_pull_orphans(self):
 
94
        if not self.workingtree_format.missing_parent_conflicts:
 
95
            raise tests.TestSkipped(
 
96
                '%r does not support missing parent conflicts' %
 
97
                    self.workingtree_format)
 
98
        trunk = self.make_branch_deleting_dir('trunk')
 
99
        work = trunk.bzrdir.sprout('work', revision_id='2').open_workingtree()
 
100
        work.branch.get_config().set_user_option(
 
101
            'bzr.transform.orphan_policy', 'move')
 
102
        # Add some unversioned files in dir
 
103
        self.build_tree(['work/dir/foo',
 
104
                         'work/dir/subdir/',
 
105
                         'work/dir/subdir/foo'])
 
106
        work.pull(trunk)
 
107
        self.assertLength(0, work.conflicts())
 
108
        # The directory removal should succeed
 
109
        self.assertPathDoesNotExist('work/dir')