/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
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,
24
    tests,
4597.3.26 by Vincent Ladeuil
Tests passing for a minimal --interactive implementation.
25
    workingtree,
4597.2.2 by Vincent Ladeuil
Cleanup conflict 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 TestConflictStanzas(tests.TestCase):
59
60
    def test_stanza_roundtrip(self):
61
        # write and read our example stanza.
62
        stanza_iter = example_conflicts.to_stanzas()
63
        processed = conflicts.ConflictList.from_stanzas(stanza_iter)
64
        for o, p in zip(processed, example_conflicts):
65
            self.assertEqual(o, p)
66
67
            self.assertIsInstance(o.path, unicode)
68
69
            if o.file_id is not None:
70
                self.assertIsInstance(o.file_id, str)
71
72
            conflict_path = getattr(o, 'conflict_path', None)
73
            if conflict_path is not None:
74
                self.assertIsInstance(conflict_path, unicode)
75
76
            conflict_file_id = getattr(o, 'conflict_file_id', None)
77
            if conflict_file_id is not None:
78
                self.assertIsInstance(conflict_file_id, str)
79
80
    def test_stanzification(self):
81
        for stanza in example_conflicts.to_stanzas():
82
            if 'file_id' in stanza:
83
                # In Stanza form, the file_id has to be unicode.
84
                self.assertStartsWith(stanza['file_id'], u'\xeed')
85
            self.assertStartsWith(stanza['path'], u'p\xe5th')
86
            if 'conflict_path' in stanza:
87
                self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')
88
            if 'conflict_file_id' in stanza:
89
                self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
90
91
92
class TestConflicts(tests.TestCaseWithTransport):
1185.14.8 by Aaron Bentley
Added test_commit.py
93
94
    def test_conflicts(self):
95
        """Conflicts are detected properly"""
4597.2.3 by Vincent Ladeuil
More cleanup.
96
        # Use BzrDirFormat6 so we can fake conflicts
97
        tree = self.make_branch_and_tree('.', format=bzrdir.BzrDirFormat6())
98
        self.build_tree_contents([('hello', 'hello world4'),
99
                                  ('hello.THIS', 'hello world2'),
100
                                  ('hello.BASE', 'hello world1'),
101
                                  ('hello.OTHER', 'hello world3'),
102
                                  ('hello.sploo.BASE', 'yellowworld'),
103
                                  ('hello.sploo.OTHER', 'yellowworld2'),
104
                                  ])
2255.2.61 by John Arbash Meinel
Find callers of list_files() and make sure the tree is always locked.
105
        tree.lock_read()
4597.2.2 by Vincent Ladeuil
Cleanup conflict tests.
106
        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.
107
        tree.unlock()
4597.2.3 by Vincent Ladeuil
More cleanup.
108
        tree_conflicts = tree.conflicts()
109
        self.assertEqual(2, len(tree_conflicts))
110
        self.assertTrue('hello' in tree_conflicts[0].path)
111
        self.assertTrue('hello.sploo' in tree_conflicts[1].path)
112
        conflicts.restore('hello')
113
        conflicts.restore('hello.sploo')
4597.2.2 by Vincent Ladeuil
Cleanup conflict tests.
114
        self.assertEqual(0, len(tree.conflicts()))
1185.35.1 by Aaron Bentley
Implemented conflicts.restore
115
        self.assertFileEqual('hello world2', 'hello')
3376.2.4 by Martin Pool
Remove every assert statement from bzrlib!
116
        self.assertFalse(os.path.lexists('hello.sploo'))
4597.2.3 by Vincent Ladeuil
More cleanup.
117
        self.assertRaises(errors.NotConflicted, conflicts.restore, 'hello')
118
        self.assertRaises(errors.NotConflicted,
119
                          conflicts.restore, 'hello.sploo')
1534.10.4 by Aaron Bentley
Implemented conflict serialization
120
1558.12.9 by Aaron Bentley
Handle resolving conflicts with directories properly
121
    def test_resolve_conflict_dir(self):
122
        tree = self.make_branch_and_tree('.')
4597.2.3 by Vincent Ladeuil
More cleanup.
123
        self.build_tree_contents([('hello', 'hello world4'),
124
                                  ('hello.THIS', 'hello world2'),
125
                                  ('hello.BASE', 'hello world1'),
126
                                  ])
127
        os.mkdir('hello.OTHER')
1558.12.9 by Aaron Bentley
Handle resolving conflicts with directories properly
128
        tree.add('hello', 'q')
4597.2.3 by Vincent Ladeuil
More cleanup.
129
        l = conflicts.ConflictList([conflicts.TextConflict('hello')])
1558.12.9 by Aaron Bentley
Handle resolving conflicts with directories properly
130
        l.remove_files(tree)
131
1551.15.58 by Aaron Bentley
Status honours selected paths for conflicts (#127606)
132
    def test_select_conflicts(self):
133
        tree = self.make_branch_and_tree('.')
4597.2.3 by Vincent Ladeuil
More cleanup.
134
        clist = conflicts.ConflictList
135
136
        def check_select(not_selected, selected, paths, **kwargs):
137
            self.assertEqual(
138
                (not_selected, selected),
139
                tree_conflicts.select_conflicts(tree, paths, **kwargs))
140
141
        foo = conflicts.ContentsConflict('foo')
142
        bar = conflicts.ContentsConflict('bar')
143
        tree_conflicts = clist([foo, bar])
144
145
        check_select(clist([bar]), clist([foo]), ['foo'])
146
        check_select(clist(), tree_conflicts,
147
                     [''], ignore_misses=True, recurse=True)
148
149
        foobaz  = conflicts.ContentsConflict('foo/baz')
150
        tree_conflicts = clist([foobaz, bar])
151
152
        check_select(clist([bar]), clist([foobaz]),
153
                     ['foo'], ignore_misses=True, recurse=True)
154
155
        qux = conflicts.PathConflict('qux', 'foo/baz')
156
        tree_conflicts = clist([qux])
157
158
        check_select(clist(), tree_conflicts,
159
                     ['foo'], ignore_misses=True, recurse=True)
160
        check_select (tree_conflicts, clist(), ['foo'], ignore_misses=True)
1551.15.58 by Aaron Bentley
Status honours selected paths for conflicts (#127606)
161
3017.2.1 by Aaron Bentley
Revert now resolves conflicts recursively (#102739)
162
    def test_resolve_conflicts_recursive(self):
163
        tree = self.make_branch_and_tree('.')
164
        self.build_tree(['dir/', 'dir/hello'])
165
        tree.add(['dir', 'dir/hello'])
4597.2.3 by Vincent Ladeuil
More cleanup.
166
167
        dirhello = conflicts.ConflictList([conflicts.TextConflict('dir/hello')])
168
        tree.set_conflicts(dirhello)
169
170
        conflicts.resolve(tree, ['dir'], recursive=False, ignore_misses=True)
171
        self.assertEqual(dirhello, tree.conflicts())
172
173
        conflicts.resolve(tree, ['dir'], recursive=True, ignore_misses=True)
174
        self.assertEqual(conflicts.ConflictList([]), tree.conflicts())
4773.1.1 by Vincent Ladeuil
Cleanup imports in test_conflicts
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.28 by Vincent Ladeuil
Implement --interactive for ContentsConflict.
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("""
236
$ bzr resolve --interactive file
237
<keep_mine
238
$ bzr commit --strict -m 'No more conflicts nor unknown files'
239
""")
240
241
    def test_resolve_taking_theirs(self):
242
        self.run_script("""
243
$ bzr resolve --interactive file
244
<take_theirs
245
$ bzr commit --strict -m 'No more conflicts nor unknown files'
246
""")
247
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
248
4597.3.31 by Vincent Ladeuil
Implement --interactive for MissingParent.
249
class TestResolveDuplicateEntry(TestResolveConflicts):
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
250
251
    preamble = """
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
252
$ bzr init trunk
253
$ cd trunk
254
$ echo 'trunk content' >file
255
$ bzr add file
256
$ bzr commit -m 'Create trunk'
257
$ echo 'trunk content too' >file2
258
$ bzr add file2
259
$ bzr commit -m 'Add file2 in trunk'
260
261
$ bzr branch . -r 1 ../branch
262
$ cd ../branch
263
$ echo 'branch content' >file2
264
$ bzr add file2
265
$ bzr commit -m 'Add file2 in branch'
266
267
$ bzr merge ../trunk
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
268
2>+N  file2
269
2>R   file2 => file2.moved
270
2>Conflict adding file file2.  Moved existing file to file2.moved.
271
2>1 conflicts encountered.
272
"""
273
274
    def test_keep_this(self):
275
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
276
$ bzr rm file2  --force
277
$ bzr mv file2.moved file2
278
$ bzr resolve file2
279
$ 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.
280
""")
281
282
    def test_keep_other(self):
283
        self.failIfExists('branch/file2.moved')
284
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
285
$ bzr rm file2.moved --force
286
$ bzr resolve file2
287
$ 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.
288
""")
289
        self.failIfExists('branch/file2.moved')
290
4597.3.27 by Vincent Ladeuil
(keep_mine, take_theirs) sounds clearer than (keep_this, keep_other).
291
    def test_resolve_keeping_mine(self):
4597.3.19 by Vincent Ladeuil
Some failing tests.
292
        self.run_script("""
4597.3.26 by Vincent Ladeuil
Tests passing for a minimal --interactive implementation.
293
$ bzr resolve --interactive file2
4597.3.27 by Vincent Ladeuil
(keep_mine, take_theirs) sounds clearer than (keep_this, keep_other).
294
<keep_mine
4597.3.19 by Vincent Ladeuil
Some failing tests.
295
$ bzr commit --strict -m 'No more conflicts nor unknown files'
296
""")
297
4597.3.27 by Vincent Ladeuil
(keep_mine, take_theirs) sounds clearer than (keep_this, keep_other).
298
    def test_resolve_taking_theirs(self):
4597.3.19 by Vincent Ladeuil
Some failing tests.
299
        self.run_script("""
4597.3.26 by Vincent Ladeuil
Tests passing for a minimal --interactive implementation.
300
$ bzr resolve --interactive file2
4597.3.27 by Vincent Ladeuil
(keep_mine, take_theirs) sounds clearer than (keep_this, keep_other).
301
<take_theirs
4597.3.19 by Vincent Ladeuil
Some failing tests.
302
$ bzr commit --strict -m 'No more conflicts nor unknown files'
303
""")
304
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
305
306
class TestResolveUnversionedParent(TestResolveConflicts):
307
4597.3.29 by Vincent Ladeuil
Fix bogus tests.
308
    # FIXME: Add the reverse tests: dir deleted in trunk, file added in branch
309
4597.3.30 by Vincent Ladeuil
Light changes learned while starting to understand multiple conflicts on
310
    # FIXME: While this *creates* UnversionedParent conflicts, this really only
311
    # tests MissingParent resolution :-/
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
312
    preamble = """
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
313
$ bzr init trunk
314
$ cd trunk
4597.3.29 by Vincent Ladeuil
Fix bogus tests.
315
$ mkdir dir
316
$ bzr add dir
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
317
$ bzr commit -m 'Create trunk'
4597.3.29 by Vincent Ladeuil
Fix bogus tests.
318
$ echo 'trunk content' >dir/file
319
$ bzr add dir/file
320
$ bzr commit -m 'Add dir/file in trunk'
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
321
322
$ bzr branch . -r 1 ../branch
323
$ cd ../branch
4597.3.29 by Vincent Ladeuil
Fix bogus tests.
324
$ bzr rm dir
325
$ bzr commit -m 'Remove dir in branch'
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
326
327
$ bzr merge ../trunk
4597.3.29 by Vincent Ladeuil
Fix bogus tests.
328
2>+N  dir/
329
2>+N  dir/file
330
2>Conflict adding files to dir.  Created directory.
331
2>Conflict because dir is not versioned, but has versioned children.  Versioned directory.
332
2>2 conflicts encountered.
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
333
"""
334
4597.3.29 by Vincent Ladeuil
Fix bogus tests.
335
    def test_keep_mine(self):
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
336
        self.run_script("""
4597.3.29 by Vincent Ladeuil
Fix bogus tests.
337
$ bzr rm dir  --force
338
$ bzr resolve dir
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
339
$ 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.
340
""")
341
4597.3.29 by Vincent Ladeuil
Fix bogus tests.
342
    def test_take_theirs(self):
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
343
        self.run_script("""
4597.3.29 by Vincent Ladeuil
Fix bogus tests.
344
$ bzr resolve dir
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
345
$ 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.
346
""")
347
348
349
class TestResolveMissingParent(TestResolveConflicts):
350
351
    preamble = """
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
352
$ bzr init trunk
353
$ cd trunk
354
$ mkdir dir
355
$ echo 'trunk content' >dir/file
356
$ bzr add
357
$ bzr commit -m 'Create trunk'
358
$ echo 'trunk content' >dir/file2
359
$ bzr add dir/file2
360
$ bzr commit -m 'Add dir/file2 in branch'
361
362
$ bzr branch . -r 1 ../branch
363
$ cd ../branch
364
$ bzr rm dir/file --force
365
$ bzr rm dir
366
$ bzr commit -m 'Remove dir/file'
367
368
$ bzr merge ../trunk
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
369
2>+N  dir/
370
2>+N  dir/file2
371
2>Conflict adding files to dir.  Created directory.
372
2>Conflict because dir is not versioned, but has versioned children.  Versioned directory.
373
2>2 conflicts encountered.
374
"""
375
376
    def test_keep_them_all(self):
377
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
378
$ bzr resolve dir
379
$ 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.
380
""")
381
382
    def test_adopt_child(self):
383
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
384
$ bzr mv dir/file2 file2
385
$ bzr rm dir --force
386
$ bzr resolve dir
387
$ 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.
388
""")
389
390
    def test_kill_them_all(self):
391
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
392
$ bzr rm dir --force
393
$ bzr resolve dir
394
$ 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.
395
""")
396
4597.3.31 by Vincent Ladeuil
Implement --interactive for MissingParent.
397
    def test_resolve_keeping_mine(self):
398
        self.run_script("""
399
$ bzr resolve --interactive dir
400
<keep_mine
401
$ bzr commit --strict -m 'No more conflicts nor unknown files'
402
""")
403
404
    def test_resolve_taking_theirs(self):
405
        self.run_script("""
406
$ bzr resolve --interactive dir
407
<take_theirs
408
$ bzr commit --strict -m 'No more conflicts nor unknown files'
409
""")
410
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
411
412
class TestResolveDeletingParent(TestResolveConflicts):
413
414
    preamble = """
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
415
$ bzr init trunk
416
$ cd trunk
417
$ mkdir dir
418
$ echo 'trunk content' >dir/file
419
$ bzr add
420
$ bzr commit -m 'Create trunk'
421
$ bzr rm dir/file --force
422
$ bzr rm dir --force
423
$ bzr commit -m 'Remove dir/file'
424
425
$ bzr branch . -r 1 ../branch
426
$ cd ../branch
427
$ echo 'branch content' >dir/file2
428
$ bzr add dir/file2
429
$ bzr commit -m 'Add dir/file2 in branch'
430
431
$ bzr merge ../trunk
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
432
2>-D  dir/file
433
2>Conflict: can't delete dir because it is not empty.  Not deleting.
434
2>Conflict because dir is not versioned, but has versioned children.  Versioned directory.
435
2>2 conflicts encountered.
436
"""
437
438
    def test_keep_them_all(self):
439
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
440
$ bzr resolve dir
441
$ 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.
442
""")
443
444
    def test_adopt_child(self):
445
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
446
$ bzr mv dir/file2 file2
447
$ bzr rm dir --force
448
$ bzr resolve dir
449
$ 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.
450
""")
451
452
    def test_kill_them_all(self):
453
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
454
$ bzr rm dir --force
455
$ bzr resolve dir
456
$ 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.
457
""")
458
4597.3.32 by Vincent Ladeuil
Implement --interactive for DeletingParent noting the inconsistency.
459
    def test_resolve_keeping_mine(self):
460
        self.run_script("""
461
$ bzr resolve --interactive dir
462
<keep_mine
463
$ bzr commit --strict -m 'No more conflicts nor unknown files'
464
""")
465
466
    def test_resolve_taking_theirs(self):
467
        self.run_script("""
468
$ bzr resolve --interactive dir
469
<take_theirs
470
$ bzr commit --strict -m 'No more conflicts nor unknown files'
471
""")
472
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
473
474
class TestResolvePathConflict(TestResolveConflicts):
475
476
    preamble = """
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
477
$ bzr init trunk
478
$ cd trunk
479
$ mkdir dir
480
$ echo 'Boo!' >file
481
$ bzr add
482
$ bzr commit -m 'Create trunk'
483
$ bzr mv file file-in-trunk
484
$ bzr commit -m 'Renamed to file-in-trunk'
485
486
$ bzr branch . -r 1 ../branch
487
$ cd ../branch
488
$ bzr mv file file-in-branch
489
$ bzr commit -m 'Renamed to file-in-branch'
490
491
$ bzr merge ../trunk
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
492
2>R   file-in-branch => file-in-trunk
493
2>Path conflict: file-in-branch / file-in-trunk
494
2>1 conflicts encountered.
495
"""
496
497
    def test_keep_source(self):
498
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
499
$ bzr resolve file-in-trunk
500
$ 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.
501
""")
502
503
    def test_keep_target(self):
504
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
505
$ bzr mv file-in-trunk file-in-branch
506
$ bzr resolve file-in-branch
507
$ 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.
508
""")
509
4597.3.33 by Vincent Ladeuil
Implement --interactive for PathConflict.
510
    def test_resolve_keeping_mine(self):
511
        self.run_script("""
512
$ bzr resolve --interactive file-in-branch
513
<keep_mine
514
$ bzr commit --strict -m 'No more conflicts nor unknown files'
515
""")
516
517
    def test_resolve_taking_theirs(self):
518
        self.run_script("""
519
$ bzr resolve --interactive file-in-branch
520
<take_theirs
521
$ bzr commit --strict -m 'No more conflicts nor unknown files'
522
""")
523
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
524
525
class TestResolveParentLoop(TestResolveConflicts):
526
527
    preamble = """
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
528
$ bzr init trunk
529
$ cd trunk
530
$ bzr mkdir dir1
531
$ bzr mkdir dir2
532
$ bzr commit -m 'Create trunk'
533
$ bzr mv dir2 dir1
534
$ bzr commit -m 'Moved dir2 into dir1'
535
536
$ bzr branch . -r 1 ../branch
537
$ cd ../branch
538
$ bzr mv dir1 dir2
539
$ bzr commit -m 'Moved dir1 into dir2'
540
541
$ bzr merge ../trunk
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
542
2>Conflict moving dir2/dir1 into dir2.  Cancelled move.
543
2>1 conflicts encountered.
544
"""
545
4597.3.34 by Vincent Ladeuil
Implement --interactive for ParentLoop.
546
    def test_keep_mine(self):
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
547
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
548
$ bzr resolve dir2
549
$ 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.
550
""")
551
4597.3.34 by Vincent Ladeuil
Implement --interactive for ParentLoop.
552
    def test_take_theirs(self):
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
553
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
554
$ bzr mv dir2/dir1 dir1
555
$ bzr mv dir2 dir1
556
$ bzr resolve dir2
557
$ 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.
558
""")
559
4597.3.34 by Vincent Ladeuil
Implement --interactive for ParentLoop.
560
    def test_resolve_keeping_mine(self):
561
        self.run_script("""
562
$ bzr resolve --interactive dir2
563
<keep_mine
564
$ bzr commit --strict -m 'No more conflicts nor unknown files'
565
""")
566
567
    def test_resolve_taking_theirs(self):
568
        self.run_script("""
569
$ bzr resolve --interactive dir2
570
<take_theirs
571
$ bzr commit --strict -m 'No more conflicts nor unknown files'
572
""")
573
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
574
575
class TestResolveNonDirectoryParent(TestResolveConflicts):
576
577
    preamble = """
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
578
$ bzr init trunk
579
$ cd trunk
580
$ bzr mkdir foo
581
$ bzr commit -m 'Create trunk'
582
$ echo "Boing" >foo/bar
583
$ bzr add foo/bar
584
$ bzr commit -m 'Add foo/bar'
585
586
$ bzr branch . -r 1 ../branch
587
$ cd ../branch
588
$ rm -r foo
589
$ echo "Boo!" >foo
590
$ bzr commit -m 'foo is now a file'
591
592
$ bzr merge ../trunk
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
593
2>+N  foo.new/bar
594
2>RK  foo => foo.new/
595
# FIXME: The message is misleading, foo.new *is* a directory when the message
596
# is displayed -- vila 090916
597
2>Conflict: foo.new is not a directory, but has files in it.  Created directory.
598
2>1 conflicts encountered.
599
"""
600
4597.3.35 by Vincent Ladeuil
Implement --interactive for NonDirectoryParent, sort of.
601
    def test_keep_mine(self):
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
602
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
603
$ bzr rm foo.new --force
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
604
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
605
# aside ? -- vila 090916
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
606
$ bzr add foo
607
$ bzr resolve foo.new
608
$ 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.
609
""")
610
4597.3.35 by Vincent Ladeuil
Implement --interactive for NonDirectoryParent, sort of.
611
    def test_take_theirs(self):
612
        self.run_script("""
613
$ bzr rm foo --force
614
$ bzr mv foo.new foo
615
$ bzr resolve foo
616
$ bzr commit --strict -m 'No more conflicts nor unknown files'
617
""")
618
619
    def test_resolve_keeping_mine(self):
620
        self.run_script("""
621
$ bzr resolve --interactive foo.new
622
<keep_mine
623
$ bzr commit --strict -m 'No more conflicts nor unknown files'
624
""")
625
626
    def test_resolve_taking_theirs(self):
627
        self.run_script("""
628
$ bzr resolve --interactive foo.new
629
<take_theirs
630
$ bzr commit --strict -m 'No more conflicts nor unknown files'
631
""")
632
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
633
634
class TestMalformedTransform(script.TestCaseWithTransportAndScript):
635
636
    def test_bug_430129(self):
637
        # This is nearly like TestResolveNonDirectoryParent but with branch and
638
        # trunk switched. As such it should certainly produce the same
639
        # conflict.
640
        self.run_script("""
4597.3.15 by Vincent Ladeuil
Update to new shell-like tests syntax.
641
$ bzr init trunk
642
$ cd trunk
643
$ bzr mkdir foo
644
$ bzr commit -m 'Create trunk'
645
$ rm -r foo
646
$ echo "Boo!" >foo
647
$ bzr commit -m 'foo is now a file'
648
649
$ bzr branch . -r 1 ../branch
650
$ cd ../branch
651
$ echo "Boing" >foo/bar
652
$ bzr add foo/bar
653
$ bzr commit -m 'Add foo/bar'
654
655
$ bzr merge ../trunk
4597.3.12 by Vincent Ladeuil
Start writing tests for all expected conflict resolution actions.
656
2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]
657
""")