~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2008-05-02 02:31:14 UTC
  • mfrom: (3399 +trunk)
  • mto: (3408.1.1 doc)
  • mto: This revision was merged to the branch mainline in revision 3409.
  • Revision ID: mbp@sourcefrog.net-20080502023114-y2gcg3w3jc770j9m
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
    def test_set_rh_empty_history(self):
39
39
        branch = self.make_branch('source')
40
 
        Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
 
40
        Branch.hooks.install_named_hook('set_rh', self.capture_set_rh_hook,
 
41
                                        None)
41
42
        branch.set_revision_history([])
42
43
        self.assertEqual(self.hook_calls,
43
44
            [('set_rh', branch, [], True)])
50
51
        tree.commit('empty commit', rev_id='foo')
51
52
        tree.unlock()
52
53
        branch = tree.branch
53
 
        Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
 
54
        Branch.hooks.install_named_hook('set_rh', self.capture_set_rh_hook,
 
55
                                        None)
54
56
        # some branches require that their history be set to a revision in the
55
57
        # repository
56
58
        branch.set_revision_history(['f\xc2\xb5'])
59
61
 
60
62
    def test_set_rh_branch_is_locked(self):
61
63
        branch = self.make_branch('source')
62
 
        Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
 
64
        Branch.hooks.install_named_hook('set_rh', self.capture_set_rh_hook,
 
65
                                        None)
63
66
        branch.set_revision_history([])
64
67
        self.assertEqual(self.hook_calls,
65
68
            [('set_rh', branch, [], True)])
66
69
 
67
70
    def test_set_rh_calls_all_hooks_no_errors(self):
68
71
        branch = self.make_branch('source')
69
 
        Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
70
 
        Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
 
72
        Branch.hooks.install_named_hook('set_rh', self.capture_set_rh_hook,
 
73
                                        None)
 
74
        Branch.hooks.install_named_hook('set_rh', self.capture_set_rh_hook,
 
75
                                        None)
71
76
        branch.set_revision_history([])
72
77
        self.assertEqual(self.hook_calls,
73
78
            [('set_rh', branch, [], True),
92
97
 
93
98
    def test_post_change_branch_tip_empty_history(self):
94
99
        branch = self.make_branch('source')
95
 
        Branch.hooks.install_hook('post_change_branch_tip',
96
 
                                  self.capture_post_change_branch_tip_hook)
 
100
        Branch.hooks.install_named_hook(
 
101
            'post_change_branch_tip',
 
102
            self.capture_post_change_branch_tip_hook,
 
103
            None)
97
104
        branch.set_last_revision_info(0, NULL_REVISION)
98
105
        self.assertEqual(len(self.hook_calls), 1)
99
106
        self.assertEqual(self.hook_calls[0][0].branch, branch)
110
117
        tree.commit('empty commit', rev_id='foo')
111
118
        tree.unlock()
112
119
        branch = tree.branch
113
 
        Branch.hooks.install_hook('post_change_branch_tip',
114
 
                                  self.capture_post_change_branch_tip_hook)
 
120
        Branch.hooks.install_named_hook(
 
121
            'post_change_branch_tip',
 
122
            self.capture_post_change_branch_tip_hook,
 
123
            None)
115
124
        # some branches require that their history be set to a revision in the
116
125
        # repository
117
126
        branch.set_last_revision_info(1, 'f\xc2\xb5')
124
133
 
125
134
    def test_post_change_branch_tip_branch_is_locked(self):
126
135
        branch = self.make_branch('source')
127
 
        Branch.hooks.install_hook('post_change_branch_tip',
128
 
                                  self.capture_post_change_branch_tip_hook)
 
136
        Branch.hooks.install_named_hook(
 
137
            'post_change_branch_tip',
 
138
            self.capture_post_change_branch_tip_hook,
 
139
            None)
129
140
        branch.set_last_revision_info(0, NULL_REVISION)
130
141
        self.assertEqual(len(self.hook_calls), 1)
131
142
        self.assertEqual(self.hook_calls[0][0].branch, branch)
133
144
 
134
145
    def test_post_change_branch_tip_calls_all_hooks_no_errors(self):
135
146
        branch = self.make_branch('source')
136
 
        Branch.hooks.install_hook('post_change_branch_tip',
137
 
                                  self.capture_post_change_branch_tip_hook)
138
 
        Branch.hooks.install_hook('post_change_branch_tip',
139
 
                                  self.capture_post_change_branch_tip_hook)
 
147
        Branch.hooks.install_named_hook(
 
148
            'post_change_branch_tip',
 
149
            self.capture_post_change_branch_tip_hook,
 
150
            None)
 
151
        Branch.hooks.install_named_hook(
 
152
            'post_change_branch_tip',
 
153
            self.capture_post_change_branch_tip_hook,
 
154
            None)
140
155
        branch.set_last_revision_info(0, NULL_REVISION)
141
156
        self.assertEqual(len(self.hook_calls), 2)
142
157
        self.assertEqual(self.hook_calls[0][0].branch, branch)