~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2007-03-28 07:08:42 UTC
  • mfrom: (2380 +trunk)
  • mto: (2018.5.146 hpss)
  • mto: This revision was merged to the branch mainline in revision 2414.
  • Revision ID: andrew.bennetts@canonical.com-20070328070842-r843houy668oxb9o
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import os
18
18
 
 
19
from bzrlib import (
 
20
    conflicts
 
21
    )
19
22
from bzrlib.workingtree import WorkingTree
20
23
from bzrlib.tests.blackbox import ExternalBase
21
24
 
59
62
        self.assertEqual(['my_other_file', 'myfile'], conflicts)
60
63
 
61
64
    def test_resolve(self):
62
 
        self.runbzr('resolve', retcode=3)
63
65
        self.runbzr('resolve myfile')
64
66
        conflicts = self.runbzr('conflicts', backtick=True)
65
67
        self.assertEqual(2, len(conflicts.splitlines()))
88
90
                self.fail("tree still contains conflicts: %r" % conflicts)
89
91
        finally:
90
92
            os.chdir(orig_dir)
 
93
 
 
94
    def test_auto_resolve(self):
 
95
        """Text conflicts can be resolved automatically"""
 
96
        tree = self.make_branch_and_tree('tree')
 
97
        self.build_tree_contents([('tree/file',
 
98
            '<<<<<<<\na\n=======\n>>>>>>>\n')])
 
99
        tree.add('file', 'file_id')
 
100
        self.assertEqual(tree.kind('file_id'), 'file')
 
101
        file_conflict = conflicts.TextConflict('file', file_id='file_id')
 
102
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
 
103
        os.chdir('tree')
 
104
        note = self.run_bzr('resolve', retcode=1)[1]
 
105
        self.assertContainsRe(note, '0 conflict\\(s\\) auto-resolved.')
 
106
        self.assertContainsRe(note,
 
107
            'Remaining conflicts:\nText conflict in file')
 
108
        self.build_tree_contents([('file', 'a\n')])
 
109
        note = self.run_bzr('resolve')[1]
 
110
        self.assertContainsRe(note, 'All conflicts resolved.')