[Bug 5282] New: http wire protocol doesn't gracefully handle unbundle commands with bundle2 without a replycaps part

mercurial-bugs at selenic.com mercurial-bugs at selenic.com
Tue Jun 28 00:56:27 EDT 2016


https://bz.mercurial-scm.org/show_bug.cgi?id=5282

            Bug ID: 5282
           Summary: http wire protocol doesn't gracefully handle unbundle
                    commands with bundle2 without a replycaps part
           Product: Mercurial
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: UNCONFIRMED
          Severity: feature
          Priority: wish
         Component: hgweb
          Assignee: bugzilla at selenic.com
          Reporter: mh+hg at glandium.org
                CC: mercurial-devel at selenic.com

As I'm doing an independent implementation of the wire protocol, I've hit an
interesting problem that is not exposed by mercurial itself, because it always
sends a replycaps part.

When sending a bundle2 without a replycaps part over http, the push actually
works, but from the client POV, fails with an internal server error:

$ hg init h
$ cd h
$ echo a > a
$ hg commit -A -m a
adding a
committing files:
a
committing manifest
committing changelog
committed changeset 0:5221ed28c448
$ hg bundle -a /tmp/bundle.hg
1 changesets found
$ cd ..
$ hg init h2
$ hg --config web.push_ssl=false --config web.allow_push=* -R h2 serve
listening at http://localhost:8000/ (bound to *:8000)
$ (echo "POST /?cmd=unbundle&heads=0000000000000000000000000000000000000000
HTTP/1.1"; echo Content-Type: application/mercurial-0.1; echo Content-Length:
$(stat -c %s /tmp/bundle.hg); echo; cat /tmp/bundle.hg) | nc localhost 8000
HTTP/1.1 500 Internal Server Error
Server: BaseHTTP/0.3 Python/2.7.12rc1
Date: Tue, 28 Jun 2016 04:39:24 GMT
Transfer-Encoding: chunked

15
Internal Server Error
0

$ hg -R h2 log -T {node}
5221ed28c448b254622436fb8e0da299dedeeefa


The error on the hg serve end looks like the following:
127.0.0.1 - - [28/Jun/2016 13:39:24] Exception happened during processing
request '/?cmd=unbundle&heads=0000000000000000000000000000000000000000':
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/server.py", line 99,
in do_POST
    self.do_write()
  File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/server.py", line 92,
in do_write
    self.do_hgweb()
  File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/server.py", line 160,
in do_hgweb
    for chunk in self.server.application(env, self._start_response):
  File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/hgweb_mod.py", line
308, in run_wsgi
    for r in self._runwsgi(req, repo):
  File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/hgweb_mod.py", line
348, in _runwsgi
    return protocol.call(rctx.repo, req, cmd)
  File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/protocol.py", line
104, in call
    rsp = '%d\n%s' % (rsp.res, val)
TypeError: %d format: a number is required, not NoneType


The "same" works with the stdio wire protocol (which is what is used through
ssh):
$ hg init h3
$ (echo unbundle; echo heads 40; echo
0000000000000000000000000000000000000000$(stat -c %s /tmp/bundle.hg); cat
/tmp/bundle.hg; echo 0) | hg -R h3 serve --stdio
0
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
0
4
None
$ hg -R h3 log -T {node}
5221ed28c448b254622436fb8e0da299dedeeefa

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list