##// END OF EJS Templates
hooks: use python 2.4 compatible exception handling
Lee Cantey -
r14916:58f97dcb stable
parent child Browse files
Show More
@@ -65,26 +65,27 b' def _pythonhook(ui, repo, name, hname, f'
65 65 '("%s" is not callable)') %
66 66 (hname, funcname))
67 67 try:
68 # redirect IO descriptors the the ui descriptors so hooks that write
69 # directly to these don't mess the command protocol when running through
70 # the command server
71 old = sys.stdout, sys.stderr, sys.stdin
72 sys.stdout, sys.stderr, sys.stdin = ui.fout, ui.ferr, ui.fin
68 try:
69 # redirect IO descriptors the the ui descriptors so hooks
70 # that write directly to these don't mess up the command
71 # protocol when running through the command server
72 old = sys.stdout, sys.stderr, sys.stdin
73 sys.stdout, sys.stderr, sys.stdin = ui.fout, ui.ferr, ui.fin
73 74
74 r = obj(ui=ui, repo=repo, hooktype=name, **args)
75 except KeyboardInterrupt:
76 raise
77 except Exception, exc:
78 if isinstance(exc, util.Abort):
79 ui.warn(_('error: %s hook failed: %s\n') %
80 (hname, exc.args[0]))
81 else:
82 ui.warn(_('error: %s hook raised an exception: '
83 '%s\n') % (hname, exc))
84 if throw:
75 r = obj(ui=ui, repo=repo, hooktype=name, **args)
76 except KeyboardInterrupt:
85 77 raise
86 ui.traceback()
87 return True
78 except Exception, exc:
79 if isinstance(exc, util.Abort):
80 ui.warn(_('error: %s hook failed: %s\n') %
81 (hname, exc.args[0]))
82 else:
83 ui.warn(_('error: %s hook raised an exception: '
84 '%s\n') % (hname, exc))
85 if throw:
86 raise
87 ui.traceback()
88 return True
88 89 finally:
89 90 sys.stdout, sys.stderr, sys.stdin = old
90 91 if r:
General Comments 0
You need to be logged in to leave comments. Login now