4597.2.2
by Vincent Ladeuil
Cleanup conflict tests. |
1 |
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1185.14.8
by Aaron Bentley
Added test_commit.py |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
1185.14.8
by Aaron Bentley
Added test_commit.py |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
1185.14.8
by Aaron Bentley
Added test_commit.py |
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1185.14.8
by Aaron Bentley
Added test_commit.py |
16 |
|
17 |
||
18 |
import os |
|
19 |
||
4597.2.2
by Vincent Ladeuil
Cleanup conflict tests. |
20 |
from bzrlib import ( |
21 |
bzrdir, |
|
22 |
conflicts, |
|
23 |
errors, |
|
4597.3.51
by Vincent Ladeuil
Implement conflicts.ResolveActionOption. |
24 |
option, |
4597.2.2
by Vincent Ladeuil
Cleanup conflict tests. |
25 |
tests, |
26 |
)
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
27 |
from bzrlib.tests import script |
1185.14.8
by Aaron Bentley
Added test_commit.py |
28 |
|
1534.10.4
by Aaron Bentley
Implemented conflict serialization |
29 |
|
1185.14.8
by Aaron Bentley
Added test_commit.py |
30 |
# TODO: Test commit with some added, and added-but-missing files
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
31 |
# RBC 20060124 is that not tested in test_commit.py ?
|
1185.14.8
by Aaron Bentley
Added test_commit.py |
32 |
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
33 |
# The order of 'path' here is important - do not let it
|
34 |
# be a sorted list.
|
|
2309.4.13
by John Arbash Meinel
Conflicts go through Stanza so the need to be aware of utf8 versus unicode file ids. |
35 |
# u'\xe5' == a with circle
|
36 |
# '\xc3\xae' == u'\xee' == i with hat
|
|
4597.2.2
by Vincent Ladeuil
Cleanup conflict tests. |
37 |
# So these are u'path' and 'id' only with a circle and a hat. (shappo?)
|
38 |
example_conflicts = conflicts.ConflictList( |
|
39 |
[conflicts.MissingParent('Not deleting', u'p\xe5thg', '\xc3\xaedg'), |
|
40 |
conflicts.ContentsConflict(u'p\xe5tha', None, '\xc3\xaeda'), |
|
41 |
conflicts.TextConflict(u'p\xe5tha'), |
|
42 |
conflicts.PathConflict(u'p\xe5thb', u'p\xe5thc', '\xc3\xaedb'), |
|
43 |
conflicts.DuplicateID('Unversioned existing file', |
|
44 |
u'p\xe5thc', u'p\xe5thc2', |
|
45 |
'\xc3\xaedc', '\xc3\xaedc'), |
|
46 |
conflicts.DuplicateEntry('Moved existing file to', |
|
47 |
u'p\xe5thdd.moved', u'p\xe5thd', |
|
48 |
'\xc3\xaedd', None), |
|
49 |
conflicts.ParentLoop('Cancelled move', u'p\xe5the', u'p\xe5th2e', |
|
50 |
None, '\xc3\xaed2e'), |
|
51 |
conflicts.UnversionedParent('Versioned directory', |
|
52 |
u'p\xe5thf', '\xc3\xaedf'), |
|
53 |
conflicts.NonDirectoryParent('Created directory', |
|
54 |
u'p\xe5thg', '\xc3\xaedg'), |
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
55 |
])
|
1534.10.4
by Aaron Bentley
Implemented conflict serialization |
56 |
|
57 |
||
4597.2.2
by Vincent Ladeuil
Cleanup conflict tests. |
58 |
class TestConflicts(tests.TestCaseWithTransport): |
1185.14.8
by Aaron Bentley
Added test_commit.py |
59 |
|
60 |
def test_conflicts(self): |
|
61 |
"""Conflicts are detected properly"""
|
|
4597.2.3
by Vincent Ladeuil
More cleanup. |
62 |
# Use BzrDirFormat6 so we can fake conflicts
|
63 |
tree = self.make_branch_and_tree('.', format=bzrdir.BzrDirFormat6()) |
|
64 |
self.build_tree_contents([('hello', 'hello world4'), |
|
65 |
('hello.THIS', 'hello world2'), |
|
66 |
('hello.BASE', 'hello world1'), |
|
67 |
('hello.OTHER', 'hello world3'), |
|
68 |
('hello.sploo.BASE', 'yellowworld'), |
|
69 |
('hello.sploo.OTHER', 'yellowworld2'), |
|
70 |
])
|
|
2255.2.61
by John Arbash Meinel
Find callers of list_files() and make sure the tree is always locked. |
71 |
tree.lock_read() |
4597.2.2
by Vincent Ladeuil
Cleanup conflict tests. |
72 |
self.assertEqual(6, len(list(tree.list_files()))) |
2255.2.61
by John Arbash Meinel
Find callers of list_files() and make sure the tree is always locked. |
73 |
tree.unlock() |
4597.2.3
by Vincent Ladeuil
More cleanup. |
74 |
tree_conflicts = tree.conflicts() |
75 |
self.assertEqual(2, len(tree_conflicts)) |
|
76 |
self.assertTrue('hello' in tree_conflicts[0].path) |
|
77 |
self.assertTrue('hello.sploo' in tree_conflicts[1].path) |
|
78 |
conflicts.restore('hello') |
|
79 |
conflicts.restore('hello.sploo') |
|
4597.2.2
by Vincent Ladeuil
Cleanup conflict tests. |
80 |
self.assertEqual(0, len(tree.conflicts())) |
1185.35.1
by Aaron Bentley
Implemented conflicts.restore |
81 |
self.assertFileEqual('hello world2', 'hello') |
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
82 |
self.assertFalse(os.path.lexists('hello.sploo')) |
4597.2.3
by Vincent Ladeuil
More cleanup. |
83 |
self.assertRaises(errors.NotConflicted, conflicts.restore, 'hello') |
84 |
self.assertRaises(errors.NotConflicted, |
|
85 |
conflicts.restore, 'hello.sploo') |
|
1534.10.4
by Aaron Bentley
Implemented conflict serialization |
86 |
|
1558.12.9
by Aaron Bentley
Handle resolving conflicts with directories properly |
87 |
def test_resolve_conflict_dir(self): |
88 |
tree = self.make_branch_and_tree('.') |
|
4597.2.3
by Vincent Ladeuil
More cleanup. |
89 |
self.build_tree_contents([('hello', 'hello world4'), |
90 |
('hello.THIS', 'hello world2'), |
|
91 |
('hello.BASE', 'hello world1'), |
|
92 |
])
|
|
93 |
os.mkdir('hello.OTHER') |
|
1558.12.9
by Aaron Bentley
Handle resolving conflicts with directories properly |
94 |
tree.add('hello', 'q') |
4597.2.3
by Vincent Ladeuil
More cleanup. |
95 |
l = conflicts.ConflictList([conflicts.TextConflict('hello')]) |
1558.12.9
by Aaron Bentley
Handle resolving conflicts with directories properly |
96 |
l.remove_files(tree) |
97 |
||
1551.15.58
by Aaron Bentley
Status honours selected paths for conflicts (#127606) |
98 |
def test_select_conflicts(self): |
99 |
tree = self.make_branch_and_tree('.') |
|
4597.2.3
by Vincent Ladeuil
More cleanup. |
100 |
clist = conflicts.ConflictList |
101 |
||
102 |
def check_select(not_selected, selected, paths, **kwargs): |
|
103 |
self.assertEqual( |
|
104 |
(not_selected, selected), |
|
105 |
tree_conflicts.select_conflicts(tree, paths, **kwargs)) |
|
106 |
||
107 |
foo = conflicts.ContentsConflict('foo') |
|
108 |
bar = conflicts.ContentsConflict('bar') |
|
109 |
tree_conflicts = clist([foo, bar]) |
|
110 |
||
111 |
check_select(clist([bar]), clist([foo]), ['foo']) |
|
112 |
check_select(clist(), tree_conflicts, |
|
113 |
[''], ignore_misses=True, recurse=True) |
|
114 |
||
115 |
foobaz = conflicts.ContentsConflict('foo/baz') |
|
116 |
tree_conflicts = clist([foobaz, bar]) |
|
117 |
||
118 |
check_select(clist([bar]), clist([foobaz]), |
|
119 |
['foo'], ignore_misses=True, recurse=True) |
|
120 |
||
121 |
qux = conflicts.PathConflict('qux', 'foo/baz') |
|
122 |
tree_conflicts = clist([qux]) |
|
123 |
||
124 |
check_select(clist(), tree_conflicts, |
|
125 |
['foo'], ignore_misses=True, recurse=True) |
|
126 |
check_select (tree_conflicts, clist(), ['foo'], ignore_misses=True) |
|
1551.15.58
by Aaron Bentley
Status honours selected paths for conflicts (#127606) |
127 |
|
3017.2.1
by Aaron Bentley
Revert now resolves conflicts recursively (#102739) |
128 |
def test_resolve_conflicts_recursive(self): |
129 |
tree = self.make_branch_and_tree('.') |
|
130 |
self.build_tree(['dir/', 'dir/hello']) |
|
131 |
tree.add(['dir', 'dir/hello']) |
|
4597.2.3
by Vincent Ladeuil
More cleanup. |
132 |
|
133 |
dirhello = conflicts.ConflictList([conflicts.TextConflict('dir/hello')]) |
|
134 |
tree.set_conflicts(dirhello) |
|
135 |
||
136 |
conflicts.resolve(tree, ['dir'], recursive=False, ignore_misses=True) |
|
137 |
self.assertEqual(dirhello, tree.conflicts()) |
|
138 |
||
139 |
conflicts.resolve(tree, ['dir'], recursive=True, ignore_misses=True) |
|
140 |
self.assertEqual(conflicts.ConflictList([]), tree.conflicts()) |
|
4773.1.1
by Vincent Ladeuil
Cleanup imports in test_conflicts |
141 |
|
142 |
||
4597.3.43
by Vincent Ladeuil
Cleanups, ready to record. |
143 |
class TestConflictStanzas(tests.TestCase): |
144 |
||
145 |
def test_stanza_roundtrip(self): |
|
146 |
# write and read our example stanza.
|
|
147 |
stanza_iter = example_conflicts.to_stanzas() |
|
148 |
processed = conflicts.ConflictList.from_stanzas(stanza_iter) |
|
149 |
for o, p in zip(processed, example_conflicts): |
|
150 |
self.assertEqual(o, p) |
|
151 |
||
152 |
self.assertIsInstance(o.path, unicode) |
|
153 |
||
154 |
if o.file_id is not None: |
|
155 |
self.assertIsInstance(o.file_id, str) |
|
156 |
||
157 |
conflict_path = getattr(o, 'conflict_path', None) |
|
158 |
if conflict_path is not None: |
|
159 |
self.assertIsInstance(conflict_path, unicode) |
|
160 |
||
161 |
conflict_file_id = getattr(o, 'conflict_file_id', None) |
|
162 |
if conflict_file_id is not None: |
|
163 |
self.assertIsInstance(conflict_file_id, str) |
|
164 |
||
165 |
def test_stanzification(self): |
|
166 |
for stanza in example_conflicts.to_stanzas(): |
|
167 |
if 'file_id' in stanza: |
|
168 |
# In Stanza form, the file_id has to be unicode.
|
|
169 |
self.assertStartsWith(stanza['file_id'], u'\xeed') |
|
170 |
self.assertStartsWith(stanza['path'], u'p\xe5th') |
|
171 |
if 'conflict_path' in stanza: |
|
172 |
self.assertStartsWith(stanza['conflict_path'], u'p\xe5th') |
|
173 |
if 'conflict_file_id' in stanza: |
|
174 |
self.assertStartsWith(stanza['conflict_file_id'], u'\xeed') |
|
175 |
||
176 |
||
4597.3.31
by Vincent Ladeuil
Implement --interactive for MissingParent. |
177 |
# FIXME: Tests missing for DuplicateID conflict type
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
178 |
class TestResolveConflicts(script.TestCaseWithTransportAndScript): |
179 |
||
180 |
preamble = None # The setup script set by daughter classes |
|
181 |
||
182 |
def setUp(self): |
|
183 |
super(TestResolveConflicts, self).setUp() |
|
184 |
self.run_script(self.preamble) |
|
185 |
||
186 |
||
187 |
class TestResolveTextConflicts(TestResolveConflicts): |
|
188 |
# TBC
|
|
189 |
pass
|
|
190 |
||
191 |
||
192 |
class TestResolveContentConflicts(TestResolveConflicts): |
|
193 |
||
194 |
# FIXME: We need to add the reverse case (delete in trunk, modify in
|
|
195 |
# branch) but that could wait until the resolution mechanism is implemented.
|
|
196 |
||
197 |
preamble = """ |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
198 |
$ bzr init trunk
|
199 |
$ cd trunk
|
|
200 |
$ echo 'trunk content' >file
|
|
201 |
$ bzr add file
|
|
202 |
$ bzr commit -m 'Create trunk'
|
|
203 |
||
204 |
$ bzr branch . ../branch
|
|
205 |
$ cd ../branch
|
|
206 |
$ bzr rm file
|
|
207 |
$ bzr commit -m 'Delete file'
|
|
208 |
||
209 |
$ cd ../trunk
|
|
210 |
$ echo 'more content' >>file
|
|
211 |
$ bzr commit -m 'Modify file'
|
|
212 |
||
213 |
$ cd ../branch
|
|
214 |
$ bzr merge ../trunk
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
215 |
2>+N file.OTHER
|
216 |
2>Contents conflict in file
|
|
217 |
2>1 conflicts encountered.
|
|
218 |
"""
|
|
219 |
||
4597.3.28
by Vincent Ladeuil
Implement --interactive for ContentsConflict. |
220 |
def test_keep_mine(self): |
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
221 |
self.run_script(""" |
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
222 |
$ bzr rm file.OTHER --force # a simple rm file.OTHER is valid too
|
223 |
$ bzr resolve file
|
|
224 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
225 |
""") |
226 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
227 |
def test_take_theirs(self): |
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
228 |
self.run_script(""" |
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
229 |
$ bzr mv file.OTHER file
|
230 |
$ bzr resolve file
|
|
231 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
232 |
""") |
233 |
||
4597.3.28
by Vincent Ladeuil
Implement --interactive for ContentsConflict. |
234 |
def test_resolve_keeping_mine(self): |
235 |
self.run_script(""" |
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
236 |
$ bzr resolve --keep-mine file
|
4597.3.28
by Vincent Ladeuil
Implement --interactive for ContentsConflict. |
237 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
238 |
""") |
|
239 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
240 |
def test_resolve_taking_theirs(self): |
4597.3.28
by Vincent Ladeuil
Implement --interactive for ContentsConflict. |
241 |
self.run_script(""" |
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
242 |
$ bzr resolve --take-theirs file
|
4597.3.28
by Vincent Ladeuil
Implement --interactive for ContentsConflict. |
243 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
244 |
""") |
|
245 |
||
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
246 |
|
4597.3.31
by Vincent Ladeuil
Implement --interactive for MissingParent. |
247 |
class TestResolveDuplicateEntry(TestResolveConflicts): |
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
248 |
|
249 |
preamble = """ |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
250 |
$ bzr init trunk
|
251 |
$ cd trunk
|
|
252 |
$ echo 'trunk content' >file
|
|
253 |
$ bzr add file
|
|
254 |
$ bzr commit -m 'Create trunk'
|
|
255 |
$ echo 'trunk content too' >file2
|
|
256 |
$ bzr add file2
|
|
257 |
$ bzr commit -m 'Add file2 in trunk'
|
|
258 |
||
259 |
$ bzr branch . -r 1 ../branch
|
|
260 |
$ cd ../branch
|
|
261 |
$ echo 'branch content' >file2
|
|
262 |
$ bzr add file2
|
|
263 |
$ bzr commit -m 'Add file2 in branch'
|
|
264 |
||
265 |
$ bzr merge ../trunk
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
266 |
2>+N file2
|
267 |
2>R file2 => file2.moved
|
|
268 |
2>Conflict adding file file2. Moved existing file to file2.moved.
|
|
269 |
2>1 conflicts encountered.
|
|
270 |
"""
|
|
271 |
||
272 |
def test_keep_this(self): |
|
273 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
274 |
$ bzr rm file2 --force
|
275 |
$ bzr mv file2.moved file2
|
|
276 |
$ bzr resolve file2
|
|
277 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
278 |
""") |
279 |
||
280 |
def test_keep_other(self): |
|
281 |
self.failIfExists('branch/file2.moved') |
|
282 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
283 |
$ bzr rm file2.moved --force
|
284 |
$ bzr resolve file2
|
|
285 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
286 |
""") |
287 |
self.failIfExists('branch/file2.moved') |
|
288 |
||
4597.3.27
by Vincent Ladeuil
(keep_mine, take_theirs) sounds clearer than (keep_this, keep_other). |
289 |
def test_resolve_keeping_mine(self): |
4597.3.19
by Vincent Ladeuil
Some failing tests. |
290 |
self.run_script(""" |
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
291 |
$ bzr resolve --keep-mine file2
|
4597.3.19
by Vincent Ladeuil
Some failing tests. |
292 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
293 |
""") |
|
294 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
295 |
def test_resolve_taking_theirs(self): |
4597.3.19
by Vincent Ladeuil
Some failing tests. |
296 |
self.run_script(""" |
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
297 |
$ bzr resolve --take-theirs file2
|
4597.3.19
by Vincent Ladeuil
Some failing tests. |
298 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
299 |
""") |
|
300 |
||
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
301 |
|
302 |
class TestResolveUnversionedParent(TestResolveConflicts): |
|
303 |
||
4597.3.29
by Vincent Ladeuil
Fix bogus tests. |
304 |
# FIXME: Add the reverse tests: dir deleted in trunk, file added in branch
|
305 |
||
4597.3.30
by Vincent Ladeuil
Light changes learned while starting to understand multiple conflicts on |
306 |
# FIXME: While this *creates* UnversionedParent conflicts, this really only
|
307 |
# tests MissingParent resolution :-/
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
308 |
preamble = """ |
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
309 |
$ bzr init trunk
|
310 |
$ cd trunk
|
|
4597.3.29
by Vincent Ladeuil
Fix bogus tests. |
311 |
$ mkdir dir
|
312 |
$ bzr add dir
|
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
313 |
$ bzr commit -m 'Create trunk'
|
4597.3.29
by Vincent Ladeuil
Fix bogus tests. |
314 |
$ echo 'trunk content' >dir/file
|
315 |
$ bzr add dir/file
|
|
316 |
$ bzr commit -m 'Add dir/file in trunk'
|
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
317 |
|
318 |
$ bzr branch . -r 1 ../branch
|
|
319 |
$ cd ../branch
|
|
4597.3.29
by Vincent Ladeuil
Fix bogus tests. |
320 |
$ bzr rm dir
|
321 |
$ bzr commit -m 'Remove dir in branch'
|
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
322 |
|
323 |
$ bzr merge ../trunk
|
|
4597.3.29
by Vincent Ladeuil
Fix bogus tests. |
324 |
2>+N dir/
|
325 |
2>+N dir/file
|
|
326 |
2>Conflict adding files to dir. Created directory.
|
|
327 |
2>Conflict because dir is not versioned, but has versioned children. Versioned directory.
|
|
328 |
2>2 conflicts encountered.
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
329 |
"""
|
330 |
||
4597.3.29
by Vincent Ladeuil
Fix bogus tests. |
331 |
def test_keep_mine(self): |
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
332 |
self.run_script(""" |
4597.3.29
by Vincent Ladeuil
Fix bogus tests. |
333 |
$ bzr rm dir --force
|
334 |
$ bzr resolve dir
|
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
335 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
336 |
""") |
337 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
338 |
def test_take_theirs(self): |
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
339 |
self.run_script(""" |
4597.3.29
by Vincent Ladeuil
Fix bogus tests. |
340 |
$ bzr resolve dir
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
341 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
342 |
""") |
343 |
||
344 |
||
345 |
class TestResolveMissingParent(TestResolveConflicts): |
|
346 |
||
347 |
preamble = """ |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
348 |
$ bzr init trunk
|
349 |
$ cd trunk
|
|
350 |
$ mkdir dir
|
|
351 |
$ echo 'trunk content' >dir/file
|
|
352 |
$ bzr add
|
|
353 |
$ bzr commit -m 'Create trunk'
|
|
354 |
$ echo 'trunk content' >dir/file2
|
|
355 |
$ bzr add dir/file2
|
|
356 |
$ bzr commit -m 'Add dir/file2 in branch'
|
|
357 |
||
358 |
$ bzr branch . -r 1 ../branch
|
|
359 |
$ cd ../branch
|
|
360 |
$ bzr rm dir/file --force
|
|
361 |
$ bzr rm dir
|
|
362 |
$ bzr commit -m 'Remove dir/file'
|
|
363 |
||
364 |
$ bzr merge ../trunk
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
365 |
2>+N dir/
|
366 |
2>+N dir/file2
|
|
367 |
2>Conflict adding files to dir. Created directory.
|
|
368 |
2>Conflict because dir is not versioned, but has versioned children. Versioned directory.
|
|
369 |
2>2 conflicts encountered.
|
|
370 |
"""
|
|
371 |
||
372 |
def test_keep_them_all(self): |
|
373 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
374 |
$ bzr resolve dir
|
375 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
376 |
""") |
377 |
||
378 |
def test_adopt_child(self): |
|
379 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
380 |
$ bzr mv dir/file2 file2
|
381 |
$ bzr rm dir --force
|
|
382 |
$ bzr resolve dir
|
|
383 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
384 |
""") |
385 |
||
386 |
def test_kill_them_all(self): |
|
387 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
388 |
$ bzr rm dir --force
|
389 |
$ bzr resolve dir
|
|
390 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
391 |
""") |
392 |
||
4597.3.31
by Vincent Ladeuil
Implement --interactive for MissingParent. |
393 |
def test_resolve_keeping_mine(self): |
394 |
self.run_script(""" |
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
395 |
$ bzr resolve --keep-mine dir
|
4597.3.31
by Vincent Ladeuil
Implement --interactive for MissingParent. |
396 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
397 |
""") |
|
398 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
399 |
def test_resolve_taking_theirs(self): |
4597.3.31
by Vincent Ladeuil
Implement --interactive for MissingParent. |
400 |
self.run_script(""" |
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
401 |
$ bzr resolve --take-theirs dir
|
4597.3.31
by Vincent Ladeuil
Implement --interactive for MissingParent. |
402 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
403 |
""") |
|
404 |
||
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
405 |
|
406 |
class TestResolveDeletingParent(TestResolveConflicts): |
|
407 |
||
408 |
preamble = """ |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
409 |
$ bzr init trunk
|
410 |
$ cd trunk
|
|
411 |
$ mkdir dir
|
|
412 |
$ echo 'trunk content' >dir/file
|
|
413 |
$ bzr add
|
|
414 |
$ bzr commit -m 'Create trunk'
|
|
415 |
$ bzr rm dir/file --force
|
|
416 |
$ bzr rm dir --force
|
|
417 |
$ bzr commit -m 'Remove dir/file'
|
|
418 |
||
419 |
$ bzr branch . -r 1 ../branch
|
|
420 |
$ cd ../branch
|
|
421 |
$ echo 'branch content' >dir/file2
|
|
422 |
$ bzr add dir/file2
|
|
423 |
$ bzr commit -m 'Add dir/file2 in branch'
|
|
424 |
||
425 |
$ bzr merge ../trunk
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
426 |
2>-D dir/file
|
427 |
2>Conflict: can't delete dir because it is not empty. Not deleting.
|
|
428 |
2>Conflict because dir is not versioned, but has versioned children. Versioned directory.
|
|
429 |
2>2 conflicts encountered.
|
|
430 |
"""
|
|
431 |
||
432 |
def test_keep_them_all(self): |
|
433 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
434 |
$ bzr resolve dir
|
435 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
436 |
""") |
437 |
||
438 |
def test_adopt_child(self): |
|
439 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
440 |
$ bzr mv dir/file2 file2
|
441 |
$ bzr rm dir --force
|
|
442 |
$ bzr resolve dir
|
|
443 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
444 |
""") |
445 |
||
446 |
def test_kill_them_all(self): |
|
447 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
448 |
$ bzr rm dir --force
|
449 |
$ bzr resolve dir
|
|
450 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
451 |
""") |
452 |
||
4597.3.32
by Vincent Ladeuil
Implement --interactive for DeletingParent noting the inconsistency. |
453 |
def test_resolve_keeping_mine(self): |
454 |
self.run_script(""" |
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
455 |
$ bzr resolve --keep-mine dir
|
4597.3.32
by Vincent Ladeuil
Implement --interactive for DeletingParent noting the inconsistency. |
456 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
457 |
""") |
|
458 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
459 |
def test_resolve_taking_theirs(self): |
4597.3.32
by Vincent Ladeuil
Implement --interactive for DeletingParent noting the inconsistency. |
460 |
self.run_script(""" |
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
461 |
$ bzr resolve --take-theirs dir
|
4597.3.32
by Vincent Ladeuil
Implement --interactive for DeletingParent noting the inconsistency. |
462 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
463 |
""") |
|
464 |
||
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
465 |
|
466 |
class TestResolvePathConflict(TestResolveConflicts): |
|
467 |
||
468 |
preamble = """ |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
469 |
$ bzr init trunk
|
470 |
$ cd trunk
|
|
471 |
$ echo 'Boo!' >file
|
|
472 |
$ bzr add
|
|
473 |
$ bzr commit -m 'Create trunk'
|
|
474 |
$ bzr mv file file-in-trunk
|
|
475 |
$ bzr commit -m 'Renamed to file-in-trunk'
|
|
476 |
||
477 |
$ bzr branch . -r 1 ../branch
|
|
478 |
$ cd ../branch
|
|
479 |
$ bzr mv file file-in-branch
|
|
480 |
$ bzr commit -m 'Renamed to file-in-branch'
|
|
481 |
||
482 |
$ bzr merge ../trunk
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
483 |
2>R file-in-branch => file-in-trunk
|
484 |
2>Path conflict: file-in-branch / file-in-trunk
|
|
485 |
2>1 conflicts encountered.
|
|
486 |
"""
|
|
487 |
||
488 |
def test_keep_source(self): |
|
489 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
490 |
$ bzr resolve file-in-trunk
|
491 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
492 |
""") |
493 |
||
494 |
def test_keep_target(self): |
|
495 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
496 |
$ bzr mv file-in-trunk file-in-branch
|
497 |
$ bzr resolve file-in-branch
|
|
498 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
499 |
""") |
500 |
||
4597.3.33
by Vincent Ladeuil
Implement --interactive for PathConflict. |
501 |
def test_resolve_keeping_mine(self): |
502 |
self.run_script(""" |
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
503 |
$ bzr resolve --keep-mine file-in-branch
|
4597.3.33
by Vincent Ladeuil
Implement --interactive for PathConflict. |
504 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
505 |
""") |
|
506 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
507 |
def test_resolve_taking_theirs(self): |
4597.3.33
by Vincent Ladeuil
Implement --interactive for PathConflict. |
508 |
self.run_script(""" |
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
509 |
$ bzr resolve --take-theirs file-in-branch
|
4597.3.33
by Vincent Ladeuil
Implement --interactive for PathConflict. |
510 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
511 |
""") |
|
512 |
||
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
513 |
|
514 |
class TestResolveParentLoop(TestResolveConflicts): |
|
515 |
||
516 |
preamble = """ |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
517 |
$ bzr init trunk
|
518 |
$ cd trunk
|
|
519 |
$ bzr mkdir dir1
|
|
520 |
$ bzr mkdir dir2
|
|
521 |
$ bzr commit -m 'Create trunk'
|
|
522 |
$ bzr mv dir2 dir1
|
|
523 |
$ bzr commit -m 'Moved dir2 into dir1'
|
|
524 |
||
525 |
$ bzr branch . -r 1 ../branch
|
|
526 |
$ cd ../branch
|
|
527 |
$ bzr mv dir1 dir2
|
|
528 |
$ bzr commit -m 'Moved dir1 into dir2'
|
|
529 |
||
530 |
$ bzr merge ../trunk
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
531 |
2>Conflict moving dir2/dir1 into dir2. Cancelled move.
|
532 |
2>1 conflicts encountered.
|
|
533 |
"""
|
|
534 |
||
4597.3.34
by Vincent Ladeuil
Implement --interactive for ParentLoop. |
535 |
def test_keep_mine(self): |
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
536 |
self.run_script(""" |
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
537 |
$ bzr resolve dir2
|
538 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
539 |
""") |
540 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
541 |
def test_take_theirs(self): |
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
542 |
self.run_script(""" |
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
543 |
$ bzr mv dir2/dir1 dir1
|
544 |
$ bzr mv dir2 dir1
|
|
545 |
$ bzr resolve dir2
|
|
546 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
547 |
""") |
548 |
||
4597.3.34
by Vincent Ladeuil
Implement --interactive for ParentLoop. |
549 |
def test_resolve_keeping_mine(self): |
550 |
self.run_script(""" |
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
551 |
$ bzr resolve --keep-mine dir2
|
4597.3.34
by Vincent Ladeuil
Implement --interactive for ParentLoop. |
552 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
553 |
""") |
|
554 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
555 |
def test_resolve_taking_theirs(self): |
4597.3.34
by Vincent Ladeuil
Implement --interactive for ParentLoop. |
556 |
self.run_script(""" |
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
557 |
$ bzr resolve --take-theirs dir2
|
4597.3.34
by Vincent Ladeuil
Implement --interactive for ParentLoop. |
558 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
559 |
""") |
|
560 |
||
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
561 |
|
562 |
class TestResolveNonDirectoryParent(TestResolveConflicts): |
|
563 |
||
564 |
preamble = """ |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
565 |
$ bzr init trunk
|
566 |
$ cd trunk
|
|
567 |
$ bzr mkdir foo
|
|
568 |
$ bzr commit -m 'Create trunk'
|
|
569 |
$ echo "Boing" >foo/bar
|
|
570 |
$ bzr add foo/bar
|
|
571 |
$ bzr commit -m 'Add foo/bar'
|
|
572 |
||
573 |
$ bzr branch . -r 1 ../branch
|
|
574 |
$ cd ../branch
|
|
575 |
$ rm -r foo
|
|
576 |
$ echo "Boo!" >foo
|
|
577 |
$ bzr commit -m 'foo is now a file'
|
|
578 |
||
579 |
$ bzr merge ../trunk
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
580 |
2>+N foo.new/bar
|
581 |
2>RK foo => foo.new/
|
|
582 |
# FIXME: The message is misleading, foo.new *is* a directory when the message
|
|
583 |
# is displayed -- vila 090916
|
|
584 |
2>Conflict: foo.new is not a directory, but has files in it. Created directory.
|
|
585 |
2>1 conflicts encountered.
|
|
586 |
"""
|
|
587 |
||
4597.3.35
by Vincent Ladeuil
Implement --interactive for NonDirectoryParent, sort of. |
588 |
def test_keep_mine(self): |
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
589 |
self.run_script(""" |
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
590 |
$ bzr rm foo.new --force
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
591 |
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
|
592 |
# aside ? -- vila 090916
|
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
593 |
$ bzr add foo
|
594 |
$ bzr resolve foo.new
|
|
595 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
596 |
""") |
597 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
598 |
def test_take_theirs(self): |
4597.3.35
by Vincent Ladeuil
Implement --interactive for NonDirectoryParent, sort of. |
599 |
self.run_script(""" |
600 |
$ bzr rm foo --force
|
|
601 |
$ bzr mv foo.new foo
|
|
602 |
$ bzr resolve foo
|
|
603 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
|
604 |
""") |
|
605 |
||
606 |
def test_resolve_keeping_mine(self): |
|
607 |
self.run_script(""" |
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
608 |
$ bzr resolve --keep-mine foo.new
|
4597.3.35
by Vincent Ladeuil
Implement --interactive for NonDirectoryParent, sort of. |
609 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
610 |
""") |
|
611 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
612 |
def test_resolve_taking_theirs(self): |
4597.3.35
by Vincent Ladeuil
Implement --interactive for NonDirectoryParent, sort of. |
613 |
self.run_script(""" |
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
614 |
$ bzr resolve --take-theirs foo.new
|
4597.3.35
by Vincent Ladeuil
Implement --interactive for NonDirectoryParent, sort of. |
615 |
$ bzr commit --strict -m 'No more conflicts nor unknown files'
|
616 |
""") |
|
617 |
||
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
618 |
|
619 |
class TestMalformedTransform(script.TestCaseWithTransportAndScript): |
|
620 |
||
621 |
def test_bug_430129(self): |
|
622 |
# This is nearly like TestResolveNonDirectoryParent but with branch and
|
|
623 |
# trunk switched. As such it should certainly produce the same
|
|
624 |
# conflict.
|
|
625 |
self.run_script(""" |
|
4597.3.15
by Vincent Ladeuil
Update to new shell-like tests syntax. |
626 |
$ bzr init trunk
|
627 |
$ cd trunk
|
|
628 |
$ bzr mkdir foo
|
|
629 |
$ bzr commit -m 'Create trunk'
|
|
630 |
$ rm -r foo
|
|
631 |
$ echo "Boo!" >foo
|
|
632 |
$ bzr commit -m 'foo is now a file'
|
|
633 |
||
634 |
$ bzr branch . -r 1 ../branch
|
|
635 |
$ cd ../branch
|
|
636 |
$ echo "Boing" >foo/bar
|
|
637 |
$ bzr add foo/bar
|
|
638 |
$ bzr commit -m 'Add foo/bar'
|
|
639 |
||
640 |
$ bzr merge ../trunk
|
|
4597.3.12
by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions. |
641 |
2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]
|
642 |
""") |
|
4597.3.51
by Vincent Ladeuil
Implement conflicts.ResolveActionOption. |
643 |
|
644 |
||
645 |
class TestResolveActionOption(tests.TestCase): |
|
646 |
||
647 |
def setUp(self): |
|
648 |
super(TestResolveActionOption, self).setUp() |
|
649 |
self.options = [conflicts.ResolveActionOption()] |
|
650 |
self.parser = option.get_optparser(dict((o.name, o) |
|
651 |
for o in self.options)) |
|
652 |
||
653 |
def parse(self, args): |
|
654 |
return self.parser.parse_args(args) |
|
655 |
||
656 |
def test_unknown_action(self): |
|
657 |
self.assertRaises(errors.BadOptionValue, |
|
658 |
self.parse, ['--action', 'take-me-to-the-moon']) |
|
659 |
||
660 |
def test_done(self): |
|
661 |
opts, args = self.parse(['--action', 'done']) |
|
662 |
self.assertEqual({'action':'done'}, opts) |
|
663 |
||
664 |
def test_keep_mine(self): |
|
665 |
opts, args = self.parse(['--action', 'keep-mine']) |
|
666 |
self.assertEqual({'action': 'keep_mine'}, opts) |
|
667 |
opts, args = self.parse(['--keep-mine']) |
|
668 |
self.assertEqual({'action': 'keep_mine'}, opts) |
|
669 |
||
4597.3.63
by Vincent Ladeuil
That's take-theirs not take-their. |
670 |
def test_take_theirs(self): |
671 |
opts, args = self.parse(['--action', 'take-theirs']) |
|
672 |
self.assertEqual({'action': 'take_theirs'}, opts) |
|
673 |
opts, args = self.parse(['--take-theirs']) |
|
674 |
self.assertEqual({'action': 'take_theirs'}, opts) |