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