/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-03-05 07:32:38 UTC
  • mto: (7290.1.21 work)
  • mto: This revision was merged to the branch mainline in revision 7311.
  • Revision ID: jelmer@jelmer.uk-20190305073238-zlqn981opwnqsmzi
Add appveyor configuration.

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
    )
29
24
from ..bzr import (
30
25
    bzrdir,
31
 
    conflicts as _mod_bzr_conflicts,
32
26
    workingtree as bzrworkingtree,
33
27
    workingtree_3,
34
28
    workingtree_4,
43
37
    TreeLink,
44
38
    )
45
39
 
46
 
from .features import SymlinkFeature
47
40
 
48
41
class TestTreeDirectory(TestCaseWithTransport):
49
42
 
412
405
 
413
406
class TestAutoResolve(TestCaseWithTransport):
414
407
 
415
 
    def _auto_resolve(self, tree):
416
 
        """Call auto_resolve on tree expecting deprecation"""
417
 
        return self.applyDeprecated(
418
 
            symbol_versioning.deprecated_in((3, 0, 1)),
419
 
            tree.auto_resolve,)
420
 
 
421
408
    def test_auto_resolve(self):
422
409
        base = self.make_branch_and_tree('base')
423
410
        self.build_tree_contents([('base/hello', b'Hello')])
431
418
        self.build_tree_contents([('this/hello', b'Hello World')])
432
419
        this.commit('Add World')
433
420
        this.merge_from_branch(other.branch)
434
 
        self.assertEqual([_mod_bzr_conflicts.TextConflict('hello', b'hello_id')],
435
 
                         this.conflicts())
436
 
        self._auto_resolve(this)
437
 
        self.assertEqual([_mod_bzr_conflicts.TextConflict('hello', b'hello_id')],
438
 
                         this.conflicts())
439
 
        self.build_tree_contents([('this/hello', '<<<<<<<')])
440
 
        self._auto_resolve(this)
441
 
        self.assertEqual([_mod_bzr_conflicts.TextConflict('hello', b'hello_id')],
442
 
                         this.conflicts())
443
 
        self.build_tree_contents([('this/hello', '=======')])
444
 
        self._auto_resolve(this)
445
 
        self.assertEqual([_mod_bzr_conflicts.TextConflict('hello', b'hello_id')],
446
 
                         this.conflicts())
447
 
        self.build_tree_contents([('this/hello', '\n>>>>>>>')])
448
 
        remaining, resolved = self._auto_resolve(this)
449
 
        self.assertEqual([_mod_bzr_conflicts.TextConflict('hello', b'hello_id')],
 
421
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
 
422
                         this.conflicts())
 
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()
 
436
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
450
437
                         this.conflicts())
451
438
        self.assertEqual([], resolved)
452
439
        self.build_tree_contents([('this/hello', b'hELLO wORLD')])
453
 
        remaining, resolved = self._auto_resolve(this)
 
440
        remaining, resolved = this.auto_resolve()
454
441
        self.assertEqual([], this.conflicts())
455
 
        self.assertEqual([_mod_bzr_conflicts.TextConflict('hello', b'hello_id')],
 
442
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
456
443
                         resolved)
457
444
        self.assertPathDoesNotExist('this/hello.BASE')
458
445
 
459
 
    def test_unsupported_symlink_auto_resolve(self):
460
 
        self.requireFeature(SymlinkFeature)
461
 
        base = self.make_branch_and_tree('base')
462
 
        self.build_tree_contents([('base/hello', 'Hello')])
463
 
        base.add('hello', b'hello_id')
464
 
        base.commit('commit 0')
465
 
        other = base.controldir.sprout('other').open_workingtree()
466
 
        self.build_tree_contents([('other/hello', 'Hello')])
467
 
        os.symlink('other/hello', 'other/foo')
468
 
        other.add('foo', b'foo_id')
469
 
        other.commit('commit symlink')
470
 
        this = base.controldir.sprout('this').open_workingtree()
471
 
        self.assertPathExists('this/hello')
472
 
        self.build_tree_contents([('this/hello', 'Hello')])
473
 
        this.commit('commit 2')
474
 
        log = BytesIO()
475
 
        trace.push_log_file(log)
476
 
        os_symlink = getattr(os, 'symlink', None)
477
 
        os.symlink = None
478
 
        try:
479
 
            this.merge_from_branch(other.branch)
480
 
        finally:
481
 
            if os_symlink:
482
 
                os.symlink = os_symlink
483
 
        self.assertContainsRe(
484
 
            log.getvalue(),
485
 
            b'Unable to create symlink "foo" on this filesystem')
486
 
 
487
446
    def test_auto_resolve_dir(self):
488
447
        tree = self.make_branch_and_tree('tree')
489
448
        self.build_tree(['tree/hello/'])
490
449
        tree.add('hello', b'hello-id')
491
 
        file_conflict = _mod_bzr_conflicts.TextConflict('hello', b'hello-id')
492
 
        tree.set_conflicts([file_conflict])
493
 
        remaining, resolved = self._auto_resolve(tree)
494
 
        self.assertEqual(
495
 
            remaining,
496
 
            conflicts.ConflictList([_mod_bzr_conflicts.TextConflict(u'hello', 'hello-id')]))
497
 
        self.assertEqual(resolved, [])
498
 
 
499
 
    def test_auto_resolve_missing(self):
500
 
        tree = self.make_branch_and_tree('tree')
501
 
        file_conflict = _mod_bzr_conflicts.TextConflict('hello', b'hello-id')
502
 
        tree.set_conflicts([file_conflict])
503
 
        remaining, resolved = self._auto_resolve(tree)
504
 
        self.assertEqual(remaining, [])
505
 
        self.assertEqual(
506
 
            resolved,
507
 
            conflicts.ConflictList([_mod_bzr_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()
 
453
 
 
454
 
 
455
class TestFindTrees(TestCaseWithTransport):
 
456
 
 
457
    def test_find_trees(self):
 
458
        self.make_branch_and_tree('foo')
 
459
        self.make_branch_and_tree('foo/bar')
 
460
        # Sticking a tree inside a control dir is heinous, so let's skip it
 
461
        self.make_branch_and_tree('foo/.bzr/baz')
 
462
        self.make_branch('qux')
 
463
        trees = workingtree.WorkingTree.find_trees('.')
 
464
        self.assertEqual(2, len(list(trees)))
508
465
 
509
466
 
510
467
class TestStoredUncommitted(TestCaseWithTransport):