~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-06-28 07:08:27 UTC
  • mfrom: (2553.1.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070628070827-h5s313dg5tnag9vj
(robertc) Show the names of commit hooks during commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import os
23
23
 
24
 
from bzrlib import merge_directive
25
24
from bzrlib.branch import Branch
26
25
from bzrlib.bzrdir import BzrDir
27
26
from bzrlib.conflicts import ConflictList, ContentsConflict
45
44
    def test_merge_reprocess(self):
46
45
        d = BzrDir.create_standalone_workingtree('.')
47
46
        d.commit('h')
48
 
        self.run_bzr('merge . --reprocess --merge-type weave')
 
47
        self.run_bzr('merge', '.', '--reprocess', '--merge-type', 'weave')
49
48
 
50
49
    def test_merge(self):
51
50
        from bzrlib.branch import Branch
234
233
        tree_a.commit('commit 2')
235
234
        tree_a.rename_one('file_2', 'file_ii')
236
235
        ## os.chdir('b')
237
 
        self.run_bzr('merge a --uncommitted -d b')
 
236
        self.run_bzr('merge', 'a', '--uncommitted', '-d', 'b')
238
237
        self.failUnlessExists('b/file_1')
239
238
        self.failUnlessExists('b/file_ii')
240
239
        tree_b.revert([])
241
240
        self.run_bzr_error(('Cannot use --uncommitted and --revision',),
242
 
                           'merge /a --uncommitted -r1 -d b')
 
241
                           'merge', '/a', '--uncommitted', '-r1',
 
242
                           '-d', 'b')
243
243
 
244
244
    def pullable_branch(self):
245
245
        os.mkdir('a')
266
266
    def test_merge_pull(self):
267
267
        self.pullable_branch()
268
268
        os.chdir('a')
269
 
        (out, err) = self.run_bzr('merge --pull ../b')
 
269
        (out, err) = self.run_bzr('merge', '--pull', '../b')
270
270
        self.assertContainsRe(err, 'Now on revision 2\\.')
271
271
        tree_a = WorkingTree.open('.')
272
272
        self.assertEqual([self.id2], tree_a.get_parent_ids())
281
281
        self.build_tree(['tree_a/file/'])
282
282
        tree_a.commit('changed file to directory')
283
283
        os.chdir('tree_b')
284
 
        self.run_bzr('merge ../tree_a')
 
284
        self.run_bzr('merge', '../tree_a')
285
285
        self.assertEqual('directory', file_kind('file'))
286
286
        tree_b.revert([])
287
287
        self.assertEqual('file', file_kind('file'))
288
288
        self.build_tree_contents([('file', 'content_2')])
289
289
        tree_b.commit('content change')
290
 
        self.run_bzr('merge ../tree_a', retcode=1)
 
290
        self.run_bzr('merge', '../tree_a', retcode=1)
291
291
        self.assertEqual(tree_b.conflicts(),
292
292
                         [ContentsConflict('file', file_id='file-id')])
293
 
 
294
 
    def test_directive_cherrypick(self):
295
 
        source = self.make_branch_and_tree('source')
296
 
        self.build_tree(['source/a'])
297
 
        source.add('a')
298
 
        source.commit('Added a', rev_id='rev1')
299
 
        self.build_tree(['source/b'])
300
 
        source.add('b')
301
 
        source.commit('Added b', rev_id='rev2')
302
 
        target = self.make_branch_and_tree('target')
303
 
        target.commit('empty commit')
304
 
        self.write_directive('directive', source.branch, 'target', 'rev2',
305
 
                             'rev1')
306
 
        self.run_bzr('merge -d target directive')
307
 
        self.failIfExists('target/a')
308
 
        self.failUnlessExists('target/b')
309
 
 
310
 
    def write_directive(self, filename, source, target, revision_id,
311
 
                        base_revision_id=None, mangle_patch=False):
312
 
        md = merge_directive.MergeDirective2.from_objects(
313
 
            source.repository, revision_id, 0, 0, target,
314
 
            base_revision_id=base_revision_id)
315
 
        if mangle_patch:
316
 
            md.patch = 'asdf\n'
317
 
        self.build_tree_contents([(filename, ''.join(md.to_lines()))])
318
 
 
319
 
    def test_directive_verify_warning(self):
320
 
        source = self.make_branch_and_tree('source')
321
 
        self.build_tree(['source/a'])
322
 
        source.add('a')
323
 
        source.commit('Added a', rev_id='rev1')
324
 
        target = self.make_branch_and_tree('target')
325
 
        target.commit('empty commit')
326
 
        self.write_directive('directive', source.branch, 'target', 'rev1')
327
 
        err = self.run_bzr('merge -d target directive')[1]
328
 
        self.assertNotContainsRe(err, 'Preview patch does not match changes')
329
 
        target.revert([])
330
 
        self.write_directive('directive', source.branch, 'target', 'rev1',
331
 
                             mangle_patch=True)
332
 
        err = self.run_bzr('merge -d target directive')[1]
333
 
        self.assertContainsRe(err, 'Preview patch does not match changes')