/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
 
from io import BytesIO
19
 
import os
20
 
 
21
18
from .. import (
22
19
    conflicts,
23
20
    errors,
24
 
    symbol_versioning,
25
 
    trace,
26
21
    transport,
27
22
    workingtree,
28
23
    )
42
37
    TreeLink,
43
38
    )
44
39
 
45
 
from .features import SymlinkFeature
46
40
 
47
41
class TestTreeDirectory(TestCaseWithTransport):
48
42
 
411
405
 
412
406
class TestAutoResolve(TestCaseWithTransport):
413
407
 
414
 
    def _auto_resolve(self, tree):
415
 
        """Call auto_resolve on tree expecting deprecation"""
416
 
        return self.applyDeprecated(
417
 
            symbol_versioning.deprecated_in((3, 0, 1)),
418
 
            tree.auto_resolve,)
419
 
 
420
408
    def test_auto_resolve(self):
421
409
        base = self.make_branch_and_tree('base')
422
410
        self.build_tree_contents([('base/hello', b'Hello')])
432
420
        this.merge_from_branch(other.branch)
433
421
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
434
422
                         this.conflicts())
435
 
        self._auto_resolve(this)
436
 
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
437
 
                         this.conflicts())
438
 
        self.build_tree_contents([('this/hello', '<<<<<<<')])
439
 
        self._auto_resolve(this)
440
 
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
441
 
                         this.conflicts())
442
 
        self.build_tree_contents([('this/hello', '=======')])
443
 
        self._auto_resolve(this)
444
 
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
445
 
                         this.conflicts())
446
 
        self.build_tree_contents([('this/hello', '\n>>>>>>>')])
447
 
        remaining, resolved = self._auto_resolve(this)
 
423
        this.auto_resolve()
 
424
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
 
425
                         this.conflicts())
 
426
        self.build_tree_contents([('this/hello', b'<<<<<<<')])
 
427
        this.auto_resolve()
 
428
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
 
429
                         this.conflicts())
 
430
        self.build_tree_contents([('this/hello', b'=======')])
 
431
        this.auto_resolve()
 
432
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
 
433
                         this.conflicts())
 
434
        self.build_tree_contents([('this/hello', b'\n>>>>>>>')])
 
435
        remaining, resolved = this.auto_resolve()
448
436
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
449
437
                         this.conflicts())
450
438
        self.assertEqual([], resolved)
451
439
        self.build_tree_contents([('this/hello', b'hELLO wORLD')])
452
 
        remaining, resolved = self._auto_resolve(this)
 
440
        remaining, resolved = this.auto_resolve()
453
441
        self.assertEqual([], this.conflicts())
454
442
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
455
443
                         resolved)
456
444
        self.assertPathDoesNotExist('this/hello.BASE')
457
445
 
458
 
    def test_unsupported_symlink_auto_resolve(self):
459
 
        self.requireFeature(SymlinkFeature)
460
 
        base = self.make_branch_and_tree('base')
461
 
        self.build_tree_contents([('base/hello', 'Hello')])
462
 
        base.add('hello', b'hello_id')
463
 
        base.commit('commit 0')
464
 
        other = base.controldir.sprout('other').open_workingtree()
465
 
        self.build_tree_contents([('other/hello', 'Hello')])
466
 
        os.symlink('other/hello', 'other/foo')
467
 
        other.add('foo', b'foo_id')
468
 
        other.commit('commit symlink')
469
 
        this = base.controldir.sprout('this').open_workingtree()
470
 
        self.assertPathExists('this/hello')
471
 
        self.build_tree_contents([('this/hello', 'Hello')])
472
 
        this.commit('commit 2')
473
 
        log = BytesIO()
474
 
        trace.push_log_file(log)
475
 
        os_symlink = getattr(os, 'symlink', None)
476
 
        os.symlink = None
477
 
        try:
478
 
            this.merge_from_branch(other.branch)
479
 
        finally:
480
 
            if os_symlink:
481
 
                os.symlink = os_symlink
482
 
        self.assertContainsRe(
483
 
            log.getvalue(),
484
 
            b'Unable to create symlink "foo" on this filesystem')
485
 
 
486
446
    def test_auto_resolve_dir(self):
487
447
        tree = self.make_branch_and_tree('tree')
488
448
        self.build_tree(['tree/hello/'])
489
449
        tree.add('hello', b'hello-id')
490
 
        file_conflict = conflicts.TextConflict('hello', b'hello-id')
491
 
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
492
 
        remaining, resolved = self._auto_resolve(tree)
493
 
        self.assertEqual(
494
 
            remaining,
495
 
            conflicts.ConflictList([conflicts.TextConflict(u'hello', 'hello-id')]))
496
 
        self.assertEqual(resolved, [])
497
 
 
498
 
    def test_auto_resolve_missing(self):
499
 
        tree = self.make_branch_and_tree('tree')
500
 
        file_conflict = conflicts.TextConflict('hello', b'hello-id')
501
 
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
502
 
        remaining, resolved = self._auto_resolve(tree)
503
 
        self.assertEqual(remaining, [])
504
 
        self.assertEqual(
505
 
            resolved,
506
 
            conflicts.ConflictList([conflicts.TextConflict(u'hello', 'hello-id')]))
 
450
        file_conflict = conflicts.TextConflict('file', b'hello-id')
 
451
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
 
452
        tree.auto_resolve()
507
453
 
508
454
 
509
455
class TestStoredUncommitted(TestCaseWithTransport):