/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_commit.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:
16
16
 
17
17
 
18
18
import os
19
 
from io import BytesIO
20
19
 
21
20
import breezy
22
21
from .. import (
23
22
    config,
24
23
    controldir,
25
24
    errors,
26
 
    trace,
27
25
    )
28
26
from ..branch import Branch
29
27
from ..bzr.bzrdir import BzrDirMetaFormat1
38
36
    BzrError,
39
37
    LockContention,
40
38
    )
41
 
from ..bzr.inventorytree import InventoryTreeChange
42
39
from . import (
43
40
    TestCase,
44
41
    TestCaseWithTransport,
173
170
            reporter.calls)
174
171
 
175
172
        tree = b.repository.revision_tree(b'rev2')
176
 
        self.assertFalse(tree.has_filename('hello'))
 
173
        self.assertFalse(tree.has_id(b'hello-id'))
177
174
 
178
175
    def test_partial_commit_move(self):
179
176
        """Test a partial commit where a file was renamed but not committed.
361
358
        wt.commit('removed hello', rev_id=b'rev2')
362
359
 
363
360
        tree = b.repository.revision_tree(b'rev2')
364
 
        self.assertFalse(tree.has_filename('hello'))
 
361
        self.assertFalse(tree.has_id(b'hello-id'))
365
362
 
366
363
    def test_committed_ancestry(self):
367
364
        """Test commit appends revisions to ancestry."""
529
526
        bound = master.sprout('bound')
530
527
        wt = bound.open_workingtree()
531
528
        wt.branch.set_bound_location(os.path.realpath('master'))
532
 
        with master_branch.lock_write():
 
529
        master_branch.lock_write()
 
530
        try:
533
531
            self.assertRaises(LockContention, wt.commit, 'silly')
 
532
        finally:
 
533
            master_branch.unlock()
534
534
 
535
535
    def test_commit_bound_merge(self):
536
536
        # see bug #43959; commit of a merge in a bound branch fails to push
676
676
        finally:
677
677
            basis.unlock()
678
678
 
679
 
    def test_unsupported_symlink_commit(self):
680
 
        self.requireFeature(SymlinkFeature)
681
 
        tree = self.make_branch_and_tree('.')
682
 
        self.build_tree(['hello'])
683
 
        tree.add('hello')
684
 
        tree.commit('added hello', rev_id=b'hello_id')
685
 
        os.symlink('hello', 'foo')
686
 
        tree.add('foo')
687
 
        tree.commit('added foo', rev_id=b'foo_id')
688
 
        log = BytesIO()
689
 
        trace.push_log_file(log)
690
 
        os_symlink = getattr(os, 'symlink', None)
691
 
        os.symlink = None
692
 
        try:
693
 
            # At this point as bzr thinks symlinks are not supported
694
 
            # we should get a warning about symlink foo and bzr should
695
 
            # not think its removed.
696
 
            os.unlink('foo')
697
 
            self.build_tree(['world'])
698
 
            tree.add('world')
699
 
            tree.commit('added world', rev_id=b'world_id')
700
 
        finally:
701
 
            if os_symlink:
702
 
                os.symlink = os_symlink
703
 
        self.assertContainsRe(
704
 
            log.getvalue(),
705
 
            b'Ignoring "foo" as symlinks are not '
706
 
            b'supported on this filesystem\\.')
707
 
 
708
679
    def test_commit_kind_changes(self):
709
680
        self.requireFeature(SymlinkFeature)
710
681
        tree = self.make_branch_and_tree('.')
892
863
 
893
864
    def test_add_file_not_excluded(self):
894
865
        changes = [
895
 
            InventoryTreeChange(
896
 
                'fid', (None, 'newpath'),
897
 
                0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
898
 
                ('file', 'file'), (True, True))]
 
866
            ('fid', (None, 'newpath'),
 
867
             0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
 
868
             ('file', 'file'), (True, True))]
899
869
        self.assertEqual(changes, list(
900
870
            filter_excluded(changes, ['otherpath'])))
901
871
 
902
872
    def test_add_file_excluded(self):
903
873
        changes = [
904
 
            InventoryTreeChange(
905
 
                'fid', (None, 'newpath'),
906
 
                0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
907
 
                ('file', 'file'), (True, True))]
 
874
            ('fid', (None, 'newpath'),
 
875
             0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
 
876
             ('file', 'file'), (True, True))]
908
877
        self.assertEqual([], list(filter_excluded(changes, ['newpath'])))
909
878
 
910
879
    def test_delete_file_excluded(self):
911
880
        changes = [
912
 
            InventoryTreeChange(
913
 
                'fid', ('somepath', None),
914
 
                0, (False, None), ('pid', None), ('newpath', None),
915
 
                ('file', None), (True, None))]
 
881
            ('fid', ('somepath', None),
 
882
             0, (False, None), ('pid', None), ('newpath', None),
 
883
             ('file', None), (True, None))]
916
884
        self.assertEqual([], list(filter_excluded(changes, ['somepath'])))
917
885
 
918
886
    def test_move_from_or_to_excluded(self):
919
887
        changes = [
920
 
            InventoryTreeChange(
921
 
                'fid', ('oldpath', 'newpath'),
922
 
                0, (False, False), ('pid', 'pid'), ('oldpath', 'newpath'),
923
 
                ('file', 'file'), (True, True))]
 
888
            ('fid', ('oldpath', 'newpath'),
 
889
             0, (False, False), ('pid', 'pid'), ('oldpath', 'newpath'),
 
890
             ('file', 'file'), (True, True))]
924
891
        self.assertEqual([], list(filter_excluded(changes, ['oldpath'])))
925
892
        self.assertEqual([], list(filter_excluded(changes, ['newpath'])))