Issue1178

Title Push over HTTP: ValueError: invalid literal for int()
Priority bug Status resolved
Superseder Nosy List djc, pmezard, specmurt, tonfa
Assigned To Topics patch, ui

Created on 2008-06-12.23:02:53 by specmurt, last changed 2008-09-09.09:48:31 by djc.

Messages
msg7010 (view) Author: djc Date: 2008-09-09.09:48:31
See also issue1250, which is now the issue for stdout/stderr writing from hgweb.

Resolving this now.
msg7000 (view) Author: djc Date: 2008-09-08.12:47:47
Well, this is exemplary of all the problems with hg writing to stderr/stdout
while serving a WSGI request, when it really shouldn't be... We could make this
issue the poster child for such problems?
msg6999 (view) Author: tonfa Date: 2008-09-08.12:44:16
in crew (9141bebefe3e)

can this be closed ? do we need something else ?
msg6991 (view) Author: djc Date: 2008-09-08.09:57:09
Yeah, that would be a good start, IMO.
msg6981 (view) Author: tonfa Date: 2008-09-07.12:03:10
This would make the output better

diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py
--- a/mercurial/httprepo.py
+++ b/mercurial/httprepo.py
@@ -422,16 +422,18 @@
         fp = httpsendfile(tempname, "rb")
         try:
             try:
-                rfp = self.do_cmd(
-                    'unbundle', data=fp,
-                    headers={'Content-Type': 'application/octet-stream'},
-                    heads=' '.join(map(hex, heads)))
+                resp = self.do_read(
+                     'unbundle', data=fp,
+                     headers={'Content-Type': 'application/octet-stream'},
+                     heads=' '.join(map(hex, heads)))
+                resp_code, output = resp.split('\n', 1)
                 try:
-                    ret = int(rfp.readline())
-                    self.ui.write(rfp.read())
-                    return ret
-                finally:
-                    rfp.close()
+                    ret = int(resp_code)
+                except ValueError, err:
+                    raise util.UnexpectedOutput(
+                            _('push failed (unexpected response):'), resp)
+                self.ui.write(output)
+                return ret
             except socket.error, err:
                 if err[0] in (errno.ECONNRESET, errno.EPIPE):
                     raise util.Abort(_('push failed: %s') % err[1])
msg6278 (view) Author: specmurt Date: 2008-06-14.08:10:53
No hook and today I've actualy figured out why it was happening. It happens when
hgwebdir.cgi script doesn't have write access to the directory parent of .hg on
the server. In my example it's project1 directory. However error message is
cryptic an doesn't show you where the problem is. You may close the issue though.
msg6272 (view) Author: pmezard Date: 2008-06-13.11:30:48
Do you have a server side hook ?
msg6270 (view) Author: specmurt Date: 2008-06-12.23:02:52
I am running hgwebdir.cgi from the same version of HG as a Windows client. When
I try to push the simple change set I get this error.
==================================
C:\Projects\project1>hg --version
Mercurial Distributed SCM (version 1.0.1+20080525)

Copyright (C) 2005-2008 Matt Mackall <mpm@selenic.com> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
==================================
C:\Projects\project1>hg push --traceback
pushing to http://hg.eneset.com/private/projects/project1
http authorization required
realm: Eneset Technology Pty Ltd Private HG Repository
user: username
password:
real URL is http://hg.eneset.com/private/projects/project1/
searching for changes
Traceback (most recent call last):
  File "mercurial\dispatch.pyc", line 45, in _runcatch
  File "mercurial\dispatch.pyc", line 364, in _dispatch
  File "mercurial\dispatch.pyc", line 417, in _runcommand
  File "mercurial\dispatch.pyc", line 373, in checkargs
  File "mercurial\dispatch.pyc", line 356, in <lambda>
  File "mercurial\commands.pyc", line 2098, in push
  File "mercurial\localrepo.pyc", line 1498, in push
  File "mercurial\localrepo.pyc", line 1578, in push_unbundle
  File "mercurial\httprepo.pyc", line 429, in unbundle
ValueError: invalid literal for int() with base 10: '<?xml version="1.0" encodin
g="ANSI_X3.4-1968"?>\n'
** unknown exception encountered, details follow
** report bug details to http://www.selenic.com/mercurial/bts
** or mercurial@selenic.com
** Mercurial Distributed SCM (version 1.0.1+20080525)
Traceback (most recent call last):
  File "hg", line 20, 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 364, in _dispatch
  File "mercurial\dispatch.pyc", line 417, in _runcommand
  File "mercurial\dispatch.pyc", line 373, in checkargs
  File "mercurial\dispatch.pyc", line 356, in <lambda>
  File "mercurial\commands.pyc", line 2098, in push
  File "mercurial\localrepo.pyc", line 1498, in push
  File "mercurial\localrepo.pyc", line 1578, in push_unbundle
  File "mercurial\httprepo.pyc", line 429, in unbundle
ValueError: invalid literal for int() with base 10: '<?xml version="1.0" encodin
g="ANSI_X3.4-1968"?>\n'
History
Date User Action Args
2008-09-09 09:48:31djcsetstatus: chatting -> resolved
nosy: tonfa, pmezard, djc, specmurt
messages: + msg7010
2008-09-08 12:47:47djcsetnosy: tonfa, pmezard, djc, specmurt
messages: + msg7000
2008-09-08 12:44:16tonfasetnosy: tonfa, pmezard, djc, specmurt
messages: + msg6999
2008-09-08 09:57:09djcsetnosy: + djc
messages: + msg6991
2008-09-07 12:03:12tonfasettopic: + ui, patch
nosy: + tonfa
messages: + msg6981
2008-06-14 08:10:54specmurtsetnosy: pmezard, specmurt
messages: + msg6278
2008-06-13 11:30:53pmezardsetstatus: unread -> chatting
nosy: + pmezard
messages: + msg6272
2008-06-12 23:02:53specmurtcreate