/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: 2017-05-21 18:10:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521181028-zn04pdfw0od9hfj3
Rename brzlib => breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
import os
19
19
 
20
 
import brzlib
21
 
from brzlib import (
 
20
import breezy
 
21
from breezy import (
22
22
    config,
23
23
    controldir,
24
24
    errors,
25
25
    )
26
 
from brzlib.branch import Branch
27
 
from brzlib.bzrdir import BzrDirMetaFormat1
28
 
from brzlib.commit import Commit, NullCommitReporter
29
 
from brzlib.errors import (
 
26
from breezy.branch import Branch
 
27
from breezy.bzrdir import BzrDirMetaFormat1
 
28
from breezy.commit import Commit, NullCommitReporter
 
29
from breezy.errors import (
30
30
    PointlessCommit,
31
31
    BzrError,
32
32
    SigningFailed,
33
33
    LockContention,
34
34
    )
35
 
from brzlib.tests import (
 
35
from breezy.tests import (
36
36
    TestCaseWithTransport,
37
37
    test_foreign,
38
38
    )
39
 
from brzlib.tests.features import (
 
39
from breezy.tests.features import (
40
40
    SymlinkFeature,
41
41
    )
42
 
from brzlib.tests.matchers import MatchesAncestry
 
42
from breezy.tests.matchers import MatchesAncestry
43
43
 
44
44
 
45
45
# TODO: Test commit with some added, and added-but-missing files
377
377
 
378
378
    def test_strict_commit(self):
379
379
        """Try and commit with unknown files and strict = True, should fail."""
380
 
        from brzlib.errors import StrictCommitFailed
 
380
        from breezy.errors import StrictCommitFailed
381
381
        wt = self.make_branch_and_tree('.')
382
382
        b = wt.branch
383
383
        with file('hello', 'w') as f: f.write('hello world')
414
414
        wt.commit(message='add hello', strict=False)
415
415
 
416
416
    def test_signed_commit(self):
417
 
        import brzlib.gpg
418
 
        import brzlib.commit as commit
419
 
        oldstrategy = brzlib.gpg.GPGStrategy
 
417
        import breezy.gpg
 
418
        import breezy.commit as commit
 
419
        oldstrategy = breezy.gpg.GPGStrategy
420
420
        wt = self.make_branch_and_tree('.')
421
421
        branch = wt.branch
422
422
        wt.commit("base", allow_pointless=True, rev_id='A')
423
423
        self.assertFalse(branch.repository.has_signature_for_revision_id('A'))
424
424
        try:
425
 
            from brzlib.testament import Testament
 
425
            from breezy.testament import Testament
426
426
            # monkey patch gpg signing mechanism
427
 
            brzlib.gpg.GPGStrategy = brzlib.gpg.LoopbackGPGStrategy
 
427
            breezy.gpg.GPGStrategy = breezy.gpg.LoopbackGPGStrategy
428
428
            conf = config.MemoryStack('''
429
429
gpg_signing_command=cat -
430
430
create_signatures=always
433
433
                message="base", allow_pointless=True, rev_id='B',
434
434
                working_tree=wt)
435
435
            def sign(text):
436
 
                return brzlib.gpg.LoopbackGPGStrategy(None).sign(text)
 
436
                return breezy.gpg.LoopbackGPGStrategy(None).sign(text)
437
437
            self.assertEqual(sign(Testament.from_revision(branch.repository,
438
438
                                                          'B').as_short_text()),
439
439
                             branch.repository.get_signature_text('B'))
440
440
        finally:
441
 
            brzlib.gpg.GPGStrategy = oldstrategy
 
441
            breezy.gpg.GPGStrategy = oldstrategy
442
442
 
443
443
    def test_commit_failed_signature(self):
444
 
        import brzlib.gpg
445
 
        import brzlib.commit as commit
446
 
        oldstrategy = brzlib.gpg.GPGStrategy
 
444
        import breezy.gpg
 
445
        import breezy.commit as commit
 
446
        oldstrategy = breezy.gpg.GPGStrategy
447
447
        wt = self.make_branch_and_tree('.')
448
448
        branch = wt.branch
449
449
        wt.commit("base", allow_pointless=True, rev_id='A')
450
450
        self.assertFalse(branch.repository.has_signature_for_revision_id('A'))
451
451
        try:
452
452
            # monkey patch gpg signing mechanism
453
 
            brzlib.gpg.GPGStrategy = brzlib.gpg.DisabledGPGStrategy
 
453
            breezy.gpg.GPGStrategy = breezy.gpg.DisabledGPGStrategy
454
454
            conf = config.MemoryStack('''
455
455
gpg_signing_command=cat -
456
456
create_signatures=always
465
465
            self.assertEqual(branch.last_revision(), 'A')
466
466
            self.assertFalse(branch.repository.has_revision('B'))
467
467
        finally:
468
 
            brzlib.gpg.GPGStrategy = oldstrategy
 
468
            breezy.gpg.GPGStrategy = oldstrategy
469
469
 
470
470
    def test_commit_invokes_hooks(self):
471
 
        import brzlib.commit as commit
 
471
        import breezy.commit as commit
472
472
        wt = self.make_branch_and_tree('.')
473
473
        branch = wt.branch
474
474
        calls = []
475
475
        def called(branch, rev_id):
476
476
            calls.append('called')
477
 
        brzlib.ahook = called
 
477
        breezy.ahook = called
478
478
        try:
479
 
            conf = config.MemoryStack('post_commit=brzlib.ahook brzlib.ahook')
 
479
            conf = config.MemoryStack('post_commit=breezy.ahook breezy.ahook')
480
480
            commit.Commit(config_stack=conf).commit(
481
481
                message = "base", allow_pointless=True, rev_id='A',
482
482
                working_tree = wt)
483
483
            self.assertEqual(['called', 'called'], calls)
484
484
        finally:
485
 
            del brzlib.ahook
 
485
            del breezy.ahook
486
486
 
487
487
    def test_commit_object_doesnt_set_nick(self):
488
488
        # using the Commit object directly does not set the branch nick.