~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2006-06-13 13:24:40 UTC
  • mfrom: (1767 +trunk)
  • mto: (1769.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1770.
  • Revision ID: jelmer@samba.org-20060613132440-24e222a86f948f60
[merge] bzr.dev

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