173
171
if 'conflict_file_id' in stanza:
174
172
self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
177
# FIXME: Tests missing for DuplicateID conflict type
178
class TestResolveConflicts(script.TestCaseWithTransportAndScript):
180
preamble = None # The setup script set by daughter classes
183
super(TestResolveConflicts, self).setUp()
184
self.run_script(self.preamble)
187
class TestResolveTextConflicts(TestResolveConflicts):
192
class TestResolveContentConflicts(TestResolveConflicts):
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.
200
$ echo 'trunk content' >file
202
$ bzr commit -m 'Create trunk'
204
$ bzr branch . ../branch
207
$ bzr commit -m 'Delete file'
210
$ echo 'more content' >>file
211
$ bzr commit -m 'Modify file'
216
2>Contents conflict in file
217
2>1 conflicts encountered.
220
def test_take_this(self):
222
$ bzr rm file.OTHER --force # a simple rm file.OTHER is valid too
224
$ bzr commit --strict -m 'No more conflicts nor unknown files'
227
def test_take_other(self):
229
$ bzr mv file.OTHER file
231
$ bzr commit --strict -m 'No more conflicts nor unknown files'
234
def test_resolve_taking_this(self):
236
$ bzr resolve --take-this file
237
$ bzr commit --strict -m 'No more conflicts nor unknown files'
240
def test_resolve_taking_other(self):
242
$ bzr resolve --take-other file
243
$ bzr commit --strict -m 'No more conflicts nor unknown files'
247
class TestResolveDuplicateEntry(TestResolveConflicts):
252
$ echo 'trunk content' >file
254
$ bzr commit -m 'Create trunk'
255
$ echo 'trunk content too' >file2
257
$ bzr commit -m 'Add file2 in trunk'
259
$ bzr branch . -r 1 ../branch
261
$ echo 'branch content' >file2
263
$ bzr commit -m 'Add file2 in branch'
267
2>R file2 => file2.moved
268
2>Conflict adding file file2. Moved existing file to file2.moved.
269
2>1 conflicts encountered.
272
def test_keep_this(self):
274
$ bzr rm file2 --force
275
$ bzr mv file2.moved file2
277
$ bzr commit --strict -m 'No more conflicts nor unknown files'
280
def test_keep_other(self):
281
self.failIfExists('branch/file2.moved')
283
$ bzr rm file2.moved --force
285
$ bzr commit --strict -m 'No more conflicts nor unknown files'
287
self.failIfExists('branch/file2.moved')
289
def test_resolve_taking_this(self):
291
$ bzr resolve --take-this file2
292
$ bzr commit --strict -m 'No more conflicts nor unknown files'
295
def test_resolve_taking_other(self):
297
$ bzr resolve --take-other file2
298
$ bzr commit --strict -m 'No more conflicts nor unknown files'
302
class TestResolveUnversionedParent(TestResolveConflicts):
304
# FIXME: Add the reverse tests: dir deleted in trunk, file added in branch
306
# FIXME: While this *creates* UnversionedParent conflicts, this really only
307
# tests MissingParent resolution :-/
313
$ bzr commit -m 'Create trunk'
314
$ echo 'trunk content' >dir/file
316
$ bzr commit -m 'Add dir/file in trunk'
318
$ bzr branch . -r 1 ../branch
321
$ bzr commit -m 'Remove dir in branch'
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.
331
def test_take_this(self):
335
$ bzr commit --strict -m 'No more conflicts nor unknown files'
338
def test_take_other(self):
341
$ bzr commit --strict -m 'No more conflicts nor unknown files'
345
class TestResolveMissingParent(TestResolveConflicts):
351
$ echo 'trunk content' >dir/file
353
$ bzr commit -m 'Create trunk'
354
$ echo 'trunk content' >dir/file2
356
$ bzr commit -m 'Add dir/file2 in branch'
358
$ bzr branch . -r 1 ../branch
360
$ bzr rm dir/file --force
362
$ bzr commit -m 'Remove dir/file'
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.
372
def test_keep_them_all(self):
375
$ bzr commit --strict -m 'No more conflicts nor unknown files'
378
def test_adopt_child(self):
380
$ bzr mv dir/file2 file2
383
$ bzr commit --strict -m 'No more conflicts nor unknown files'
386
def test_kill_them_all(self):
390
$ bzr commit --strict -m 'No more conflicts nor unknown files'
393
def test_resolve_taking_this(self):
395
$ bzr resolve --take-this dir
396
$ bzr commit --strict -m 'No more conflicts nor unknown files'
399
def test_resolve_taking_other(self):
401
$ bzr resolve --take-other dir
402
$ bzr commit --strict -m 'No more conflicts nor unknown files'
406
class TestResolveDeletingParent(TestResolveConflicts):
412
$ echo 'trunk content' >dir/file
414
$ bzr commit -m 'Create trunk'
415
$ bzr rm dir/file --force
417
$ bzr commit -m 'Remove dir/file'
419
$ bzr branch . -r 1 ../branch
421
$ echo 'branch content' >dir/file2
423
$ bzr commit -m 'Add dir/file2 in branch'
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.
432
def test_keep_them_all(self):
435
$ bzr commit --strict -m 'No more conflicts nor unknown files'
438
def test_adopt_child(self):
440
$ bzr mv dir/file2 file2
443
$ bzr commit --strict -m 'No more conflicts nor unknown files'
446
def test_kill_them_all(self):
450
$ bzr commit --strict -m 'No more conflicts nor unknown files'
453
def test_resolve_taking_this(self):
455
$ bzr resolve --take-this dir
456
$ bzr commit --strict -m 'No more conflicts nor unknown files'
459
def test_resolve_taking_other(self):
461
$ bzr resolve --take-other dir
462
$ bzr commit --strict -m 'No more conflicts nor unknown files'
466
class TestResolvePathConflict(TestResolveConflicts):
473
$ bzr commit -m 'Create trunk'
474
$ bzr mv file file-in-trunk
475
$ bzr commit -m 'Renamed to file-in-trunk'
477
$ bzr branch . -r 1 ../branch
479
$ bzr mv file file-in-branch
480
$ bzr commit -m 'Renamed to file-in-branch'
483
2>R file-in-branch => file-in-trunk
484
2>Path conflict: file-in-branch / file-in-trunk
485
2>1 conflicts encountered.
488
def test_keep_source(self):
490
$ bzr resolve file-in-trunk
491
$ bzr commit --strict -m 'No more conflicts nor unknown files'
494
def test_keep_target(self):
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'
501
def test_resolve_taking_this(self):
503
$ bzr resolve --take-this file-in-branch
504
$ bzr commit --strict -m 'No more conflicts nor unknown files'
507
def test_resolve_taking_other(self):
509
$ bzr resolve --take-other file-in-branch
510
$ bzr commit --strict -m 'No more conflicts nor unknown files'
514
class TestResolveParentLoop(TestResolveConflicts):
521
$ bzr commit -m 'Create trunk'
523
$ bzr commit -m 'Moved dir2 into dir1'
525
$ bzr branch . -r 1 ../branch
528
$ bzr commit -m 'Moved dir1 into dir2'
531
2>Conflict moving dir2/dir1 into dir2. Cancelled move.
532
2>1 conflicts encountered.
535
def test_take_this(self):
538
$ bzr commit --strict -m 'No more conflicts nor unknown files'
541
def test_take_other(self):
543
$ bzr mv dir2/dir1 dir1
546
$ bzr commit --strict -m 'No more conflicts nor unknown files'
549
def test_resolve_taking_this(self):
551
$ bzr resolve --take-this dir2
552
$ bzr commit --strict -m 'No more conflicts nor unknown files'
554
self.failUnlessExists('dir2')
556
def test_resolve_taking_other(self):
558
$ bzr resolve --take-other dir2
559
$ bzr commit --strict -m 'No more conflicts nor unknown files'
561
self.failUnlessExists('dir1')
564
class TestResolveNonDirectoryParent(TestResolveConflicts):
570
$ bzr commit -m 'Create trunk'
571
$ echo "Boing" >foo/bar
573
$ bzr commit -m 'Add foo/bar'
575
$ bzr branch . -r 1 ../branch
579
$ bzr commit -m 'foo is now a file'
584
# FIXME: The message is misleading, foo.new *is* a directory when the message
585
# is displayed -- vila 090916
586
2>Conflict: foo.new is not a directory, but has files in it. Created directory.
587
2>1 conflicts encountered.
590
def test_take_this(self):
592
$ bzr rm foo.new --force
593
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
594
# aside ? -- vila 090916
596
$ bzr resolve foo.new
597
$ bzr commit --strict -m 'No more conflicts nor unknown files'
600
def test_take_other(self):
605
$ bzr commit --strict -m 'No more conflicts nor unknown files'
608
def test_resolve_taking_this(self):
610
$ bzr resolve --take-this foo.new
611
$ bzr commit --strict -m 'No more conflicts nor unknown files'
614
def test_resolve_taking_other(self):
616
$ bzr resolve --take-other foo.new
617
$ bzr commit --strict -m 'No more conflicts nor unknown files'
621
class TestMalformedTransform(script.TestCaseWithTransportAndScript):
623
def test_bug_430129(self):
624
# This is nearly like TestResolveNonDirectoryParent but with branch and
625
# trunk switched. As such it should certainly produce the same
631
$ bzr commit -m 'Create trunk'
634
$ bzr commit -m 'foo is now a file'
636
$ bzr branch . -r 1 ../branch
638
$ echo "Boing" >foo/bar
640
$ bzr commit -m 'Add foo/bar'
643
2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]
647
class TestResolveActionOption(tests.TestCase):
650
super(TestResolveActionOption, self).setUp()
651
self.options = [conflicts.ResolveActionOption()]
652
self.parser = option.get_optparser(dict((o.name, o)
653
for o in self.options))
655
def parse(self, args):
656
return self.parser.parse_args(args)
658
def test_unknown_action(self):
659
self.assertRaises(errors.BadOptionValue,
660
self.parse, ['--action', 'take-me-to-the-moon'])
663
opts, args = self.parse(['--action', 'done'])
664
self.assertEqual({'action':'done'}, opts)
666
def test_take_this(self):
667
opts, args = self.parse(['--action', 'take-this'])
668
self.assertEqual({'action': 'take_this'}, opts)
669
opts, args = self.parse(['--take-this'])
670
self.assertEqual({'action': 'take_this'}, opts)
672
def test_take_other(self):
673
opts, args = self.parse(['--action', 'take-other'])
674
self.assertEqual({'action': 'take_other'}, opts)
675
opts, args = self.parse(['--take-other'])
676
self.assertEqual({'action': 'take_other'}, opts)