Commit Graph

148 Commits

Author SHA1 Message Date
Augie Fackler
9c414eb57e httprepo: send 100-continue on POSTs if using http2 2011-05-02 12:10:50 -05:00
Augie Fackler
33ebd50b83 url: use new http support if requested by the user
The new http library is wired in via an extra module
(httpconnection.py), as it requires similar but different plumbing to
connect the library to Mercurial's internals and urllib2. Eventualy we
should be able to remove all of keepalive.py and its associated tangle
in url.py and replace it all with the code in httpconnection.py.

To use the new library, set 'ui.usehttp2' to true. The underlying http
library uses the logging module liberally, so if things break you can
use 'ui.http2debuglevel' to set the log level to INFO or DEBUG to get
that logging information (for example, ui.http2debuglevel=info.)
2011-05-06 10:22:08 -05:00
Mads Kiilerich
aec14e75e6 httprepo: proper handling of invalid responses without content-type (issue2019)
This can currently be tested on http://sf.net/
2011-03-07 14:47:30 +01:00
Mads Kiilerich
e24ddf937d httprepo: use the original exception after falling back to static-http failed
Before the fine exception handling in httprepo was never shown.

The static-http exception will now only be shown when static-http is requested
explicitly.
2011-03-07 22:50:55 +01:00
Matt Mackall
89ec131e91 http: minor tweaks to long arg handling
x-arg -> x-hgarg
replace itertools.count(1)
2011-05-01 03:51:04 -05:00
Steven Brown
c1075f3880 httprepo: long arguments support (issue2126)
Send the command arguments in the HTTP headers. The command is still part
of the URL. If the server does not have the 'httpheader' capability, the
client will send the command arguments in the URL as it did previously.

Web servers typically allow more data to be placed within the headers than
in the URL, so this approach will:
- Avoid HTTP errors due to using a URL that is too large.
- Allow Mercurial to implement a more efficient wire protocol.

An alternate approach is to send the arguments as part of the request body.
This approach has been rejected because it requires the use of POST
requests, so it would break any existing configuration that relies on the
request type for authentication or caching.

Extensibility:
- The header size is provided by the server, which makes it possible to
  introduce an hgrc setting for it.
- The client ignores the capability value after the first comma, which
  allows more information to be included in the future.
2011-05-01 01:04:37 +08:00
Brodie Rao
b7f0d2a103 url: move URL parsing functions into util to improve startup time
The introduction of the new URL parsing code has created a startup
time regression. This is mainly due to the use of url.hasscheme() in
the ui class. It ends up importing many libraries that the url module
requires.

This fix helps marginally, but if we can get rid of the urllib import
in the URL parser all together, startup time will go back to normal.

perfstartup time before the URL refactoring (707e4b1e8064):

! wall 0.050692 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)

current startup time (9ad1dce9e7f4):

! wall 0.070685 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)

after this change:

! wall 0.064667 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)
2011-04-30 09:43:20 -07:00
Benoit Boissinot
a8923ec73f bundle: more comments about the different header types, remove useless if 2011-04-30 14:22:03 +02:00
Brodie Rao
de32ed5320 httprepo/sshrepo: use url.url
Like the previous patch to getauthinfo(), this also makes
username/password parsing more forgiving for SSH URLs.

This also opens up the possibility of allowing non-numeric ports,
since the URL parser has no problem handling them.

Related issues:

- issue851: @ in password in http url
- issue2055: nonnumeric port bug with https protocol
2011-03-30 20:01:35 -07:00
Peter Arrenbrecht
fec6de2003 httprepo: use caps instead of between for compat check
We usually query the capabilities at some point anyway so this way the first roundtrip
actually does useful work.
2011-03-12 18:29:02 +01:00
Steven Brown
41ef0052ee httprepo: order URL query string fields for readability
- cmd is always first, since the other fields are arguments to that command.
- The other fields are in alphabetical order, rather than random order.

example "hg serve" output
BEFORE
127.0.0.1 - - [26/Feb/2011 14:20:07] "GET /?bases=fa5962be1d87fe9a57244a14033550e192e57521+1a38f137b190482eaf0986594cd6e6b486c76fec&cmd=changegroupsubset&heads=1a38f137b190482eaf0986594cd6e6b486c76fec+fa5962be1d87fe9a57244a14033550e192e57521 HTTP/1.1" 200 -
127.0.0.1 - - [26/Feb/2011 14:00:50] "GET /?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between HTTP/1.1" 200 -
127.0.0.1 - - [26/Feb/2011 14:17:28] "GET /?nodes=1a38f137b190482eaf0986594cd6e6b486c76fec+fa5962be1d87fe9a57244a14033550e192e57521&cmd=branches HTTP/1.1" 200 -

AFTER
127.0.0.1 - - [26/Feb/2011 14:21:28] "GET /?cmd=changegroupsubset&bases=fa5962be1d87fe9a57244a14033550e192e57521+1a38f137b190482eaf0986594cd6e6b486c76fec&heads=1a38f137b190482eaf0986594cd6e6b486c76fec+fa5962be1d87fe9a57244a14033550e192e57521 HTTP/1.1" 200 -
127.0.0.1 - - [26/Feb/2011 13:48:13] "GET /?cmd=between&pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000 HTTP/1.1" 200 -
127.0.0.1 - - [26/Feb/2011 14:19:17] "GET /?cmd=branches&nodes=1a38f137b190482eaf0986594cd6e6b486c76fec+fa5962be1d87fe9a57244a14033550e192e57521 HTTP/1.1" 200 -
2011-03-07 15:37:11 +08:00
Augie Fackler
ae84cccfbf httpsendfile: record progress information during read()
This allows us to provide deterministic progress information during
transfer of bundle data over HTTP. This is required because we
currently buffer the bundle data to local disk prior to transfer since
wsgiref lacks chunked transfer-coding support.
2010-12-10 13:31:06 -06:00
Dan Villiom Podlaski Christiansen
8612617f1e httprepo: remove is-comparison with string literal
An identity check between a variable and a string literal was added to
the pushkey implementation in c77f1a86a050. While CPython will
normally intern strings and thus make the test safe, value identity is
what should be used here.
2010-11-16 21:35:58 +01:00
Matt Mackall
509a829041 pushkey: force HTTP POST on push and add tests (issue2489) 2010-11-12 01:21:45 -06:00
Brodie Rao
203cf2fbd9 cleanup: remove unused imports 2010-08-27 13:32:38 -04:00
Matt Mackall
c0eb9c1315 Merge with stable 2010-08-06 12:59:13 -05:00
Matt Mackall
cc6b733d1e httprepo: decompress stream incrementally to reduce memory usage 2010-08-05 16:17:39 -05:00
Matt Mackall
d46a89387f protocol: unify client unbundle support
- introduce _callpush helper
- factor out differences in result handling into helpers
- unify
2010-07-14 17:12:18 -05:00
Matt Mackall
8c936882a2 protocol: unify client changegroup methods 2010-07-14 17:09:31 -05:00
Matt Mackall
a91ad01089 protocol: clean up call-like functions in http and ssh clients 2010-07-14 17:07:10 -05:00
Matt Mackall
60b140435c protocol: unify stream_out client code 2010-07-14 16:55:44 -05:00
Matt Mackall
fcb8f496e2 protocol: unify basic http client requests 2010-07-14 16:35:51 -05:00
Renato Cunha
b6d6b8775c removed exception args indexing (not supported by py3k)
Py3k removed __getitem__ for exception classes. The correct way of
getting the exception arguments is by using the args method.
2010-07-14 23:03:21 -03:00
Matt Mackall
d8e0a2188b pushkey: add http support
pushkey requires the same permissions as push
listitems requires the same permissions as pull
2010-06-16 16:05:19 -05:00
Greg Ward
89bd117131 push: document return values between various repo methods.
This starts at localrepository.push() and seeps down to
push_addchangegroup(), push_unbundle(), prepush(), addchangegroup(),
and leaks out to sshrepository.unbundle(), sshrepository.addchangegroup(),
and httprepository.unbundle().  Seems to cover everything you ever
wanted to know about pushing but were afraid to ask.
2010-05-02 21:56:25 -04:00
Sune Foldager
155fe1239e httprepo: normalize output from unbundle with ssh
Lines from the remote are prefixed with 'remote: ' and written
locally using ui.status, similar to what sshrepo does.
2010-02-24 12:35:26 -05:00
Sune Foldager
320624e3e5 httprepo: send Content-Type instead of content-type 2010-02-22 23:12:12 -05:00
Sune Foldager
7964a5e927 httprepo: use content-type application/mercurial-0.1 for POST
Previously, application/octet-stream was used. The content-type is
currently ignored by the server.
2010-02-22 16:28:57 +01:00
Benoit Boissinot
bb6f91a4eb http: len(x) fails if it doesn't fit into an int, use __len__() instead
len(x) raises OverflowError if it's bigger than 2**31-1, we need to call
__len__() ourself instead.
2010-02-17 11:00:48 +01:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
cd3ef170f7 Merge with stable 2010-01-19 22:45:09 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Sune Foldager
a2d25fc09b branchmap: fix defective fallback fix a3d9c67908ca
The fix applied as a3d9c67908ca doesn't work and is essentially a no-op.
This fix also adds a comment about the nature of the problem, and a test.
2009-11-18 15:20:08 +01:00
Henrik Stuart
1d4d06ceca support encoding fallback in branchmap to maintain compatibility with 1.3.x 2009-11-16 13:35:36 +01:00
Jesse Glick
7656a30c59 Sometimes pushing to an HTTP repo fails with a useless message.
abort: 'https://.../.../' does not appear to be an hg repository!

Ought to produce a better diagnostics on the client. With patched 1.3.1,
observed to produce an Apache HTML error message (from cgitb) including the
vital text:

  File ".../hgwebdir.cgi", line 70, in ?
    wsgicgi.launch(application)
  File "mercurial/hgweb/wsgicgi.py", line 68, in launch
  File "mercurial/hgweb/hgwebdir_mod.py", line 91, in __call__
  File "mercurial/hgweb/hgwebdir_mod.py", line 148, in run_wsgi
  File "mercurial/hgweb/hgweb_mod.py", line 100, in run_wsgi
  File "mercurial/hgweb/protocol.py", line 156, in unbundle
  File "mercurial/localrepo.py", line 2031, in addchangegroup
  File "mercurial/revlog.py", line 1204, in addgroup
LookupError: 00manifest.i@......: unknown parent

Might also be helpful if server's hgweb_mod.run_wsgi caught unexpected errors
and returned a well-formed error response including the stack trace. The client
patch would still be useful in this case, because it would let you diagnose
issues with HTTP proxy servers and so on.
2009-10-17 14:00:41 -04:00
Martin Geisler
9f1896c083 do not attempt to translate ui.debug output 2009-09-19 01:15:38 +02:00
Henrik Stuart
a4975b3627 named branches: client branchmap wire protocol support (issue736)
Co-contributor: Sune Foldager <cryo@cyanite.org>
2009-05-23 17:03:51 +02:00
Steve Borho
01beb4abff httprepo: always store the response url (issue1968)
Fixes a regression caused by e52456aeb2b0
2010-01-05 10:20:28 -06:00
Dan Villiom Podlaski Christiansen
892998bd5c httprepo: suppress the `real URL is...' message in safe, common cases.
When the actual and requested URL only differ by trailing slashes,
there is no need to warn. As an example, this easily happens when
accessing repositories on Bitbucket over HTTP(S).

As far as I could tell, there were no existing tests for this
behaviour.
2009-11-18 12:47:58 +01:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Matt Mackall
de487eacda ui: print_exc() -> traceback() 2009-04-26 16:50:44 -05:00
Martin Geisler
1deb417a82 util: use built-in set and frozenset
This drops Python 2.3 compatibility.
2009-04-22 00:55:32 +02:00
Patrick Mezard
6e39e5470b Merge with crew-stable 2009-04-13 14:36:55 +02:00
Patrick Mezard
b41a06764a httprepo: hide password in debug traces too 2009-04-13 14:33:47 +02:00
Steve Borho
7d99d0a5a5 hide passwords in httprepo error messages 2009-04-11 18:34:21 -05:00
Martin Geisler
2d9bab6890 httprepo: lowercase debug output 2009-03-29 21:52:43 +02:00
Steve Borho
506abe9706 close sockets on httprepository deletion (issue1487)
With this destructor in place, I no longer see tracebacks
on the server after using win32 clients for pull, push, etc.
2009-01-28 20:06:59 -06:00
Matt Mackall
534da54d07 error: move UnexpectedOutput (now ResponseError) 2009-01-12 11:28:28 -06:00
Matt Mackall
e0735a1762 error: move repo errors
rename NoCapability to CapabilityError
2009-01-12 10:42:31 -06:00