Created on 2010-01-05.17:30:39 by jan1972, last changed 2010-02-15.21:18:15 by tonfa.
| msg11392 (view) |
Author: jan1972 |
Date: 2010-01-06.07:39:41 |
|
BTW, with respect to the limitations of the HTTP protocol, I don't really
care whether the external hook script should write its error messages to
stdout rather than to stderr.
All I would like is to be able to tell the user something more meaningful than:
abort: pretxnchangegroup.checkMerge hook exited with status 3
|
| msg11390 (view) |
Author: jan1972 |
Date: 2010-01-06.07:27:39 |
|
Matt & Steve, thanks to the both of you for your answers so far!
I am using version 1.4+20091117 (and the matching TortoiseHg 0.9, although
it is completely unrelated to ToirtoiseHg as stated earlier.... the best
proof being that using the command line interface yields the same behaviour).
Excuse my asking, but whatever the patch one might well do in the module
supporting the HTTP protocol I really cannot see how one can possibly grab
the stderr of an external process launched by Python's subprocess.call() in
mercurial/hook.py. Could you explain shortly why this behaviour is
"intended, correct and standard"?
Again, I am talking about "external program" hooks (a.k.a. shell script)
here (so I am assuming that mercurial.hook._exthook() is getting called
here, not mercurial.hook._pythonhook().
Why not use one of the many popen variations instead and redirect stderr to
a file-like object which would write to ui?
Many thanks in advance
Best regards
|
| msg11386 (view) |
Author: mpm |
Date: 2010-01-05.18:57:32 |
|
I see, your problem is related to http.
We're not going to change the stderr behavior for local hooks. It's
intended, correct, and standard.
Http usage presents other difficulties, as there's no side path analogous to
stderr available in either http or our changegroup protocol. However, we've
had a patch in place since around 1.0 to capture such messages:
http://www.selenic.com/hg/rev/be76e54570f0
What version are you using?
|
| msg11385 (view) |
Author: sborho |
Date: 2010-01-05.18:05:53 |
|
TortoiseHg, as of version 0.9, captures stderr output from hooks and
displays it in the output dialog. What version are you using?
His suggested workaround would be in mercurial/hook.py.
|
| msg11384 (view) |
Author: jan1972 |
Date: 2010-01-05.17:57:00 |
|
Nothing specific to TortoiseHg: it is related to the fact that I am using an
external hook.
BTW, if you try a hook on a local repo, there is nothing wrong in having the
script dump to stderr directly. The issue is when you push to a remote repo
(http in my case) which runs the 'pretxnchangegroup' hook and wants to
forbid the push for a reason or another. That reason is not displayed to the
user.
|
| msg11383 (view) |
Author: mpm |
Date: 2010-01-05.17:51:10 |
|
This seems to be specific to TortoiseHG?
|
| msg11382 (view) |
Author: jan1972 |
Date: 2010-01-05.17:30:38 |
|
When running an external hook, the file hook.py uses util.system(), which,
in turn, uses subprocess.call().
This loses track of anything printed by the hook as an error message and the
end user is left alone with an error code.
Shouldn't it use popen instead and redirect sys.stderr to ui.write() ??
This is the way SVN hooks works and its very valuable.
PS:
A workaround would be to use internal hooks in which a reference to the ui
is provided, but I don't want to go down that route for several reasons:
1. To ease the install process, our Windows boxes use the standard
TortoiseHg installer and therefore don't use our Python version already
installed elsewhere
2. Besides the function in the 'commands' module, there is no real API
(which is guaranteed to work in future releases... or to be deprecated slowly)
|
|
| Date |
User |
Action |
Args |
| 2010-02-15 21:18:15 | tonfa | set | nosy:
+ cyanite |
| 2010-02-05 17:41:19 | mpm | set | status: need-eg -> chatting nosy:
mpm, sborho, abuehl, jan1972 title: Cannot provide an error message in external hooks -> Cannot provide an error message in external hooks over http |
| 2010-01-06 07:39:42 | jan1972 | set | nosy:
mpm, sborho, abuehl, jan1972 messages:
+ msg11392 |
| 2010-01-06 07:27:39 | jan1972 | set | nosy:
mpm, sborho, abuehl, jan1972 messages:
+ msg11390 |
| 2010-01-05 18:57:32 | mpm | set | nosy:
mpm, sborho, abuehl, jan1972 messages:
+ msg11386 |
| 2010-01-05 18:08:25 | abuehl | set | nosy:
+ abuehl |
| 2010-01-05 18:05:53 | sborho | set | nosy:
mpm, sborho, jan1972 messages:
+ msg11385 |
| 2010-01-05 17:57:00 | jan1972 | set | nosy:
mpm, sborho, jan1972 messages:
+ msg11384 |
| 2010-01-05 17:51:10 | mpm | set | status: unread -> need-eg nosy:
+ mpm, sborho messages:
+ msg11383 |
| 2010-01-05 17:30:39 | jan1972 | create | |
|