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

  • Committer: Jonathan Lange
  • Date: 2009-12-09 09:20:42 UTC
  • mfrom: (4881 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4907.
  • Revision ID: jml@canonical.com-20091209092042-s2zgqcf8f39yzxpj
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                           UnsupportedOperation)
35
35
from bzrlib.osutils import pathjoin, getcwd
36
36
from bzrlib.tests import TestCase
37
 
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
 
37
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
38
38
from bzrlib.trace import mutter
39
39
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
40
40
                                WorkingTree)
49
49
        self.depth = 0
50
50
 
51
51
    def clear(self):
52
 
        """See progress.ProgressBar.clear()."""
 
52
        """See progress.ProgressTask.clear()."""
53
53
 
54
54
    def clear_term(self):
55
 
        """See progress.ProgressBar.clear_term()."""
 
55
        """See progress.ProgressTask.clear_term()."""
56
56
 
57
57
    def finished(self):
58
 
        """See progress.ProgressBar.finished()."""
 
58
        """See progress.ProgressTask.finished()."""
59
59
        self.depth -= 1
60
60
 
61
61
    def note(self, fmt_string, *args, **kwargs):
62
 
        """See progress.ProgressBar.note()."""
 
62
        """See progress.ProgressTask.note()."""
63
63
 
64
64
    def progress_bar(self):
65
65
        return self
69
69
        return self
70
70
 
71
71
    def update(self, message, count=None, total=None):
72
 
        """See progress.ProgressBar.update()."""
 
72
        """See progress.ProgressTask.update()."""
73
73
        if self.depth == 1:
74
74
            self._calls.append(("update", count, total, message))
75
75
 
280
280
        wt2.merge_from_branch(wt.branch)
281
281
        wt2.commit('merged kind change')
282
282
 
 
283
    def test_commit_aborted_does_not_apply_automatic_changes_bug_282402(self):
 
284
        wt = self.make_branch_and_tree('.')
 
285
        wt.add(['a'], ['a-id'], ['file'])
 
286
        def fail_message(obj):
 
287
            raise errors.BzrCommandError("empty commit message")
 
288
        self.assertRaises(errors.BzrCommandError, wt.commit,
 
289
            message_callback=fail_message)
 
290
        self.assertEqual('a', wt.id2path('a-id'))
 
291
 
283
292
    def test_local_commit_ignores_master(self):
284
293
        # a --local commit does not require access to the master branch
285
294
        # at all, or even for it to exist.
602
611
        revid = tree.commit('first post')
603
612
        committed_tree = tree.basis_tree()
604
613
        self.assertTrue(committed_tree.has_filename("newfile"))
 
614
 
 
615
    def test_post_commit_hook(self):
 
616
        """Make sure a post_commit hook is called after a commit."""
 
617
        def post_commit_hook_test_params(params):
 
618
            self.assertTrue(isinstance(params,
 
619
                mutabletree.PostCommitHookParams))
 
620
            self.assertTrue(isinstance(params.mutable_tree,
 
621
                mutabletree.MutableTree))
 
622
            open(tree.abspath("newfile"), 'w').write("data")
 
623
            params.mutable_tree.add(["newfile"])
 
624
        def restoreDefaults():
 
625
            mutabletree.MutableTree.hooks['post_commit'] = []
 
626
        self.addCleanup(restoreDefaults)
 
627
        tree = self.make_branch_and_tree('.')
 
628
        mutabletree.MutableTree.hooks.install_named_hook(
 
629
            'post_commit',
 
630
            post_commit_hook_test_params,
 
631
            None)
 
632
        self.assertFalse(tree.has_filename("newfile"))
 
633
        revid = tree.commit('first post')
 
634
        self.assertTrue(tree.has_filename("newfile"))
 
635
        committed_tree = tree.basis_tree()
 
636
        self.assertFalse(committed_tree.has_filename("newfile"))