~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-07-19 16:09:34 UTC
  • mfrom: (2520.4.135 bzr.mpbundle)
  • Revision ID: pqm@pqm.ubuntu.com-20070719160934-d51fyijw69oto88p
Add new bundle and merge-directive formats

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
24
25
from bzrlib.branch import Branch
25
26
from bzrlib.bzrdir import BzrDir
26
27
from bzrlib.conflicts import ConflictList, ContentsConflict
289
290
        self.run_bzr('merge ../tree_a', retcode=1)
290
291
        self.assertEqual(tree_b.conflicts(),
291
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')