~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_commit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-05-01 04:55:31 UTC
  • mfrom: (3394.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080501045531-3hkmq9qzoeequw1s
Add Hooks.install_named_hook (Daniel Watkins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
 
69
69
    def test_post_commit_to_origin(self):
70
70
        tree = self.make_branch_and_memory_tree('branch')
71
 
        Branch.hooks.install_hook('post_commit',
72
 
            self.capture_post_commit_hook)
 
71
        Branch.hooks.install_named_hook('post_commit',
 
72
            self.capture_post_commit_hook, None)
73
73
        tree.lock_write()
74
74
        tree.add('')
75
75
        revid = tree.commit('a revision')
90
90
        except errors.UpgradeRequired:
91
91
            # cant bind this format, the test is irrelevant.
92
92
            return
93
 
        Branch.hooks.install_hook('post_commit',
94
 
            self.capture_post_commit_hook)
 
93
        Branch.hooks.install_named_hook('post_commit',
 
94
            self.capture_post_commit_hook, None)
95
95
        tree.lock_write()
96
96
        tree.add('')
97
97
        revid = tree.commit('a revision')
108
108
        tree.lock_write()
109
109
        tree.add('')
110
110
        revid = tree.commit('first revision')
111
 
        Branch.hooks.install_hook('post_commit',
112
 
            self.capture_post_commit_hook)
 
111
        Branch.hooks.install_named_hook('post_commit',
 
112
            self.capture_post_commit_hook, None)
113
113
        revid2 = tree.commit('second revision')
114
114
        # having committed from up the branch, we should get the
115
115
        # before and after revnos and revids correctly.
127
127
        tree.lock_write()
128
128
        tree.add('')
129
129
        root_delta.added = [('', tree.path2id(''), 'directory')]
130
 
        Branch.hooks.install_hook("pre_commit", self.capture_pre_commit_hook)
 
130
        Branch.hooks.install_named_hook("pre_commit",
 
131
            self.capture_pre_commit_hook, None)
131
132
        revid1 = tree.commit('first revision')
132
133
        revid2 = tree.commit('second revision')
133
134
        self.assertEqual([
149
150
                      old_revno, old_revid, new_revno, new_revid,
150
151
                      tree_delta, future_tree):
151
152
            raise PreCommitException(new_revid)
152
 
        Branch.hooks.install_hook("pre_commit", self.capture_pre_commit_hook)
153
 
        Branch.hooks.install_hook("pre_commit", hook_func)
 
153
        Branch.hooks.install_named_hook("pre_commit",
 
154
            self.capture_pre_commit_hook, None)
 
155
        Branch.hooks.install_named_hook("pre_commit", hook_func, None)
154
156
        revids = [None, None, None]
155
157
        # this commit will raise an exception
156
158
        # so the commit is rolled back and revno unchanged
160
162
        # unregister all pre_commit hooks
161
163
        Branch.hooks["pre_commit"] = []
162
164
        # and re-register the capture hook
163
 
        Branch.hooks.install_hook("pre_commit", self.capture_pre_commit_hook)
 
165
        Branch.hooks.install_named_hook("pre_commit",
 
166
            self.capture_pre_commit_hook, None)
164
167
        # now these commits should go through
165
168
        for i in range(1, 3):
166
169
            revids[i] = tree.commit('message')
199
202
            tree.unversion(['to_be_unversioned_id'])
200
203
            tree.mkdir('added_dir', 'added_dir_id')
201
204
            # start to capture pre_commit delta
202
 
            Branch.hooks.install_hook("pre_commit", self.capture_pre_commit_hook)
 
205
            Branch.hooks.install_named_hook("pre_commit",
 
206
                self.capture_pre_commit_hook, None)
203
207
            revid2 = tree.commit('second revision')
204
208
        finally:
205
209
            tree.unlock()