/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

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
19
20
 
20
21
import breezy
21
22
from .. import (
22
23
    config,
23
24
    controldir,
24
25
    errors,
 
26
    trace,
25
27
    )
26
28
from ..branch import Branch
27
29
from ..bzr.bzrdir import BzrDirMetaFormat1
36
38
    BzrError,
37
39
    LockContention,
38
40
    )
 
41
from ..bzr.inventorytree import InventoryTreeChange
39
42
from . import (
40
43
    TestCase,
41
44
    TestCaseWithTransport,
170
173
            reporter.calls)
171
174
 
172
175
        tree = b.repository.revision_tree(b'rev2')
173
 
        self.assertFalse(tree.has_id(b'hello-id'))
 
176
        self.assertFalse(tree.has_filename('hello'))
174
177
 
175
178
    def test_partial_commit_move(self):
176
179
        """Test a partial commit where a file was renamed but not committed.
358
361
        wt.commit('removed hello', rev_id=b'rev2')
359
362
 
360
363
        tree = b.repository.revision_tree(b'rev2')
361
 
        self.assertFalse(tree.has_id(b'hello-id'))
 
364
        self.assertFalse(tree.has_filename('hello'))
362
365
 
363
366
    def test_committed_ancestry(self):
364
367
        """Test commit appends revisions to ancestry."""
444
447
        wt.commit("base", allow_pointless=True, rev_id=b'A')
445
448
        self.assertFalse(branch.repository.has_signature_for_revision_id(b'A'))
446
449
        try:
447
 
            from ..testament import Testament
 
450
            from ..bzr.testament import Testament
448
451
            # monkey patch gpg signing mechanism
449
452
            breezy.gpg.GPGStrategy = breezy.gpg.LoopbackGPGStrategy
450
453
            conf = config.MemoryStack(b'''
526
529
        bound = master.sprout('bound')
527
530
        wt = bound.open_workingtree()
528
531
        wt.branch.set_bound_location(os.path.realpath('master'))
529
 
        master_branch.lock_write()
530
 
        try:
 
532
        with master_branch.lock_write():
531
533
            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
 
679
708
    def test_commit_kind_changes(self):
680
709
        self.requireFeature(SymlinkFeature)
681
710
        tree = self.make_branch_and_tree('.')
863
892
 
864
893
    def test_add_file_not_excluded(self):
865
894
        changes = [
866
 
            ('fid', (None, 'newpath'),
867
 
             0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
868
 
             ('file', 'file'), (True, True))]
 
895
            InventoryTreeChange(
 
896
                'fid', (None, 'newpath'),
 
897
                0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
 
898
                ('file', 'file'), (True, True))]
869
899
        self.assertEqual(changes, list(
870
900
            filter_excluded(changes, ['otherpath'])))
871
901
 
872
902
    def test_add_file_excluded(self):
873
903
        changes = [
874
 
            ('fid', (None, 'newpath'),
875
 
             0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
876
 
             ('file', 'file'), (True, True))]
 
904
            InventoryTreeChange(
 
905
                'fid', (None, 'newpath'),
 
906
                0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
 
907
                ('file', 'file'), (True, True))]
877
908
        self.assertEqual([], list(filter_excluded(changes, ['newpath'])))
878
909
 
879
910
    def test_delete_file_excluded(self):
880
911
        changes = [
881
 
            ('fid', ('somepath', None),
882
 
             0, (False, None), ('pid', None), ('newpath', None),
883
 
             ('file', None), (True, None))]
 
912
            InventoryTreeChange(
 
913
                'fid', ('somepath', None),
 
914
                0, (False, None), ('pid', None), ('newpath', None),
 
915
                ('file', None), (True, None))]
884
916
        self.assertEqual([], list(filter_excluded(changes, ['somepath'])))
885
917
 
886
918
    def test_move_from_or_to_excluded(self):
887
919
        changes = [
888
 
            ('fid', ('oldpath', 'newpath'),
889
 
             0, (False, False), ('pid', 'pid'), ('oldpath', 'newpath'),
890
 
             ('file', 'file'), (True, True))]
 
920
            InventoryTreeChange(
 
921
                'fid', ('oldpath', 'newpath'),
 
922
                0, (False, False), ('pid', 'pid'), ('oldpath', 'newpath'),
 
923
                ('file', 'file'), (True, True))]
891
924
        self.assertEqual([], list(filter_excluded(changes, ['oldpath'])))
892
925
        self.assertEqual([], list(filter_excluded(changes, ['newpath'])))