~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

  • Committer: Martin Packman
  • Date: 2012-01-05 10:44:12 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6427.
  • Revision ID: martin.packman@canonical.com-20120105104412-z03fi9m43h946fvs
Merge bzr.dev to resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
# TODO: Test commit with some added, and added-but-missing files
46
46
 
47
 
class MustSignConfig(config.Stack):
 
47
class MustSignConfig(config.MemoryStack):
48
48
 
49
 
    def __init__(self, branch):
50
 
        store = config.IniFileStore()
51
 
        store._load_from_string('''
 
49
    def __init__(self):
 
50
        super(MustSignConfig, self).__init__('''
52
51
gpg_signing_command=cat -
53
52
create_signatures=always
54
53
''')
55
 
        super(MustSignConfig, self).__init__([store.get_sections])
56
 
        # FIXME: Strictly speaking we should fallback to the no-name section in
57
 
        # branch.conf but no tests need that so far -- vila 2011-12-14
58
 
 
59
 
 
60
 
class BranchWithHooks(config.Stack):
61
 
 
62
 
    def __init__(self, branch):
63
 
        store = config.IniFileStore()
64
 
        store._load_from_string('post_commit=bzrlib.ahook bzrlib.ahook')
65
 
        super(BranchWithHooks, self).__init__([store.get_sections])
66
 
        # FIXME: Strictly speaking we should fallback to the no-name section in
67
 
        # branch.conf but no tests need that so far -- vila 2011-12-14
68
54
 
69
55
 
70
56
class CapturingReporter(NullCommitReporter):
439
425
            from bzrlib.testament import Testament
440
426
            # monkey patch gpg signing mechanism
441
427
            bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
442
 
            commit.Commit(config_stack=MustSignConfig(branch)
443
 
                          ).commit(message="base", allow_pointless=True,
444
 
                                   rev_id='B', working_tree=wt)
 
428
            conf = config.MemoryStack('''
 
429
gpg_signing_command=cat -
 
430
create_signatures=always
 
431
''')
 
432
            commit.Commit(config_stack=conf).commit(
 
433
                message="base", allow_pointless=True, rev_id='B',
 
434
                working_tree=wt)
445
435
            def sign(text):
446
436
                return bzrlib.gpg.LoopbackGPGStrategy(None).sign(text)
447
437
            self.assertEqual(sign(Testament.from_revision(branch.repository,
461
451
        try:
462
452
            # monkey patch gpg signing mechanism
463
453
            bzrlib.gpg.GPGStrategy = bzrlib.gpg.DisabledGPGStrategy
464
 
            config = MustSignConfig(branch)
 
454
            conf = config.MemoryStack('''
 
455
gpg_signing_command=cat -
 
456
create_signatures=always
 
457
''')
465
458
            self.assertRaises(SigningFailed,
466
 
                              commit.Commit(config_stack=config).commit,
 
459
                              commit.Commit(config_stack=conf).commit,
467
460
                              message="base",
468
461
                              allow_pointless=True,
469
462
                              rev_id='B',
483
476
            calls.append('called')
484
477
        bzrlib.ahook = called
485
478
        try:
486
 
            config = BranchWithHooks(branch)
487
 
            commit.Commit(config_stack=config).commit(
488
 
                            message = "base",
489
 
                            allow_pointless=True,
490
 
                            rev_id='A', working_tree = wt)
 
479
            conf = config.MemoryStack('post_commit=bzrlib.ahook bzrlib.ahook')
 
480
            commit.Commit(config_stack=conf).commit(
 
481
                message = "base", allow_pointless=True, rev_id='A',
 
482
                working_tree = wt)
491
483
            self.assertEqual(['called', 'called'], calls)
492
484
        finally:
493
485
            del bzrlib.ahook