~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_merge.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-30 13:54:37 UTC
  • mto: (1946.2.6 reduce-knit-churn)
  • mto: This revision was merged to the branch mainline in revision 1898.
  • Revision ID: john@arbash-meinel.com-20060730135437-1d722abdb14bff76
(jelmer) Install new intertree tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
        os.mkdir('a')
53
53
        os.chdir('a')
54
54
        self.example_branch()
55
 
        ancestor = Branch.open('.').revno()
56
55
        os.chdir('..')
57
56
        self.runbzr('branch a b')
58
57
        os.chdir('b')
63
62
        file('hello', 'wt').write('quuux')
64
63
        # We can't merge when there are in-tree changes
65
64
        self.runbzr('merge ../b', retcode=3)
66
 
        a = WorkingTree.open('.')
67
 
        a_tip = a.commit("Like an epidemic of u's")
 
65
        self.runbzr(['commit', '-m', "Like an epidemic of u's"])
68
66
        self.runbzr('merge ../b -r last:1..last:1 --merge-type blooof',
69
67
                    retcode=3)
70
68
        self.runbzr('merge ../b -r last:1..last:1 --merge-type merge3')
76
74
        self.runbzr('merge ../b -r last:1')
77
75
        self.check_file_contents('goodbye', 'quux')
78
76
        # Merging a branch pulls its revision into the tree
 
77
        a = WorkingTree.open('.')
79
78
        b = Branch.open('../b')
80
 
        b_tip = b.last_revision()
81
 
        self.failUnless(a.branch.repository.has_revision(b_tip))
82
 
        self.assertEqual([a_tip, b_tip], a.get_parent_ids())
83
 
        self.runbzr('revert --no-backup')
84
 
        out, err = self.runbzr('merge -r revno:1:./hello', retcode=3)
85
 
        self.assertTrue("Not a branch" in err)
86
 
        self.runbzr('merge -r revno:%d:./..revno:%d:../b'
87
 
                    %(ancestor,b.revno()))
88
 
        self.assertEquals(a.get_parent_ids(), 
89
 
                          [a.branch.last_revision(), b.last_revision()])
90
 
        self.check_file_contents('goodbye', 'quux')
91
 
        self.runbzr('revert --no-backup')
92
 
        self.runbzr('merge -r revno:%d:../b'%b.revno())
93
 
        self.assertEquals(a.get_parent_ids(),
94
 
                          [a.branch.last_revision(), b.last_revision()])
95
 
        a_tip = a.commit('merged')
 
79
        a.branch.repository.get_revision_xml(b.last_revision())
 
80
        self.log('pending merges: %s', a.pending_merges())
 
81
        self.assertEquals(a.pending_merges(),
 
82
                          [b.last_revision()])
 
83
        self.runbzr('commit -m merged')
96
84
        self.runbzr('merge ../b -r last:1')
97
 
        self.assertEqual([a_tip], a.get_parent_ids())
 
85
        self.assertEqual(a.pending_merges(), [])
98
86
 
99
87
    def test_merge_with_missing_file(self):
100
88
        """Merge handles missing file conflicts"""
207
195
        file('../bundle', 'wb').write(self.runbzr('bundle ../branch_a')[0])
208
196
        os.chdir('../branch_a')
209
197
        self.runbzr('merge ../bundle', retcode=1)
210
 
        testament_a = Testament.from_revision(tree_a.branch.repository,
211
 
                                              tree_b.get_parent_ids()[0])
 
198
        testament_a = Testament.from_revision(tree_a.branch.repository, 
 
199
                                              tree_b.last_revision())
212
200
        testament_b = Testament.from_revision(tree_b.branch.repository,
213
 
                                              tree_b.get_parent_ids()[0])
 
201
                                              tree_b.last_revision())
214
202
        self.assertEqualDiff(testament_a.as_text(),
215
203
                         testament_b.as_text())
216
204
        tree_a.set_conflicts(ConflictList())
220
208
        # but it does nothing
221
209
        self.assertFalse(tree_a.changes_from(tree_a.basis_tree()).has_changed())
222
210
        self.assertEqual('Nothing to do.\n', output)
223
 
 
224
 
    def test_merge_uncommitted(self):
225
 
        """Check that merge --uncommitted behaves properly"""
226
 
        tree_a = self.make_branch_and_tree('a')
227
 
        self.build_tree(['a/file_1', 'a/file_2'])
228
 
        tree_a.add(['file_1', 'file_2'])
229
 
        tree_a.commit('commit 1')
230
 
        tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
231
 
        self.failUnlessExists('b/file_1')
232
 
        tree_a.rename_one('file_1', 'file_i')
233
 
        tree_a.commit('commit 2')
234
 
        tree_a.rename_one('file_2', 'file_ii')
235
 
        os.chdir('b')
236
 
        self.run_bzr('merge', '../a', '--uncommitted')
237
 
        self.failUnlessExists('file_1')
238
 
        self.failUnlessExists('file_ii')
239
 
        tree_b.revert([])
240
 
        self.run_bzr_error(('Cannot use --uncommitted and --revision',), 
241
 
                           'merge', '../a', '--uncommitted', '-r1')