~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Alexander Belchenko
  • Date: 2006-07-31 16:12:57 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060731161257-91a231523255332c
new official bzr.ico

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from bzrlib.branch import Branch
25
25
from bzrlib.bzrdir import BzrDir
 
26
from bzrlib.conflicts import ConflictList
26
27
from bzrlib.osutils import abspath
27
28
from bzrlib.tests.blackbox import ExternalBase
 
29
import bzrlib.urlutils as urlutils
28
30
from bzrlib.workingtree import WorkingTree
29
31
 
30
32
 
141
143
        os.chdir('branch_b')
142
144
        out = self.runbzr('merge', retcode=3)
143
145
        self.assertEquals(out,
144
 
                ('','bzr: ERROR: No merge branch known or specified.\n'))
 
146
                ('','bzr: ERROR: No location specified or remembered\n'))
145
147
        # test implicit --remember when no parent set, this merge conflicts
146
148
        self.build_tree(['d'])
147
149
        tree_b.add('d')
152
154
        # test implicit --remember after resolving conflict
153
155
        tree_b.commit('commit d')
154
156
        out, err = self.runbzr('merge')
155
 
        self.assertEquals(out, 'Using saved branch: ../branch_a\n')
 
157
        
 
158
        base = urlutils.local_path_from_url(branch_a.base)
 
159
        self.assertEquals(out, 'Merging from remembered location %s\n' % (base,))
156
160
        self.assertEquals(err, 'All changes applied successfully.\n')
157
161
        self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
158
162
        # re-open tree as external runbzr modified it
167
171
        # re-open tree as external runbzr modified it
168
172
        tree_b = branch_b.bzrdir.open_workingtree()
169
173
        tree_b.commit('merge branch_c')
 
174
 
 
175
    def test_merge_bundle(self):
 
176
        from bzrlib.testament import Testament
 
177
        tree_a = self.make_branch_and_tree('branch_a')
 
178
        f = file('branch_a/a', 'wb')
 
179
        f.write('hello')
 
180
        f.close()
 
181
        tree_a.add('a')
 
182
        tree_a.commit('message')
 
183
 
 
184
        tree_b = tree_a.bzrdir.sprout('branch_b').open_workingtree()
 
185
        f = file('branch_a/a', 'wb')
 
186
        f.write('hey there')
 
187
        f.close()
 
188
        tree_a.commit('message')
 
189
 
 
190
        f = file('branch_b/a', 'wb')
 
191
        f.write('goodbye')
 
192
        f.close()
 
193
        tree_b.commit('message')
 
194
        os.chdir('branch_b')
 
195
        file('../bundle', 'wb').write(self.runbzr('bundle ../branch_a')[0])
 
196
        os.chdir('../branch_a')
 
197
        self.runbzr('merge ../bundle', retcode=1)
 
198
        testament_a = Testament.from_revision(tree_a.branch.repository, 
 
199
                                              tree_b.last_revision())
 
200
        testament_b = Testament.from_revision(tree_b.branch.repository,
 
201
                                              tree_b.last_revision())
 
202
        self.assertEqualDiff(testament_a.as_text(),
 
203
                         testament_b.as_text())
 
204
        tree_a.set_conflicts(ConflictList())
 
205
        tree_a.commit('message')
 
206
        # it is legal to attempt to merge an already-merged bundle
 
207
        output = self.runbzr('merge ../bundle')[1]
 
208
        # but it does nothing
 
209
        self.assertFalse(tree_a.changes_from(tree_a.basis_tree()).has_changed())
 
210
        self.assertEqual('Nothing to do.\n', output)