Show More
@@ -278,7 +278,6 b' def hook(ui, repo, hooktype, node=None, ' | |||||
278 | for id in ids: |
|
278 | for id in ids: | |
279 | bz.update(id, bin_node, changes) |
|
279 | bz.update(id, bin_node, changes) | |
280 | bz.notify(ids) |
|
280 | bz.notify(ids) | |
281 | return True |
|
|||
282 | except MySQLdb.MySQLError, err: |
|
281 | except MySQLdb.MySQLError, err: | |
283 | raise util.Abort(_('database error: %s') % err[1]) |
|
282 | raise util.Abort(_('database error: %s') % err[1]) | |
284 |
|
283 |
@@ -255,4 +255,3 b' def hook(ui, repo, hooktype, node=None, ' | |||||
255 | n.node(node) |
|
255 | n.node(node) | |
256 | n.diff(node) |
|
256 | n.diff(node) | |
257 | n.send(node, count) |
|
257 | n.send(node, count) | |
258 | return True |
|
@@ -78,8 +78,12 b' class localrepository(object):' | |||||
78 | def callhook(hname, funcname): |
|
78 | def callhook(hname, funcname): | |
79 | '''call python hook. hook is callable object, looked up as |
|
79 | '''call python hook. hook is callable object, looked up as | |
80 | name in python module. if callable returns "true", hook |
|
80 | name in python module. if callable returns "true", hook | |
81 |
|
|
81 | fails, else passes. if hook raises exception, treated as | |
82 |
hook failure. exception propagates if throw is "true". |
|
82 | hook failure. exception propagates if throw is "true". | |
|
83 | ||||
|
84 | reason for "true" meaning "hook failed" is so that | |||
|
85 | unmodified commands (e.g. mercurial.commands.update) can | |||
|
86 | be run as hooks without wrappers to convert return values.''' | |||
83 |
|
87 | |||
84 | self.ui.note(_("calling hook %s: %s\n") % (hname, funcname)) |
|
88 | self.ui.note(_("calling hook %s: %s\n") % (hname, funcname)) | |
85 | d = funcname.rfind('.') |
|
89 | d = funcname.rfind('.') | |
@@ -119,11 +123,11 b' class localrepository(object):' | |||||
119 | raise |
|
123 | raise | |
120 | if self.ui.traceback: |
|
124 | if self.ui.traceback: | |
121 | traceback.print_exc() |
|
125 | traceback.print_exc() | |
122 |
return |
|
126 | return True | |
123 |
if |
|
127 | if r: | |
124 | if throw: |
|
128 | if throw: | |
125 | raise util.Abort(_('%s hook failed') % hname) |
|
129 | raise util.Abort(_('%s hook failed') % hname) | |
126 |
self.ui.warn(_(' |
|
130 | self.ui.warn(_('warning: %s hook failed\n') % hname) | |
127 | return r |
|
131 | return r | |
128 |
|
132 | |||
129 | def runhook(name, cmd): |
|
133 | def runhook(name, cmd): | |
@@ -135,19 +139,18 b' class localrepository(object):' | |||||
135 | desc, r = util.explain_exit(r) |
|
139 | desc, r = util.explain_exit(r) | |
136 | if throw: |
|
140 | if throw: | |
137 | raise util.Abort(_('%s hook %s') % (name, desc)) |
|
141 | raise util.Abort(_('%s hook %s') % (name, desc)) | |
138 |
self.ui.warn(_(' |
|
142 | self.ui.warn(_('warning: %s hook %s\n') % (name, desc)) | |
139 |
|
|
143 | return r | |
140 | return True |
|
|||
141 |
|
144 | |||
142 |
r = |
|
145 | r = False | |
143 | hooks = [(hname, cmd) for hname, cmd in self.ui.configitems("hooks") |
|
146 | hooks = [(hname, cmd) for hname, cmd in self.ui.configitems("hooks") | |
144 | if hname.split(".", 1)[0] == name and cmd] |
|
147 | if hname.split(".", 1)[0] == name and cmd] | |
145 | hooks.sort() |
|
148 | hooks.sort() | |
146 | for hname, cmd in hooks: |
|
149 | for hname, cmd in hooks: | |
147 | if cmd.startswith('python:'): |
|
150 | if cmd.startswith('python:'): | |
148 |
r = callhook(hname, cmd[7:].strip()) |
|
151 | r = callhook(hname, cmd[7:].strip()) or r | |
149 | else: |
|
152 | else: | |
150 |
r = runhook(hname, cmd) |
|
153 | r = runhook(hname, cmd) or r | |
151 | return r |
|
154 | return r | |
152 |
|
155 | |||
153 | def tags(self): |
|
156 | def tags(self): |
@@ -100,14 +100,13 b' def printargs(args):' | |||||
100 | print 'hook args:' |
|
100 | print 'hook args:' | |
101 | for k, v in a: |
|
101 | for k, v in a: | |
102 | print ' ', k, v |
|
102 | print ' ', k, v | |
103 | return True |
|
|||
104 |
|
103 | |||
105 | def passhook(**args): |
|
104 | def passhook(**args): | |
106 | printargs(args) |
|
105 | printargs(args) | |
107 | return True |
|
|||
108 |
|
106 | |||
109 | def failhook(**args): |
|
107 | def failhook(**args): | |
110 | printargs(args) |
|
108 | printargs(args) | |
|
109 | return True | |||
111 |
|
110 | |||
112 | class LocalException(Exception): |
|
111 | class LocalException(Exception): | |
113 | pass |
|
112 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now