/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 bzrlib/tests/test_commit.py

Convert more stuff to use config stacks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from bzrlib.branch import Branch
26
26
from bzrlib.bzrdir import BzrDirMetaFormat1
27
27
from bzrlib.commit import Commit, NullCommitReporter
28
 
from bzrlib.config import BranchConfig
 
28
from bzrlib.config import (
 
29
    SIGN_ALWAYS,
 
30
    Stack,
 
31
    )
29
32
from bzrlib.errors import (
30
33
    PointlessCommit,
31
34
    BzrError,
44
47
 
45
48
# TODO: Test commit with some added, and added-but-missing files
46
49
 
47
 
class MustSignConfig(BranchConfig):
48
 
 
49
 
    def signature_needed(self):
50
 
        return True
51
 
 
52
 
    def gpg_signing_command(self):
53
 
        return ['cat', '-']
54
 
 
55
 
 
56
 
class BranchWithHooks(BranchConfig):
57
 
 
58
 
    def post_commit(self):
59
 
        return "bzrlib.ahook bzrlib.ahook"
 
50
class MustSignConfig(Stack):
 
51
 
 
52
    def get(self, name):
 
53
        if name == "gpg_signing_command":
 
54
            return "cat -"
 
55
        elif name == "signing_policy":
 
56
            return SIGN_ALWAYS
 
57
        return None
 
58
 
 
59
 
 
60
class BranchWithHooks(Stack):
 
61
 
 
62
    def get(self, name):
 
63
        if name == "post_commit":
 
64
            return "bzrlib.ahook bzrlib.ahook"
 
65
        return None
60
66
 
61
67
 
62
68
class CapturingReporter(NullCommitReporter):
431
437
            from bzrlib.testament import Testament
432
438
            # monkey patch gpg signing mechanism
433
439
            bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
434
 
            commit.Commit(config=MustSignConfig(branch)).commit(message="base",
 
440
            commit.Commit(config_stack=MustSignConfig(branch)).commit(message="base",
435
441
                                                      allow_pointless=True,
436
442
                                                      rev_id='B',
437
443
                                                      working_tree=wt)
456
462
            bzrlib.gpg.GPGStrategy = bzrlib.gpg.DisabledGPGStrategy
457
463
            config = MustSignConfig(branch)
458
464
            self.assertRaises(SigningFailed,
459
 
                              commit.Commit(config=config).commit,
 
465
                              commit.Commit(config_stack=config).commit,
460
466
                              message="base",
461
467
                              allow_pointless=True,
462
468
                              rev_id='B',
477
483
        bzrlib.ahook = called
478
484
        try:
479
485
            config = BranchWithHooks(branch)
480
 
            commit.Commit(config=config).commit(
 
486
            commit.Commit(config_stack=config).commit(
481
487
                            message = "base",
482
488
                            allow_pointless=True,
483
489
                            rev_id='A', working_tree = wt)