Issue706

Title hooks shouldn't interfere with the wire protocol
Priority bug Status resolved
Superseder Nosy List ThomasAH, alexis, djc, kupfer, sborho
Assigned To Topics

Created on 2007-08-23.21:45:43 by sborho, last changed 2008-03-24.23:41:09 by djc.

Messages
msg5717 (view) Author: djc Date: 2008-03-24.23:41:09
Setting this to resolved. Specific other problems should probably be reported
separately.
msg5705 (view) Author: djc Date: 2008-03-23.22:53:40
The redirection for ssh and http servers was implemented in 323b9c55b328.

It seems like some of these problems still persist, though.
msg3929 (view) Author: alexis Date: 2007-08-28.23:31:40
The basic problem is that when hg talks to a remote repo (over ssh or HTTP), it
uses stdin and stdout for its protocol.  If a hook prints something to stdout it
can mess things up.

A quick workaround is to redirect the output of your hook to stderr:

[hooks]
changegroup = pull-diffstat 1>&2

I'm renaming this issue to make it more general.  We'll probably have to
redirect the stdout from hooks to stderr - at least if we're the server in a
ssh/HTTP connection, but it may be easier to just do this every time.
msg3905 (view) Author: sborho Date: 2007-08-23.21:45:41
When pushing to a Linux box with a diffstat hook enabled:

[hooks]
changegroup = pull-diffstat

I get the following backtrace:

C:\hg\hg-release\.hg\patches>hg push
pushing to ssh://steve@trixy/tools/mq-win32-hg-plus
searching for changes
** unknown exception encountered, details follow
** report bug details to http://www.selenic.com/mercurial/bts
** or mercurial@selenic.com
** Mercurial Distributed SCM (version 6bc09d998af2)
Traceback (most recent call last):
  File "hg", line 25, in <module>
  File "mercurial\dispatch.pyc", line 20, in run
  File "mercurial\dispatch.pyc", line 29, in dispatch
  File "mercurial\dispatch.pyc", line 45, in _runcatch
  File "mercurial\dispatch.pyc", line 348, in _dispatch
  File "mercurial\dispatch.pyc", line 401, in _runcommand
  File "mercurial\dispatch.pyc", line 357, in checkargs
  File "mercurial\dispatch.pyc", line 340, in <lambda>
  File "mercurial\commands.pyc", line 2125, in push
  File "hgext\mq.pyc", line 2072, in push
  File "mercurial\localrepo.pyc", line 1381, in push
  File "mercurial\localrepo.pyc", line 1461, in push_unbundle
  File "mercurial\sshrepo.pyc", line 199, in unbundle
ValueError: invalid literal for int() with base 10: 'diffstat for e89549c2e8e7 t
o f159b5091958\n'
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 4 changes to 4 files

The push succeeded, regardless of the error message.  This seems to be
independent of the ssh client I use, and it happens whether I push a
normal repo or a patch queue repo.

% hg version
Mercurial Distributed SCM (version bbdcdc7f170e)
History
Date User Action Args
2008-03-24 23:41:09djcsetstatus: testing -> resolved
nosy: ThomasAH, sborho, alexis, kupfer, djc
messages: + msg5717
2008-03-24 14:41:57mpmlinkissue1048 superseder
2008-03-23 22:54:22djcsetstatus: chatting -> testing
nosy: ThomasAH, sborho, alexis, kupfer, djc
2008-03-23 22:53:41djcsetnosy: ThomasAH, sborho, alexis, kupfer, djc
messages: + msg5705
2008-03-23 22:48:47djcsetnosy: + djc
2008-02-14 18:12:10ThomasAHsetnosy: + ThomasAH
2007-10-18 22:41:00kupfersetnosy: + kupfer
2007-08-28 23:31:41alexissetstatus: unread -> chatting
nosy: + alexis
messages: + msg3929
title: Backtrace when pushing to repo with diffstat hook -> hooks shouldn't interfere with the wire protocol
2007-08-23 21:45:43sborhocreate