~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_conflicts.py

  • Committer: INADA Naoki
  • Date: 2011-05-05 09:15:34 UTC
  • mto: (5830.3.3 i18n-msgfmt)
  • mto: This revision was merged to the branch mainline in revision 5873.
  • Revision ID: songofacandy@gmail.com-20110505091534-7sv835xpofwrmpt4
Add update-pot command to Makefile and tools/bzrgettext script that
extracts help text from bzr commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
22
22
    conflicts,
23
23
    errors,
24
24
    option,
 
25
    osutils,
25
26
    tests,
26
27
    )
27
 
from bzrlib.tests import script
 
28
from bzrlib.tests import (
 
29
    script,
 
30
    scenarios,
 
31
    )
 
32
 
 
33
 
 
34
load_tests = scenarios.load_tests_apply_scenarios
28
35
 
29
36
 
30
37
# TODO: Test commit with some added, and added-but-missing files
57
64
 
58
65
class TestConflicts(tests.TestCaseWithTransport):
59
66
 
60
 
    def test_conflicts(self):
61
 
        """Conflicts are detected properly"""
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
 
                                  ])
71
 
        tree.lock_read()
72
 
        self.assertEqual(6, len(list(tree.list_files())))
73
 
        tree.unlock()
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')
80
 
        self.assertEqual(0, len(tree.conflicts()))
81
 
        self.assertFileEqual('hello world2', 'hello')
82
 
        self.assertFalse(os.path.lexists('hello.sploo'))
83
 
        self.assertRaises(errors.NotConflicted, conflicts.restore, 'hello')
84
 
        self.assertRaises(errors.NotConflicted,
85
 
                          conflicts.restore, 'hello.sploo')
86
 
 
87
67
    def test_resolve_conflict_dir(self):
88
68
        tree = self.make_branch_and_tree('.')
89
69
        self.build_tree_contents([('hello', 'hello world4'),
177
157
# FIXME: The shell-like tests should be converted to real whitebox tests... or
178
158
# moved to a blackbox module -- vila 20100205
179
159
 
 
160
# FIXME: test missing for multiple conflicts
 
161
 
180
162
# FIXME: Tests missing for DuplicateID conflict type
181
163
class TestResolveConflicts(script.TestCaseWithTransportAndScript):
182
164
 
187
169
        self.run_script(self.preamble)
188
170
 
189
171
 
190
 
class TestResolveTextConflicts(TestResolveConflicts):
191
 
    # TBC
192
 
    pass
193
 
 
194
 
 
195
 
class TestResolveContentConflicts(TestResolveConflicts):
196
 
 
197
 
    # FIXME: We need to add the reverse case (delete in trunk, modify in
198
 
    # branch) but that could wait until the resolution mechanism is implemented.
199
 
 
200
 
    preamble = """
201
 
$ bzr init trunk
202
 
$ cd trunk
203
 
$ echo 'trunk content' >file
204
 
$ bzr add file
205
 
$ bzr commit -m 'Create trunk'
206
 
 
207
 
$ bzr branch . ../branch
208
 
$ cd ../branch
209
 
$ bzr rm file
210
 
$ bzr commit -m 'Delete file'
211
 
 
212
 
$ cd ../trunk
213
 
$ echo 'more content' >>file
214
 
$ bzr commit -m 'Modify file'
215
 
 
216
 
$ cd ../branch
217
 
$ bzr merge ../trunk
218
 
2>+N  file.OTHER
219
 
2>Contents conflict in file
220
 
2>1 conflicts encountered.
221
 
"""
222
 
 
223
 
    def test_take_this(self):
224
 
        self.run_script("""
225
 
$ bzr rm file.OTHER --force # a simple rm file.OTHER is valid too
226
 
$ bzr resolve file
227
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
228
 
""")
229
 
 
230
 
    def test_take_other(self):
231
 
        self.run_script("""
232
 
$ bzr mv file.OTHER file
233
 
$ bzr resolve file
234
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
235
 
""")
236
 
 
237
 
    def test_resolve_taking_this(self):
238
 
        self.run_script("""
239
 
$ bzr resolve --take-this file
240
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
241
 
""")
242
 
 
243
 
    def test_resolve_taking_other(self):
244
 
        self.run_script("""
245
 
$ bzr resolve --take-other file
246
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
247
 
""")
248
 
 
249
 
 
250
 
class TestResolveDuplicateEntry(TestResolveConflicts):
251
 
 
252
 
    preamble = """
253
 
$ bzr init trunk
254
 
$ cd trunk
255
 
$ echo 'trunk content' >file
256
 
$ bzr add file
257
 
$ bzr commit -m 'Create trunk'
258
 
$ echo 'trunk content too' >file2
259
 
$ bzr add file2
260
 
$ bzr commit -m 'Add file2 in trunk'
261
 
 
262
 
$ bzr branch . -r 1 ../branch
263
 
$ cd ../branch
264
 
$ echo 'branch content' >file2
265
 
$ bzr add file2
266
 
$ bzr commit -m 'Add file2 in branch'
267
 
 
268
 
$ bzr merge ../trunk
269
 
2>+N  file2
270
 
2>R   file2 => file2.moved
271
 
2>Conflict adding file file2.  Moved existing file to file2.moved.
272
 
2>1 conflicts encountered.
273
 
"""
274
 
 
275
 
    def test_keep_this(self):
276
 
        self.run_script("""
277
 
$ bzr rm file2  --force
278
 
$ bzr mv file2.moved file2
279
 
$ bzr resolve file2
280
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
281
 
""")
282
 
 
283
 
    def test_keep_other(self):
284
 
        self.failIfExists('branch/file2.moved')
285
 
        self.run_script("""
286
 
$ bzr rm file2.moved --force
287
 
$ bzr resolve file2
288
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
289
 
""")
290
 
        self.failIfExists('branch/file2.moved')
291
 
 
292
 
    def test_resolve_taking_this(self):
293
 
        self.run_script("""
294
 
$ bzr resolve --take-this file2
295
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
296
 
""")
297
 
 
298
 
    def test_resolve_taking_other(self):
299
 
        self.run_script("""
300
 
$ bzr resolve --take-other file2
301
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
302
 
""")
 
172
def mirror_scenarios(base_scenarios):
 
173
    """Return a list of mirrored scenarios.
 
174
 
 
175
    Each scenario in base_scenarios is duplicated switching the roles of 'this'
 
176
    and 'other'
 
177
    """
 
178
    scenarios = []
 
179
    for common, (lname, ldict), (rname, rdict) in base_scenarios:
 
180
        a = tests.multiply_scenarios([(lname, dict(_this=ldict))],
 
181
                                     [(rname, dict(_other=rdict))])
 
182
        b = tests.multiply_scenarios([(rname, dict(_this=rdict))],
 
183
                                     [(lname, dict(_other=ldict))])
 
184
        # Inject the common parameters in all scenarios
 
185
        for name, d in a + b:
 
186
            d.update(common)
 
187
        scenarios.extend(a + b)
 
188
    return scenarios
 
189
 
 
190
 
 
191
# FIXME: Get rid of parametrized (in the class name) once we delete
 
192
# TestResolveConflicts -- vila 20100308
 
193
class TestParametrizedResolveConflicts(tests.TestCaseWithTransport):
 
194
    """This class provides a base to test single conflict resolution.
 
195
 
 
196
    Since all conflict objects are created with specific semantics for their
 
197
    attributes, each class should implement the necessary functions and
 
198
    attributes described below.
 
199
 
 
200
    Each class should define the scenarios that create the expected (single)
 
201
    conflict.
 
202
 
 
203
    Each scenario describes:
 
204
    * how to create 'base' tree (and revision)
 
205
    * how to create 'left' tree (and revision, parent rev 'base')
 
206
    * how to create 'right' tree (and revision, parent rev 'base')
 
207
    * how to check that changes in 'base'->'left' have been taken
 
208
    * how to check that changes in 'base'->'right' have been taken
 
209
 
 
210
    From each base scenario, we generate two concrete scenarios where:
 
211
    * this=left, other=right
 
212
    * this=right, other=left
 
213
 
 
214
    Then the test case verifies each concrete scenario by:
 
215
    * creating a branch containing the 'base', 'this' and 'other' revisions
 
216
    * creating a working tree for the 'this' revision
 
217
    * performing the merge of 'other' into 'this'
 
218
    * verifying the expected conflict was generated
 
219
    * resolving with --take-this or --take-other, and running the corresponding
 
220
      checks (for either 'base'->'this', or 'base'->'other')
 
221
 
 
222
    :cvar _conflict_type: The expected class of the generated conflict.
 
223
 
 
224
    :cvar _assert_conflict: A method receiving the working tree and the
 
225
        conflict object and checking its attributes.
 
226
 
 
227
    :cvar _base_actions: The branchbuilder actions to create the 'base'
 
228
        revision.
 
229
 
 
230
    :cvar _this: The dict related to 'base' -> 'this'. It contains at least:
 
231
      * 'actions': The branchbuilder actions to create the 'this'
 
232
          revision.
 
233
      * 'check': how to check the changes after resolution with --take-this.
 
234
 
 
235
    :cvar _other: The dict related to 'base' -> 'other'. It contains at least:
 
236
      * 'actions': The branchbuilder actions to create the 'other'
 
237
          revision.
 
238
      * 'check': how to check the changes after resolution with --take-other.
 
239
    """
 
240
 
 
241
    # Set by daughter classes
 
242
    _conflict_type = None
 
243
    _assert_conflict = None
 
244
 
 
245
    # Set by load_tests
 
246
    _base_actions = None
 
247
    _this = None
 
248
    _other = None
 
249
 
 
250
    scenarios = []
 
251
    """The scenario list for the conflict type defined by the class.
 
252
 
 
253
    Each scenario is of the form:
 
254
    (common, (left_name, left_dict), (right_name, right_dict))
 
255
 
 
256
    * common is a dict
 
257
 
 
258
    * left_name and right_name are the scenario names that will be combined
 
259
 
 
260
    * left_dict and right_dict are the attributes specific to each half of
 
261
      the scenario. They should include at least 'actions' and 'check' and
 
262
      will be available as '_this' and '_other' test instance attributes.
 
263
 
 
264
    Daughters classes are free to add their specific attributes as they see
 
265
    fit in any of the three dicts.
 
266
 
 
267
    This is a class method so that load_tests can find it.
 
268
 
 
269
    '_base_actions' in the common dict, 'actions' and 'check' in the left
 
270
    and right dicts use names that map to methods in the test classes. Some
 
271
    prefixes are added to these names to get the correspong methods (see
 
272
    _get_actions() and _get_check()). The motivation here is to avoid
 
273
    collisions in the class namespace.
 
274
    """
 
275
 
 
276
    def setUp(self):
 
277
        super(TestParametrizedResolveConflicts, self).setUp()
 
278
        builder = self.make_branch_builder('trunk')
 
279
        builder.start_series()
 
280
 
 
281
        # Create an empty trunk
 
282
        builder.build_snapshot('start', None, [
 
283
                ('add', ('', 'root-id', 'directory', ''))])
 
284
        # Add a minimal base content
 
285
        base_actions = self._get_actions(self._base_actions)()
 
286
        builder.build_snapshot('base', ['start'], base_actions)
 
287
        # Modify the base content in branch
 
288
        actions_other = self._get_actions(self._other['actions'])()
 
289
        builder.build_snapshot('other', ['base'], actions_other)
 
290
        # Modify the base content in trunk
 
291
        actions_this = self._get_actions(self._this['actions'])()
 
292
        builder.build_snapshot('this', ['base'], actions_this)
 
293
        # builder.get_branch() tip is now 'this'
 
294
 
 
295
        builder.finish_series()
 
296
        self.builder = builder
 
297
 
 
298
    def _get_actions(self, name):
 
299
        return getattr(self, 'do_%s' % name)
 
300
 
 
301
    def _get_check(self, name):
 
302
        return getattr(self, 'check_%s' % name)
 
303
 
 
304
    def _merge_other_into_this(self):
 
305
        b = self.builder.get_branch()
 
306
        wt = b.bzrdir.sprout('branch').open_workingtree()
 
307
        wt.merge_from_branch(b, 'other')
 
308
        return wt
 
309
 
 
310
    def assertConflict(self, wt):
 
311
        confs = wt.conflicts()
 
312
        self.assertLength(1, confs)
 
313
        c = confs[0]
 
314
        self.assertIsInstance(c, self._conflict_type)
 
315
        self._assert_conflict(wt, c)
 
316
 
 
317
    def _get_resolve_path_arg(self, wt, action):
 
318
        raise NotImplementedError(self._get_resolve_path_arg)
 
319
 
 
320
    def check_resolved(self, wt, action):
 
321
        path = self._get_resolve_path_arg(wt, action)
 
322
        conflicts.resolve(wt, [path], action=action)
 
323
        # Check that we don't have any conflicts nor unknown left
 
324
        self.assertLength(0, wt.conflicts())
 
325
        self.assertLength(0, list(wt.unknowns()))
 
326
 
 
327
    def test_resolve_taking_this(self):
 
328
        wt = self._merge_other_into_this()
 
329
        self.assertConflict(wt)
 
330
        self.check_resolved(wt, 'take_this')
 
331
        check_this = self._get_check(self._this['check'])
 
332
        check_this()
 
333
 
 
334
    def test_resolve_taking_other(self):
 
335
        wt = self._merge_other_into_this()
 
336
        self.assertConflict(wt)
 
337
        self.check_resolved(wt, 'take_other')
 
338
        check_other = self._get_check(self._other['check'])
 
339
        check_other()
 
340
 
 
341
 
 
342
class TestResolveTextConflicts(TestParametrizedResolveConflicts):
 
343
 
 
344
    _conflict_type = conflicts.TextConflict
 
345
 
 
346
    # Set by the scenarios
 
347
    # path and file-id for the file involved in the conflict
 
348
    _path = None
 
349
    _file_id = None
 
350
 
 
351
    scenarios = mirror_scenarios(
 
352
        [
 
353
            # File modified on both sides
 
354
            (dict(_base_actions='create_file',
 
355
                  _path='file', _file_id='file-id'),
 
356
             ('filed_modified_A',
 
357
              dict(actions='modify_file_A', check='file_has_content_A')),
 
358
             ('file_modified_B',
 
359
              dict(actions='modify_file_B', check='file_has_content_B')),),
 
360
            # File modified on both sides in dir
 
361
            (dict(_base_actions='create_file_in_dir',
 
362
                  _path='dir/file', _file_id='file-id'),
 
363
             ('filed_modified_A_in_dir',
 
364
              dict(actions='modify_file_A',
 
365
                   check='file_in_dir_has_content_A')),
 
366
             ('file_modified_B',
 
367
              dict(actions='modify_file_B',
 
368
                   check='file_in_dir_has_content_B')),),
 
369
            ])
 
370
 
 
371
    def do_create_file(self, path='file'):
 
372
        return [('add', (path, 'file-id', 'file', 'trunk content\n'))]
 
373
 
 
374
    def do_modify_file_A(self):
 
375
        return [('modify', ('file-id', 'trunk content\nfeature A\n'))]
 
376
 
 
377
    def do_modify_file_B(self):
 
378
        return [('modify', ('file-id', 'trunk content\nfeature B\n'))]
 
379
 
 
380
    def check_file_has_content_A(self, path='file'):
 
381
        self.assertFileEqual('trunk content\nfeature A\n',
 
382
                             osutils.pathjoin('branch', path))
 
383
 
 
384
    def check_file_has_content_B(self, path='file'):
 
385
        self.assertFileEqual('trunk content\nfeature B\n',
 
386
                             osutils.pathjoin('branch', path))
 
387
 
 
388
    def do_create_file_in_dir(self):
 
389
        return [('add', ('dir', 'dir-id', 'directory', '')),
 
390
            ] + self.do_create_file('dir/file')
 
391
 
 
392
    def check_file_in_dir_has_content_A(self):
 
393
        self.check_file_has_content_A('dir/file')
 
394
 
 
395
    def check_file_in_dir_has_content_B(self):
 
396
        self.check_file_has_content_B('dir/file')
 
397
 
 
398
    def _get_resolve_path_arg(self, wt, action):
 
399
        return self._path
 
400
 
 
401
    def assertTextConflict(self, wt, c):
 
402
        self.assertEqual(self._file_id, c.file_id)
 
403
        self.assertEqual(self._path, c.path)
 
404
    _assert_conflict = assertTextConflict
 
405
 
 
406
 
 
407
class TestResolveContentsConflict(TestParametrizedResolveConflicts):
 
408
 
 
409
    _conflict_type = conflicts.ContentsConflict
 
410
 
 
411
    # Set by the scenarios
 
412
    # path and file-id for the file involved in the conflict
 
413
    _path = None
 
414
    _file_id = None
 
415
 
 
416
    scenarios = mirror_scenarios(
 
417
        [
 
418
            # File modified/deleted
 
419
            (dict(_base_actions='create_file',
 
420
                  _path='file', _file_id='file-id'),
 
421
             ('file_modified',
 
422
              dict(actions='modify_file', check='file_has_more_content')),
 
423
             ('file_deleted',
 
424
              dict(actions='delete_file', check='file_doesnt_exist')),),
 
425
            # File modified/deleted in dir
 
426
            (dict(_base_actions='create_file_in_dir',
 
427
                  _path='dir/file', _file_id='file-id'),
 
428
             ('file_modified_in_dir',
 
429
              dict(actions='modify_file_in_dir',
 
430
                   check='file_in_dir_has_more_content')),
 
431
             ('file_deleted_in_dir',
 
432
              dict(actions='delete_file',
 
433
                   check='file_in_dir_doesnt_exist')),),
 
434
            ])
 
435
 
 
436
    def do_create_file(self):
 
437
        return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
 
438
 
 
439
    def do_modify_file(self):
 
440
        return [('modify', ('file-id', 'trunk content\nmore content\n'))]
 
441
 
 
442
    def check_file_has_more_content(self):
 
443
        self.assertFileEqual('trunk content\nmore content\n', 'branch/file')
 
444
 
 
445
    def do_delete_file(self):
 
446
        return [('unversion', 'file-id')]
 
447
 
 
448
    def check_file_doesnt_exist(self):
 
449
        self.assertPathDoesNotExist('branch/file')
 
450
 
 
451
    def do_create_file_in_dir(self):
 
452
        return [('add', ('dir', 'dir-id', 'directory', '')),
 
453
                ('add', ('dir/file', 'file-id', 'file', 'trunk content\n'))]
 
454
 
 
455
    def do_modify_file_in_dir(self):
 
456
        return [('modify', ('file-id', 'trunk content\nmore content\n'))]
 
457
 
 
458
    def check_file_in_dir_has_more_content(self):
 
459
        self.assertFileEqual('trunk content\nmore content\n', 'branch/dir/file')
 
460
 
 
461
    def check_file_in_dir_doesnt_exist(self):
 
462
        self.assertPathDoesNotExist('branch/dir/file')
 
463
 
 
464
    def _get_resolve_path_arg(self, wt, action):
 
465
        return self._path
 
466
 
 
467
    def assertContentsConflict(self, wt, c):
 
468
        self.assertEqual(self._file_id, c.file_id)
 
469
        self.assertEqual(self._path, c.path)
 
470
    _assert_conflict = assertContentsConflict
 
471
 
 
472
 
 
473
class TestResolvePathConflict(TestParametrizedResolveConflicts):
 
474
 
 
475
    _conflict_type = conflicts.PathConflict
 
476
 
 
477
    def do_nothing(self):
 
478
        return []
 
479
 
 
480
    # Each side dict additionally defines:
 
481
    # - path path involved (can be '<deleted>')
 
482
    # - file-id involved
 
483
    scenarios = mirror_scenarios(
 
484
        [
 
485
            # File renamed/deleted
 
486
            (dict(_base_actions='create_file'),
 
487
             ('file_renamed',
 
488
              dict(actions='rename_file', check='file_renamed',
 
489
                   path='new-file', file_id='file-id')),
 
490
             ('file_deleted',
 
491
              dict(actions='delete_file', check='file_doesnt_exist',
 
492
                   # PathConflicts deletion handling requires a special
 
493
                   # hard-coded value
 
494
                   path='<deleted>', file_id='file-id')),),
 
495
            # File renamed/deleted in dir
 
496
            (dict(_base_actions='create_file_in_dir'),
 
497
             ('file_renamed_in_dir',
 
498
              dict(actions='rename_file_in_dir', check='file_in_dir_renamed',
 
499
                   path='dir/new-file', file_id='file-id')),
 
500
             ('file_deleted',
 
501
              dict(actions='delete_file', check='file_in_dir_doesnt_exist',
 
502
                   # PathConflicts deletion handling requires a special
 
503
                   # hard-coded value
 
504
                   path='<deleted>', file_id='file-id')),),
 
505
            # File renamed/renamed differently
 
506
            (dict(_base_actions='create_file'),
 
507
             ('file_renamed',
 
508
              dict(actions='rename_file', check='file_renamed',
 
509
                   path='new-file', file_id='file-id')),
 
510
             ('file_renamed2',
 
511
              dict(actions='rename_file2', check='file_renamed2',
 
512
                   path='new-file2', file_id='file-id')),),
 
513
            # Dir renamed/deleted
 
514
            (dict(_base_actions='create_dir'),
 
515
             ('dir_renamed',
 
516
              dict(actions='rename_dir', check='dir_renamed',
 
517
                   path='new-dir', file_id='dir-id')),
 
518
             ('dir_deleted',
 
519
              dict(actions='delete_dir', check='dir_doesnt_exist',
 
520
                   # PathConflicts deletion handling requires a special
 
521
                   # hard-coded value
 
522
                   path='<deleted>', file_id='dir-id')),),
 
523
            # Dir renamed/renamed differently
 
524
            (dict(_base_actions='create_dir'),
 
525
             ('dir_renamed',
 
526
              dict(actions='rename_dir', check='dir_renamed',
 
527
                   path='new-dir', file_id='dir-id')),
 
528
             ('dir_renamed2',
 
529
              dict(actions='rename_dir2', check='dir_renamed2',
 
530
                   path='new-dir2', file_id='dir-id')),),
 
531
            ])
 
532
 
 
533
    def do_create_file(self):
 
534
        return [('add', ('file', 'file-id', 'file', 'trunk content\n'))]
 
535
 
 
536
    def do_create_dir(self):
 
537
        return [('add', ('dir', 'dir-id', 'directory', ''))]
 
538
 
 
539
    def do_rename_file(self):
 
540
        return [('rename', ('file', 'new-file'))]
 
541
 
 
542
    def check_file_renamed(self):
 
543
        self.assertPathDoesNotExist('branch/file')
 
544
        self.assertPathExists('branch/new-file')
 
545
 
 
546
    def do_rename_file2(self):
 
547
        return [('rename', ('file', 'new-file2'))]
 
548
 
 
549
    def check_file_renamed2(self):
 
550
        self.assertPathDoesNotExist('branch/file')
 
551
        self.assertPathExists('branch/new-file2')
 
552
 
 
553
    def do_rename_dir(self):
 
554
        return [('rename', ('dir', 'new-dir'))]
 
555
 
 
556
    def check_dir_renamed(self):
 
557
        self.assertPathDoesNotExist('branch/dir')
 
558
        self.assertPathExists('branch/new-dir')
 
559
 
 
560
    def do_rename_dir2(self):
 
561
        return [('rename', ('dir', 'new-dir2'))]
 
562
 
 
563
    def check_dir_renamed2(self):
 
564
        self.assertPathDoesNotExist('branch/dir')
 
565
        self.assertPathExists('branch/new-dir2')
 
566
 
 
567
    def do_delete_file(self):
 
568
        return [('unversion', 'file-id')]
 
569
 
 
570
    def check_file_doesnt_exist(self):
 
571
        self.assertPathDoesNotExist('branch/file')
 
572
 
 
573
    def do_delete_dir(self):
 
574
        return [('unversion', 'dir-id')]
 
575
 
 
576
    def check_dir_doesnt_exist(self):
 
577
        self.assertPathDoesNotExist('branch/dir')
 
578
 
 
579
    def do_create_file_in_dir(self):
 
580
        return [('add', ('dir', 'dir-id', 'directory', '')),
 
581
                ('add', ('dir/file', 'file-id', 'file', 'trunk content\n'))]
 
582
 
 
583
    def do_rename_file_in_dir(self):
 
584
        return [('rename', ('dir/file', 'dir/new-file'))]
 
585
 
 
586
    def check_file_in_dir_renamed(self):
 
587
        self.assertPathDoesNotExist('branch/dir/file')
 
588
        self.assertPathExists('branch/dir/new-file')
 
589
 
 
590
    def check_file_in_dir_doesnt_exist(self):
 
591
        self.assertPathDoesNotExist('branch/dir/file')
 
592
 
 
593
    def _get_resolve_path_arg(self, wt, action):
 
594
        tpath = self._this['path']
 
595
        opath = self._other['path']
 
596
        if tpath == '<deleted>':
 
597
            path = opath
 
598
        else:
 
599
            path = tpath
 
600
        return path
 
601
 
 
602
    def assertPathConflict(self, wt, c):
 
603
        tpath = self._this['path']
 
604
        tfile_id = self._this['file_id']
 
605
        opath = self._other['path']
 
606
        ofile_id = self._other['file_id']
 
607
        self.assertEqual(tfile_id, ofile_id) # Sanity check
 
608
        self.assertEqual(tfile_id, c.file_id)
 
609
        self.assertEqual(tpath, c.path)
 
610
        self.assertEqual(opath, c.conflict_path)
 
611
    _assert_conflict = assertPathConflict
 
612
 
 
613
 
 
614
class TestResolvePathConflictBefore531967(TestResolvePathConflict):
 
615
    """Same as TestResolvePathConflict but a specific conflict object.
 
616
    """
 
617
 
 
618
    def assertPathConflict(self, c):
 
619
        # We create a conflict object as it was created before the fix and
 
620
        # inject it into the working tree, the test will exercise the
 
621
        # compatibility code.
 
622
        old_c = conflicts.PathConflict('<deleted>', self._item_path,
 
623
                                       file_id=None)
 
624
        wt.set_conflicts(conflicts.ConflictList([old_c]))
 
625
 
 
626
 
 
627
class TestResolveDuplicateEntry(TestParametrizedResolveConflicts):
 
628
 
 
629
    _conflict_type = conflicts.DuplicateEntry
 
630
 
 
631
    scenarios = mirror_scenarios(
 
632
        [
 
633
            # File created with different file-ids
 
634
            (dict(_base_actions='nothing'),
 
635
             ('filea_created',
 
636
              dict(actions='create_file_a', check='file_content_a',
 
637
                   path='file', file_id='file-a-id')),
 
638
             ('fileb_created',
 
639
              dict(actions='create_file_b', check='file_content_b',
 
640
                   path='file', file_id='file-b-id')),),
 
641
            ])
 
642
 
 
643
    def do_nothing(self):
 
644
        return []
 
645
 
 
646
    def do_create_file_a(self):
 
647
        return [('add', ('file', 'file-a-id', 'file', 'file a content\n'))]
 
648
 
 
649
    def check_file_content_a(self):
 
650
        self.assertFileEqual('file a content\n', 'branch/file')
 
651
 
 
652
    def do_create_file_b(self):
 
653
        return [('add', ('file', 'file-b-id', 'file', 'file b content\n'))]
 
654
 
 
655
    def check_file_content_b(self):
 
656
        self.assertFileEqual('file b content\n', 'branch/file')
 
657
 
 
658
    def _get_resolve_path_arg(self, wt, action):
 
659
        return self._this['path']
 
660
 
 
661
    def assertDuplicateEntry(self, wt, c):
 
662
        tpath = self._this['path']
 
663
        tfile_id = self._this['file_id']
 
664
        opath = self._other['path']
 
665
        ofile_id = self._other['file_id']
 
666
        self.assertEqual(tpath, opath) # Sanity check
 
667
        self.assertEqual(tfile_id, c.file_id)
 
668
        self.assertEqual(tpath + '.moved', c.path)
 
669
        self.assertEqual(tpath, c.conflict_path)
 
670
    _assert_conflict = assertDuplicateEntry
303
671
 
304
672
 
305
673
class TestResolveUnversionedParent(TestResolveConflicts):
310
678
    # tests MissingParent resolution :-/
311
679
    preamble = """
312
680
$ bzr init trunk
 
681
...
313
682
$ cd trunk
314
683
$ mkdir dir
315
 
$ bzr add dir
316
 
$ bzr commit -m 'Create trunk'
 
684
$ bzr add -q dir
 
685
$ bzr commit -m 'Create trunk' -q
317
686
$ echo 'trunk content' >dir/file
318
 
$ bzr add dir/file
319
 
$ bzr commit -m 'Add dir/file in trunk'
320
 
 
321
 
$ bzr branch . -r 1 ../branch
 
687
$ bzr add -q dir/file
 
688
$ bzr commit -q -m 'Add dir/file in trunk'
 
689
$ bzr branch -q . -r 1 ../branch
322
690
$ cd ../branch
323
 
$ bzr rm dir
324
 
$ bzr commit -m 'Remove dir in branch'
325
 
 
 
691
$ bzr rm dir -q
 
692
$ bzr commit -q -m 'Remove dir in branch'
326
693
$ bzr merge ../trunk
327
694
2>+N  dir/
328
695
2>+N  dir/file
333
700
 
334
701
    def test_take_this(self):
335
702
        self.run_script("""
336
 
$ bzr rm dir  --force
 
703
$ bzr rm -q dir  --force
337
704
$ bzr resolve dir
338
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
705
2>2 conflict(s) resolved, 0 remaining
 
706
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
339
707
""")
340
708
 
341
709
    def test_take_other(self):
342
710
        self.run_script("""
343
711
$ bzr resolve dir
344
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
712
2>2 conflict(s) resolved, 0 remaining
 
713
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
345
714
""")
346
715
 
347
716
 
349
718
 
350
719
    preamble = """
351
720
$ bzr init trunk
 
721
...
352
722
$ cd trunk
353
723
$ mkdir dir
354
724
$ echo 'trunk content' >dir/file
355
 
$ bzr add
356
 
$ bzr commit -m 'Create trunk'
 
725
$ bzr add -q
 
726
$ bzr commit -m 'Create trunk' -q
357
727
$ echo 'trunk content' >dir/file2
358
 
$ bzr add dir/file2
359
 
$ bzr commit -m 'Add dir/file2 in branch'
360
 
 
361
 
$ bzr branch . -r 1 ../branch
 
728
$ bzr add -q dir/file2
 
729
$ bzr commit -q -m 'Add dir/file2 in branch'
 
730
$ bzr branch -q . -r 1 ../branch
362
731
$ cd ../branch
363
 
$ bzr rm dir/file --force
364
 
$ bzr rm dir
365
 
$ bzr commit -m 'Remove dir/file'
366
 
 
 
732
$ bzr rm -q dir/file --force
 
733
$ bzr rm -q dir
 
734
$ bzr commit -q -m 'Remove dir/file'
367
735
$ bzr merge ../trunk
368
736
2>+N  dir/
369
737
2>+N  dir/file2
375
743
    def test_keep_them_all(self):
376
744
        self.run_script("""
377
745
$ bzr resolve dir
378
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
746
2>2 conflict(s) resolved, 0 remaining
 
747
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
379
748
""")
380
749
 
381
750
    def test_adopt_child(self):
382
751
        self.run_script("""
383
 
$ bzr mv dir/file2 file2
384
 
$ bzr rm dir --force
 
752
$ bzr mv -q dir/file2 file2
 
753
$ bzr rm -q dir --force
385
754
$ bzr resolve dir
386
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
755
2>2 conflict(s) resolved, 0 remaining
 
756
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
387
757
""")
388
758
 
389
759
    def test_kill_them_all(self):
390
760
        self.run_script("""
391
 
$ bzr rm dir --force
 
761
$ bzr rm -q dir --force
392
762
$ bzr resolve dir
393
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
763
2>2 conflict(s) resolved, 0 remaining
 
764
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
394
765
""")
395
766
 
396
767
    def test_resolve_taking_this(self):
397
768
        self.run_script("""
398
769
$ bzr resolve --take-this dir
399
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
770
2>...
 
771
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
400
772
""")
401
773
 
402
774
    def test_resolve_taking_other(self):
403
775
        self.run_script("""
404
776
$ bzr resolve --take-other dir
405
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
777
2>...
 
778
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
406
779
""")
407
780
 
408
781
 
410
783
 
411
784
    preamble = """
412
785
$ bzr init trunk
 
786
...
413
787
$ cd trunk
414
788
$ mkdir dir
415
789
$ echo 'trunk content' >dir/file
416
 
$ bzr add
417
 
$ bzr commit -m 'Create trunk'
418
 
$ bzr rm dir/file --force
419
 
$ bzr rm dir --force
420
 
$ bzr commit -m 'Remove dir/file'
421
 
 
422
 
$ bzr branch . -r 1 ../branch
 
790
$ bzr add -q
 
791
$ bzr commit -m 'Create trunk' -q
 
792
$ bzr rm -q dir/file --force
 
793
$ bzr rm -q dir --force
 
794
$ bzr commit -q -m 'Remove dir/file'
 
795
$ bzr branch -q . -r 1 ../branch
423
796
$ cd ../branch
424
797
$ echo 'branch content' >dir/file2
425
 
$ bzr add dir/file2
426
 
$ bzr commit -m 'Add dir/file2 in branch'
427
 
 
 
798
$ bzr add -q dir/file2
 
799
$ bzr commit -q -m 'Add dir/file2 in branch'
428
800
$ bzr merge ../trunk
429
801
2>-D  dir/file
430
802
2>Conflict: can't delete dir because it is not empty.  Not deleting.
435
807
    def test_keep_them_all(self):
436
808
        self.run_script("""
437
809
$ bzr resolve dir
438
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
810
2>2 conflict(s) resolved, 0 remaining
 
811
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
439
812
""")
440
813
 
441
814
    def test_adopt_child(self):
442
815
        self.run_script("""
443
 
$ bzr mv dir/file2 file2
444
 
$ bzr rm dir --force
 
816
$ bzr mv -q dir/file2 file2
 
817
$ bzr rm -q dir --force
445
818
$ bzr resolve dir
446
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
819
2>2 conflict(s) resolved, 0 remaining
 
820
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
447
821
""")
448
822
 
449
823
    def test_kill_them_all(self):
450
824
        self.run_script("""
451
 
$ bzr rm dir --force
 
825
$ bzr rm -q dir --force
452
826
$ bzr resolve dir
453
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
827
2>2 conflict(s) resolved, 0 remaining
 
828
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
454
829
""")
455
830
 
456
831
    def test_resolve_taking_this(self):
457
832
        self.run_script("""
458
833
$ bzr resolve --take-this dir
459
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
834
2>2 conflict(s) resolved, 0 remaining
 
835
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
460
836
""")
461
837
 
462
838
    def test_resolve_taking_other(self):
463
839
        self.run_script("""
464
840
$ bzr resolve --take-other dir
465
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
466
 
""")
467
 
 
468
 
 
469
 
class TestResolvePathConflict(TestResolveConflicts):
470
 
 
471
 
    preamble = """
472
 
$ bzr init trunk
473
 
$ cd trunk
474
 
$ echo 'Boo!' >file
475
 
$ bzr add
476
 
$ bzr commit -m 'Create trunk'
477
 
$ bzr mv file file-in-trunk
478
 
$ bzr commit -m 'Renamed to file-in-trunk'
479
 
 
480
 
$ bzr branch . -r 1 ../branch
481
 
$ cd ../branch
482
 
$ bzr mv file file-in-branch
483
 
$ bzr commit -m 'Renamed to file-in-branch'
484
 
 
485
 
$ bzr merge ../trunk
486
 
2>R   file-in-branch => file-in-trunk
487
 
2>Path conflict: file-in-branch / file-in-trunk
488
 
2>1 conflicts encountered.
489
 
"""
490
 
 
491
 
    def test_keep_source(self):
492
 
        self.run_script("""
493
 
$ bzr resolve file-in-trunk
494
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
495
 
""")
496
 
 
497
 
    def test_keep_target(self):
498
 
        self.run_script("""
499
 
$ bzr mv file-in-trunk file-in-branch
500
 
$ bzr resolve file-in-branch
501
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
502
 
""")
503
 
 
504
 
    def test_resolve_taking_this(self):
505
 
        self.run_script("""
506
 
$ bzr resolve --take-this file-in-branch
507
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
508
 
""")
509
 
 
510
 
    def test_resolve_taking_other(self):
511
 
        self.run_script("""
512
 
$ bzr resolve --take-other file-in-branch
513
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
514
 
""")
515
 
 
516
 
 
517
 
class TestResolveParentLoop(TestResolveConflicts):
518
 
 
519
 
    preamble = """
520
 
$ bzr init trunk
521
 
$ cd trunk
522
 
$ bzr mkdir dir1
523
 
$ bzr mkdir dir2
524
 
$ bzr commit -m 'Create trunk'
525
 
$ bzr mv dir2 dir1
526
 
$ bzr commit -m 'Moved dir2 into dir1'
527
 
 
528
 
$ bzr branch . -r 1 ../branch
529
 
$ cd ../branch
530
 
$ bzr mv dir1 dir2
531
 
$ bzr commit -m 'Moved dir1 into dir2'
532
 
 
533
 
$ bzr merge ../trunk
534
 
2>Conflict moving dir2/dir1 into dir2.  Cancelled move.
535
 
2>1 conflicts encountered.
536
 
"""
537
 
 
538
 
    def test_take_this(self):
539
 
        self.run_script("""
540
 
$ bzr resolve dir2
541
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
542
 
""")
543
 
 
544
 
    def test_take_other(self):
545
 
        self.run_script("""
546
 
$ bzr mv dir2/dir1 dir1
547
 
$ bzr mv dir2 dir1
548
 
$ bzr resolve dir2
549
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
550
 
""")
551
 
 
552
 
    def test_resolve_taking_this(self):
553
 
        self.run_script("""
554
 
$ bzr resolve --take-this dir2
555
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
556
 
""")
557
 
        self.failUnlessExists('dir2')
558
 
 
559
 
    def test_resolve_taking_other(self):
560
 
        self.run_script("""
561
 
$ bzr resolve --take-other dir2
562
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
563
 
""")
564
 
        self.failUnlessExists('dir1')
 
841
2>deleted dir/file2
 
842
2>deleted dir
 
843
2>2 conflict(s) resolved, 0 remaining
 
844
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
 
845
""")
 
846
 
 
847
 
 
848
class TestResolveParentLoop(TestParametrizedResolveConflicts):
 
849
 
 
850
    _conflict_type = conflicts.ParentLoop
 
851
 
 
852
    _this_args = None
 
853
    _other_args = None
 
854
 
 
855
    # Each side dict additionally defines:
 
856
    # - dir_id: the directory being moved
 
857
    # - target_id: The target directory
 
858
    # - xfail: whether the test is expected to fail if the action is
 
859
    #   involved as 'other'
 
860
    scenarios = mirror_scenarios(
 
861
        [
 
862
            # Dirs moved into each other
 
863
            (dict(_base_actions='create_dir1_dir2'),
 
864
             ('dir1_into_dir2',
 
865
              dict(actions='move_dir1_into_dir2', check='dir1_moved',
 
866
                   dir_id='dir1-id', target_id='dir2-id', xfail=False)),
 
867
             ('dir2_into_dir1',
 
868
              dict(actions='move_dir2_into_dir1', check='dir2_moved',
 
869
                   dir_id='dir2-id', target_id='dir1-id', xfail=False))),
 
870
            # Subdirs moved into each other
 
871
            (dict(_base_actions='create_dir1_4'),
 
872
             ('dir1_into_dir4',
 
873
              dict(actions='move_dir1_into_dir4', check='dir1_2_moved',
 
874
                   dir_id='dir1-id', target_id='dir4-id', xfail=True)),
 
875
             ('dir3_into_dir2',
 
876
              dict(actions='move_dir3_into_dir2', check='dir3_4_moved',
 
877
                   dir_id='dir3-id', target_id='dir2-id', xfail=True))),
 
878
            ])
 
879
 
 
880
    def do_create_dir1_dir2(self):
 
881
        return [('add', ('dir1', 'dir1-id', 'directory', '')),
 
882
                ('add', ('dir2', 'dir2-id', 'directory', '')),]
 
883
 
 
884
    def do_move_dir1_into_dir2(self):
 
885
        return [('rename', ('dir1', 'dir2/dir1'))]
 
886
 
 
887
    def check_dir1_moved(self):
 
888
        self.assertPathDoesNotExist('branch/dir1')
 
889
        self.assertPathExists('branch/dir2/dir1')
 
890
 
 
891
    def do_move_dir2_into_dir1(self):
 
892
        return [('rename', ('dir2', 'dir1/dir2'))]
 
893
 
 
894
    def check_dir2_moved(self):
 
895
        self.assertPathDoesNotExist('branch/dir2')
 
896
        self.assertPathExists('branch/dir1/dir2')
 
897
 
 
898
    def do_create_dir1_4(self):
 
899
        return [('add', ('dir1', 'dir1-id', 'directory', '')),
 
900
                ('add', ('dir1/dir2', 'dir2-id', 'directory', '')),
 
901
                ('add', ('dir3', 'dir3-id', 'directory', '')),
 
902
                ('add', ('dir3/dir4', 'dir4-id', 'directory', '')),]
 
903
 
 
904
    def do_move_dir1_into_dir4(self):
 
905
        return [('rename', ('dir1', 'dir3/dir4/dir1'))]
 
906
 
 
907
    def check_dir1_2_moved(self):
 
908
        self.assertPathDoesNotExist('branch/dir1')
 
909
        self.assertPathExists('branch/dir3/dir4/dir1')
 
910
        self.assertPathExists('branch/dir3/dir4/dir1/dir2')
 
911
 
 
912
    def do_move_dir3_into_dir2(self):
 
913
        return [('rename', ('dir3', 'dir1/dir2/dir3'))]
 
914
 
 
915
    def check_dir3_4_moved(self):
 
916
        self.assertPathDoesNotExist('branch/dir3')
 
917
        self.assertPathExists('branch/dir1/dir2/dir3')
 
918
        self.assertPathExists('branch/dir1/dir2/dir3/dir4')
 
919
 
 
920
    def _get_resolve_path_arg(self, wt, action):
 
921
        # ParentLoop says: moving <conflict_path> into <path>. Cancelled move.
 
922
        # But since <path> doesn't exist in the working tree, we need to use
 
923
        # <conflict_path> instead, and that, in turn, is given by dir_id. Pfew.
 
924
        return wt.id2path(self._other['dir_id'])
 
925
 
 
926
    def assertParentLoop(self, wt, c):
 
927
        self.assertEqual(self._other['dir_id'], c.file_id)
 
928
        self.assertEqual(self._other['target_id'], c.conflict_file_id)
 
929
        # The conflict paths are irrelevant (they are deterministic but not
 
930
        # worth checking since they don't provide the needed information
 
931
        # anyway)
 
932
        if self._other['xfail']:
 
933
            # It's a bit hackish to raise from here relying on being called for
 
934
            # both tests but this avoid overriding test_resolve_taking_other
 
935
            raise tests.KnownFailure(
 
936
                "ParentLoop doesn't carry enough info to resolve --take-other")
 
937
    _assert_conflict = assertParentLoop
565
938
 
566
939
 
567
940
class TestResolveNonDirectoryParent(TestResolveConflicts):
568
941
 
569
942
    preamble = """
570
943
$ bzr init trunk
 
944
...
571
945
$ cd trunk
572
946
$ bzr mkdir foo
573
 
$ bzr commit -m 'Create trunk'
 
947
...
 
948
$ bzr commit -m 'Create trunk' -q
574
949
$ echo "Boing" >foo/bar
575
 
$ bzr add foo/bar
576
 
$ bzr commit -m 'Add foo/bar'
577
 
 
578
 
$ bzr branch . -r 1 ../branch
 
950
$ bzr add -q foo/bar
 
951
$ bzr commit -q -m 'Add foo/bar'
 
952
$ bzr branch -q . -r 1 ../branch
579
953
$ cd ../branch
580
954
$ rm -r foo
581
955
$ echo "Boo!" >foo
582
 
$ bzr commit -m 'foo is now a file'
583
 
 
 
956
$ bzr commit -q -m 'foo is now a file'
584
957
$ bzr merge ../trunk
585
958
2>+N  foo.new/bar
586
959
2>RK  foo => foo.new/
592
965
 
593
966
    def test_take_this(self):
594
967
        self.run_script("""
595
 
$ bzr rm foo.new --force
 
968
$ bzr rm -q foo.new --force
596
969
# FIXME: Isn't it weird that foo is now unkown even if foo.new has been put
597
970
# aside ? -- vila 090916
598
 
$ bzr add foo
 
971
$ bzr add -q foo
599
972
$ bzr resolve foo.new
600
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
973
2>1 conflict(s) resolved, 0 remaining
 
974
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
601
975
""")
602
976
 
603
977
    def test_take_other(self):
604
978
        self.run_script("""
605
 
$ bzr rm foo --force
606
 
$ bzr mv foo.new foo
 
979
$ bzr rm -q foo --force
 
980
$ bzr mv -q foo.new foo
607
981
$ bzr resolve foo
608
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
982
2>1 conflict(s) resolved, 0 remaining
 
983
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
609
984
""")
610
985
 
611
986
    def test_resolve_taking_this(self):
612
987
        self.run_script("""
613
988
$ bzr resolve --take-this foo.new
614
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
989
2>...
 
990
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
615
991
""")
616
992
 
617
993
    def test_resolve_taking_other(self):
618
994
        self.run_script("""
619
995
$ bzr resolve --take-other foo.new
620
 
$ bzr commit --strict -m 'No more conflicts nor unknown files'
 
996
2>...
 
997
$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
621
998
""")
622
999
 
623
1000
 
629
1006
        # conflict.
630
1007
        self.run_script("""
631
1008
$ bzr init trunk
 
1009
...
632
1010
$ cd trunk
633
1011
$ bzr mkdir foo
634
 
$ bzr commit -m 'Create trunk'
 
1012
...
 
1013
$ bzr commit -m 'Create trunk' -q
635
1014
$ rm -r foo
636
1015
$ echo "Boo!" >foo
637
 
$ bzr commit -m 'foo is now a file'
638
 
 
639
 
$ bzr branch . -r 1 ../branch
 
1016
$ bzr commit -m 'foo is now a file' -q
 
1017
$ bzr branch -q . -r 1 ../branch -q
640
1018
$ cd ../branch
641
1019
$ echo "Boing" >foo/bar
642
 
$ bzr add foo/bar
643
 
$ bzr commit -m 'Add foo/bar'
644
 
 
 
1020
$ bzr add -q foo/bar -q
 
1021
$ bzr commit -m 'Add foo/bar' -q
645
1022
$ bzr merge ../trunk
646
1023
2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')]
647
1024
""")