1
# Copyright (C) 2010, 2011 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
from breezy.bzr import conflicts as _mod_bzr_conflicts
22
from breezy.tests import (
26
from breezy.tests.blackbox import test_conflicts
29
class TestResolve(script.TestCaseWithTransportAndScript):
32
super(TestResolve, self).setUp()
33
test_conflicts.make_tree_with_conflicts(self, 'branch', 'other')
35
def test_resolve_one_by_one(self):
39
Text conflict in my_other_file
40
Path conflict: mydir3 / mydir2
41
Text conflict in myfile
43
2>1 conflict resolved, 2 remaining
44
$ brz resolve my_other_file
45
2>1 conflict resolved, 1 remaining
47
2>1 conflict resolved, 0 remaining
50
def test_resolve_all(self):
54
2>3 conflicts resolved, 0 remaining
58
def test_resolve_from_subdir(self):
62
$ brz resolve ../myfile
63
2>1 conflict resolved, 2 remaining
66
def test_resolve_via_directory_option(self):
68
$ brz resolve -d branch myfile
69
2>1 conflict resolved, 2 remaining
72
def test_resolve_all_via_directory_option(self):
74
$ brz resolve -d branch --all
75
2>3 conflicts resolved, 0 remaining
76
$ brz conflicts -d branch
79
def test_bug_842575_manual_rm(self):
82
$ echo original > trunk/foo
83
$ brz add -q trunk/foo
84
$ brz commit -q -m first trunk
85
$ brz checkout -q trunk tree
87
$ brz commit -q -m second trunk
88
$ echo modified > tree/foo
91
2>Contents conflict in foo
92
2>1 conflicts encountered.
93
2>Updated to revision 2 of branch ...
94
$ rm tree/foo.BASE tree/foo.THIS
95
$ brz resolve --all -d tree
96
2>1 conflict resolved, 0 remaining
102
except AssertionError:
103
raise KnownFailure("bug #842575")
105
def test_bug_842575_take_other(self):
108
$ echo original > trunk/foo
109
$ brz add -q trunk/foo
110
$ brz commit -q -m first trunk
111
$ brz checkout -q --lightweight trunk tree
112
$ brz rm -q trunk/foo
113
$ brz ignore -d trunk foo
114
$ brz commit -q -m second trunk
115
$ echo modified > tree/foo
119
2>Contents conflict in foo
120
2>1 conflicts encountered.
121
2>Updated to revision 2 of branch ...
122
$ brz resolve --take-other --all -d tree
123
2>1 conflict resolved, 0 remaining
128
$ echo mustignore > tree/foo
131
except AssertionError:
132
raise KnownFailure("bug 842575")
135
class TestBug788000(script.TestCaseWithTransportAndScript):
137
def test_bug_788000(self):
141
$ echo foo > a/dir/file
147
$ echo bar > b/dir/file
153
null_output_matches_anything=True)
157
Using saved parent location:...
159
2>RM dir/file => dir/file.THIS
160
2>Conflict: can't delete dir because it is not empty. Not deleting.
161
2>Conflict because dir is not versioned, but has versioned children...
162
2>Contents conflict in dir/file
163
2>3 conflicts encountered.
166
$ brz resolve --take-other
167
2>deleted dir/file.THIS
169
2>3 conflicts resolved, 0 remaining
173
class TestResolveAuto(tests.TestCaseWithTransport):
175
def test_auto_resolve(self):
176
"""Text conflicts can be resolved automatically"""
177
tree = self.make_branch_and_tree('tree')
178
self.build_tree_contents([('tree/file',
179
b'<<<<<<<\na\n=======\n>>>>>>>\n')])
180
tree.add('file', b'file_id')
181
self.assertEqual(tree.kind('file'), 'file')
182
file_conflict = _mod_bzr_conflicts.TextConflict('file', file_id=b'file_id')
183
tree.set_conflicts([file_conflict])
184
note = self.run_bzr('resolve', retcode=1, working_dir='tree')[1]
185
self.assertContainsRe(note, '0 conflicts auto-resolved.')
186
self.assertContainsRe(note,
187
'Remaining conflicts:\nText conflict in file')
188
self.build_tree_contents([('tree/file', b'a\n')])
189
note = self.run_bzr('resolve', working_dir='tree')[1]
190
self.assertContainsRe(note, 'All conflicts resolved.')