/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-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:
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 ..tree import TreeChange
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."""
679
676
        finally:
680
677
            basis.unlock()
681
678
 
682
 
    def test_unsupported_symlink_commit(self):
683
 
        self.requireFeature(SymlinkFeature)
684
 
        tree = self.make_branch_and_tree('.')
685
 
        self.build_tree(['hello'])
686
 
        tree.add('hello')
687
 
        tree.commit('added hello', rev_id=b'hello_id')
688
 
        os.symlink('hello', 'foo')
689
 
        tree.add('foo')
690
 
        tree.commit('added foo', rev_id=b'foo_id')
691
 
        log = BytesIO()
692
 
        trace.push_log_file(log)
693
 
        os_symlink = getattr(os, 'symlink', None)
694
 
        os.symlink = None
695
 
        try:
696
 
            # At this point as bzr thinks symlinks are not supported
697
 
            # we should get a warning about symlink foo and bzr should
698
 
            # not think its removed.
699
 
            os.unlink('foo')
700
 
            self.build_tree(['world'])
701
 
            tree.add('world')
702
 
            tree.commit('added world', rev_id=b'world_id')
703
 
        finally:
704
 
            if os_symlink:
705
 
                os.symlink = os_symlink
706
 
        self.assertContainsRe(
707
 
            log.getvalue(),
708
 
            b'Ignoring "foo" as symlinks are not '
709
 
            b'supported on this filesystem\\.')
710
 
 
711
679
    def test_commit_kind_changes(self):
712
680
        self.requireFeature(SymlinkFeature)
713
681
        tree = self.make_branch_and_tree('.')
895
863
 
896
864
    def test_add_file_not_excluded(self):
897
865
        changes = [
898
 
            TreeChange(
899
 
                'fid', (None, 'newpath'),
900
 
                0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
901
 
                ('file', 'file'), (True, True))]
 
866
            ('fid', (None, 'newpath'),
 
867
             0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
 
868
             ('file', 'file'), (True, True))]
902
869
        self.assertEqual(changes, list(
903
870
            filter_excluded(changes, ['otherpath'])))
904
871
 
905
872
    def test_add_file_excluded(self):
906
873
        changes = [
907
 
            TreeChange(
908
 
                'fid', (None, 'newpath'),
909
 
                0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
910
 
                ('file', 'file'), (True, True))]
 
874
            ('fid', (None, 'newpath'),
 
875
             0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
 
876
             ('file', 'file'), (True, True))]
911
877
        self.assertEqual([], list(filter_excluded(changes, ['newpath'])))
912
878
 
913
879
    def test_delete_file_excluded(self):
914
880
        changes = [
915
 
            TreeChange(
916
 
                'fid', ('somepath', None),
917
 
                0, (False, None), ('pid', None), ('newpath', None),
918
 
                ('file', None), (True, None))]
 
881
            ('fid', ('somepath', None),
 
882
             0, (False, None), ('pid', None), ('newpath', None),
 
883
             ('file', None), (True, None))]
919
884
        self.assertEqual([], list(filter_excluded(changes, ['somepath'])))
920
885
 
921
886
    def test_move_from_or_to_excluded(self):
922
887
        changes = [
923
 
            TreeChange(
924
 
                'fid', ('oldpath', 'newpath'),
925
 
                0, (False, False), ('pid', 'pid'), ('oldpath', 'newpath'),
926
 
                ('file', 'file'), (True, True))]
 
888
            ('fid', ('oldpath', 'newpath'),
 
889
             0, (False, False), ('pid', 'pid'), ('oldpath', 'newpath'),
 
890
             ('file', 'file'), (True, True))]
927
891
        self.assertEqual([], list(filter_excluded(changes, ['oldpath'])))
928
892
        self.assertEqual([], list(filter_excluded(changes, ['newpath'])))