59
59
('post_commit', local_base, master.base, old_revno, old_revid,
60
60
new_revno, new_revid, local_locked, master.is_locked()))
62
def capture_pre_commit_hook(self, local, master, old_revno, old_revid,
63
new_revno, new_revid, deleted, added, tree):
64
self.hook_calls.append(('pre_commit', old_revno, old_revid,
65
new_revno, new_revid, deleted, added))
62
67
def test_post_commit_to_origin(self):
63
68
tree = self.make_branch_and_memory_tree('branch')
64
69
Branch.hooks.install_hook('post_commit',
121
def test_pre_commit_passes(self):
122
tree = self.make_branch_and_memory_tree('branch')
125
Branch.hooks.install_hook("pre_commit", self.capture_pre_commit_hook)
126
revid1 = tree.commit('first revision')
127
revid2 = tree.commit('second revision')
129
('pre_commit', 0, NULL_REVISION, 1, revid1, [], []),
130
('pre_commit', 1, revid1, 2, revid2, [], [])
135
def test_pre_commit_fails(self):
136
tree = self.make_branch_and_memory_tree('branch')
139
class PreCommitException(Exception): pass
140
def hook_func(_1, _2, _3, _4, _5, new_revid, _7, _8, _9):
141
raise PreCommitException(new_revid)
142
Branch.hooks.install_hook("pre_commit", self.capture_pre_commit_hook)
143
Branch.hooks.install_hook("pre_commit", hook_func)
144
revids = [None, None, None]
146
tree.commit('message')
147
except PreCommitException, e:
148
revids[0] = e.message
149
Branch.hooks["pre_commit"] = []
150
Branch.hooks.install_hook("pre_commit", self.capture_pre_commit_hook)
151
for i in range(1, 3):
152
revids[i] = tree.commit('third revision')
154
('pre_commit', 0, NULL_REVISION, 1, revids[0], [], []),
155
('pre_commit', 0, NULL_REVISION, 1, revids[1], [], []),
156
('pre_commit', 1, revids[1], 2, revids[2], [], [])
161
def test_pre_commit_paths(self):
162
tree = self.make_branch_and_memory_tree('branch')
165
tree.add('file', 'bang')
166
tree.put_file_bytes_non_atomic('bang', 'die')
167
tree.mkdir('dir', 'dirid')
168
tree.add('dir/file', 'swoosh')
169
tree.put_file_bytes_non_atomic('swoosh', 'swaash')
170
Branch.hooks.install_hook("pre_commit", self.capture_pre_commit_hook)
171
rev1 = tree.commit('first revision')
172
tree.unversion(['dirid'])
173
rev2 = tree.commit('second revision')
175
('pre_commit', 0, NULL_REVISION, 1, rev1, [], ['dir', 'dir/file', 'file']),
176
('pre_commit', 1, rev1, 2, rev2, ['dir', 'dir/file'], [])