/breezy/trunk

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/trunk

« back to all changes in this revision

Viewing changes to breezy/tests/test_commit.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    )
26
26
from ..branch import Branch
27
27
from ..bzr.bzrdir import BzrDirMetaFormat1
28
 
from ..commit import Commit, NullCommitReporter
 
28
from ..commit import (
 
29
    Commit,
 
30
    NullCommitReporter,
 
31
    filter_excluded,
 
32
    )
29
33
from ..errors import (
30
34
    PointlessCommit,
31
35
    BzrError,
32
 
    SigningFailed,
33
36
    LockContention,
34
37
    )
35
38
from . import (
 
39
    TestCase,
36
40
    TestCaseWithTransport,
37
41
    test_foreign,
38
42
    )
48
52
 
49
53
    def __init__(self):
50
54
        super(MustSignConfig, self).__init__('''
51
 
gpg_signing_command=cat -
52
55
create_signatures=always
53
56
''')
54
57
 
426
429
            # monkey patch gpg signing mechanism
427
430
            breezy.gpg.GPGStrategy = breezy.gpg.LoopbackGPGStrategy
428
431
            conf = config.MemoryStack('''
429
 
gpg_signing_command=cat -
430
432
create_signatures=always
431
433
''')
432
434
            commit.Commit(config_stack=conf).commit(
452
454
            # monkey patch gpg signing mechanism
453
455
            breezy.gpg.GPGStrategy = breezy.gpg.DisabledGPGStrategy
454
456
            conf = config.MemoryStack('''
455
 
gpg_signing_command=cat -
456
457
create_signatures=always
457
458
''')
458
 
            self.assertRaises(SigningFailed,
 
459
            self.assertRaises(breezy.gpg.SigningFailed,
459
460
                              commit.Commit(config_stack=conf).commit,
460
461
                              message="base",
461
462
                              allow_pointless=True,
832
833
        tree2 = branch.create_checkout('repo/tree2')
833
834
        tree2.commit('message', rev_id='rev1')
834
835
        self.assertTrue(tree2.branch.repository.has_revision('rev1'))
 
836
 
 
837
 
 
838
class FilterExcludedTests(TestCase):
 
839
 
 
840
    def test_add_file_not_excluded(self):
 
841
        changes = [
 
842
            ('fid', (None, 'newpath'),
 
843
             0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
 
844
             ('file', 'file'), (True, True))]
 
845
        self.assertEqual(changes, list(filter_excluded(changes, ['otherpath'])))
 
846
 
 
847
    def test_add_file_excluded(self):
 
848
        changes = [
 
849
            ('fid', (None, 'newpath'),
 
850
             0, (False, False), ('pid', 'pid'), ('newpath', 'newpath'),
 
851
             ('file', 'file'), (True, True))]
 
852
        self.assertEqual([], list(filter_excluded(changes, ['newpath'])))
 
853
 
 
854
    def test_delete_file_excluded(self):
 
855
        changes = [
 
856
            ('fid', ('somepath', None),
 
857
             0, (False, None), ('pid', None), ('newpath', None),
 
858
             ('file', None), (True, None))]
 
859
        self.assertEqual([], list(filter_excluded(changes, ['somepath'])))
 
860
 
 
861
    def test_move_from_or_to_excluded(self):
 
862
        changes = [
 
863
            ('fid', ('oldpath', 'newpath'),
 
864
             0, (False, False), ('pid', 'pid'), ('oldpath', 'newpath'),
 
865
             ('file', 'file'), (True, True))]
 
866
        self.assertEqual([], list(filter_excluded(changes, ['oldpath'])))
 
867
        self.assertEqual([], list(filter_excluded(changes, ['newpath'])))