~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

  • Committer: Aaron Bentley
  • Date: 2006-11-27 16:14:24 UTC
  • mto: This revision was merged to the branch mainline in revision 2155.
  • Revision ID: abentley@panoramicfeedback.com-20061127161424-kc3b780vnb6tm6yk
Updates from review comments

Show diffs side-by-side

added added

removed removed

Lines of Context:
339
339
            from bzrlib.testament import Testament
340
340
            # monkey patch gpg signing mechanism
341
341
            bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
342
 
            commit.Commit(config=MustSignConfig(branch)).commit(
343
 
                message_callback=lambda: "base", allow_pointless=True,
344
 
                rev_id='B', working_tree=wt)
 
342
            commit.Commit(config=MustSignConfig(branch)).commit(message="base",
 
343
                                                      allow_pointless=True,
 
344
                                                      rev_id='B',
 
345
                                                      working_tree=wt)
345
346
            self.assertEqual(Testament.from_revision(branch.repository,
346
347
                             'B').as_short_text(),
347
348
                             branch.repository.get_signature_text('B'))
384
385
        try:
385
386
            config = BranchWithHooks(branch)
386
387
            commit.Commit(config=config).commit(
387
 
                            message_callback=lambda: "base",
 
388
                            message = "base",
388
389
                            allow_pointless=True,
389
390
                            rev_id='A', working_tree = wt)
390
391
            self.assertEqual(['called', 'called'], calls)
395
396
        # using the Commit object directly does not set the branch nick.
396
397
        wt = self.make_branch_and_tree('.')
397
398
        c = Commit()
398
 
        c.commit(working_tree=wt, message_callback=lambda:'empty tree', 
399
 
                 allow_pointless=True)
 
399
        c.commit(working_tree=wt, message='empty tree', allow_pointless=True)
400
400
        self.assertEquals(wt.branch.revno(), 1)
401
401
        self.assertEqual({},
402
402
                         wt.branch.repository.get_revision(
564
564
            self.called = False
565
565
            self.message = message
566
566
 
567
 
        def __call__(self):
 
567
        def __call__(self, commit_builder):
568
568
            self.called = True
569
569
            return self.message
570
570
 
576
576
            tree.commit()
577
577
        except Exception, e:
578
578
            self.assertTrue(isinstance(e, BzrError))
579
 
            self.assertEqual('The message_callback keyword parameter is'
580
 
                             ' required for commit().', str(e))
 
579
            self.assertEqual('The message or message_callback keyword'
 
580
                             ' parameter is required for commit().', str(e))
581
581
        else:
582
582
            self.fail('exception not raised')
583
 
        cb = self.Callback('commit 1')
 
583
        cb = self.Callback(u'commit 1')
584
584
        tree.commit(message_callback=cb)
585
585
        self.assertTrue(cb.called)
586
586
        repository = tree.branch.repository
590
590
    def test_no_callback_pointless(self):
591
591
        """Callback should not be invoked for pointless commit"""
592
592
        tree = self.make_branch_and_tree('.')
593
 
        cb = self.Callback('commit 2')
 
593
        cb = self.Callback(u'commit 2')
594
594
        self.assertRaises(PointlessCommit, tree.commit, message_callback=cb, 
595
595
                          allow_pointless=False)
596
596
        self.assertFalse(cb.called)
597
597
 
598
598
    def test_no_callback_netfailure(self):
599
599
        """Callback should not be invoked if connectivity fails"""
 
600
        tree = self.make_branch_and_tree('.')
 
601
        cb = self.Callback(u'commit 2')
 
602
        repository = tree.branch.repository
600
603
        # simulate network failure
601
 
        tree = self.make_branch_and_tree('.')
602
604
        def raise_(self, arg, arg2):
603
605
            raise errors.NoSuchFile('foo')
604
 
        cb = self.Callback('commit 2')
605
 
        repository = tree.branch.repository
606
606
        repository.add_inventory = raise_
607
607
        self.assertRaises(errors.NoSuchFile, tree.commit, message_callback=cb)
608
608
        self.assertFalse(cb.called)