Mercurial > hg-stable
annotate mercurial/httprepo.py @ 2465:c91118f425d0
push over http: client support.
stream bundle data using PUT request.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Tue, 20 Jun 2006 15:17:28 -0700 |
parents | cd00531ecc16 |
children | 4e78dc71d946 |
rev | line source |
---|---|
1089 | 1 # httprepo.py - HTTP repository proxy classes for mercurial |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
2 # |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
3 # Copyright 2005 Matt Mackall <mpm@selenic.com> |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
4 # |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
6 # of the GNU General Public License, incorporated herein by reference. |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
7 |
1089 | 8 from node import * |
9 from remoterepo import * | |
1400
cf9a1233738a
i18n first part: make '_' available for files who need it
Benoit Boissinot <benoit.boissinot@ens-lyon.org
parents:
1377
diff
changeset
|
10 from i18n import gettext as _ |
1251
84cf8834efb5
Fix lots of exception-related problems.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1089
diff
changeset
|
11 from demandload import * |
2015
1a09814a5b1f
Catch HTTPException when reading from remote http repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1870
diff
changeset
|
12 demandload(globals(), "hg os urllib urllib2 urlparse zlib util httplib") |
2465
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
13 demandload(globals(), "keepalive tempfile socket") |
926 | 14 |
2447
cd00531ecc16
httprepo: make "http://user:pass@host/" urls work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2446
diff
changeset
|
15 class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): |
2281
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
16 def __init__(self, ui): |
2447
cd00531ecc16
httprepo: make "http://user:pass@host/" urls work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2446
diff
changeset
|
17 urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self) |
2281
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
18 self.ui = ui |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
19 |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
20 def find_user_password(self, realm, authuri): |
2447
cd00531ecc16
httprepo: make "http://user:pass@host/" urls work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2446
diff
changeset
|
21 authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password( |
2281
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
22 self, realm, authuri) |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
23 if authinfo != (None, None): |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
24 return authinfo |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
25 |
2446
1b2bbb2b4911
httprepo: fix small bug in authentication.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
26 if not self.ui.interactive: |
2337
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
27 raise util.Abort(_('http authorization required')) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
28 |
2281
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
29 self.ui.write(_("http authorization required\n")) |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
30 self.ui.status(_("realm: %s\n") % realm) |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
31 user = self.ui.prompt(_("user:"), default=None) |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
32 passwd = self.ui.getpass() |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
33 |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
34 self.add_password(realm, authuri, user, passwd) |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
35 return (user, passwd) |
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
36 |
2337
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
37 def netlocsplit(netloc): |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
38 '''split [user[:passwd]@]host[:port] into 4-tuple.''' |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
39 |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
40 a = netloc.find('@') |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
41 if a == -1: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
42 user, passwd = None, None |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
43 else: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
44 userpass, netloc = netloc[:a], netloc[a+1:] |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
45 c = userpass.find(':') |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
46 if c == -1: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
47 user, passwd = urllib.unquote(userpass), None |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
48 else: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
49 user = urllib.unquote(userpass[:c]) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
50 passwd = urllib.unquote(userpass[c+1:]) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
51 c = netloc.find(':') |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
52 if c == -1: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
53 host, port = netloc, None |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
54 else: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
55 host, port = netloc[:c], netloc[c+1:] |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
56 return host, port, user, passwd |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
57 |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
58 def netlocunsplit(host, port, user=None, passwd=None): |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
59 '''turn host, port, user, passwd into [user[:passwd]@]host[:port].''' |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
60 if port: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
61 hostport = host + ':' + port |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
62 else: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
63 hostport = host |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
64 if user: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
65 if passwd: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
66 userpass = urllib.quote(user) + ':' + urllib.quote(passwd) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
67 else: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
68 userpass = urllib.quote(user) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
69 return userpass + '@' + hostport |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
70 return hostport |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
71 |
2465
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
72 class httpconnection(keepalive.HTTPConnection): |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
73 # must be able to send big bundle as stream. |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
74 |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
75 def send(self, data): |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
76 if isinstance(data, str): |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
77 keepalive.HTTPConnection.send(self, data) |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
78 else: |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
79 # if auth required, some data sent twice, so rewind here |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
80 data.seek(0) |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
81 for chunk in util.filechunkiter(data): |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
82 keepalive.HTTPConnection.send(self, chunk) |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
83 |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
84 class httphandler(keepalive.HTTPHandler): |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
85 def http_open(self, req): |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
86 return self.do_open(httpconnection, req) |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
87 |
926 | 88 class httprepository(remoterepository): |
60 | 89 def __init__(self, ui, path): |
2442
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
90 self.caps = None |
2337
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
91 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
92 if query or frag: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
93 raise util.Abort(_('unsupported URL component: "%s"') % |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
94 (query or frag)) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
95 if not urlpath: urlpath = '/' |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
96 host, port, user, passwd = netlocsplit(netloc) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
97 |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
98 # urllib cannot handle URLs with embedded user or passwd |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
99 self.url = urlparse.urlunsplit((scheme, netlocunsplit(host, port), |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
100 urlpath, '', '')) |
60 | 101 self.ui = ui |
2337
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
102 |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
103 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
104 proxyauthinfo = None |
2465
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
105 handler = httphandler() |
2337
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
106 |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
107 if proxyurl: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
108 # proxy can be proper url or host[:port] |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
109 if not (proxyurl.startswith('http:') or |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
110 proxyurl.startswith('https:')): |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
111 proxyurl = 'http://' + proxyurl + '/' |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
112 snpqf = urlparse.urlsplit(proxyurl) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
113 proxyscheme, proxynetloc, proxypath, proxyquery, proxyfrag = snpqf |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
114 hpup = netlocsplit(proxynetloc) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
115 |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
116 proxyhost, proxyport, proxyuser, proxypasswd = hpup |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
117 if not proxyuser: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
118 proxyuser = ui.config("http_proxy", "user") |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
119 proxypasswd = ui.config("http_proxy", "passwd") |
515 | 120 |
2337
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
121 # see if we should use a proxy for this url |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
122 no_list = [ "localhost", "127.0.0.1" ] |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
123 no_list.extend([p.strip().lower() for |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
124 p in ui.config("http_proxy", "no", '').split(',') |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
125 if p.strip()]) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
126 no_list.extend([p.strip().lower() for |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
127 p in os.getenv("no_proxy", '').split(',') |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
128 if p.strip()]) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
129 # "http_proxy.always" config is for running tests on localhost |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
130 if (not ui.configbool("http_proxy", "always") and |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
131 host.lower() in no_list): |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
132 ui.debug(_('disabling proxy for %s\n') % host) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
133 else: |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
134 proxyurl = urlparse.urlunsplit(( |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
135 proxyscheme, netlocunsplit(proxyhost, proxyport, |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
136 proxyuser, proxypasswd or ''), |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
137 proxypath, proxyquery, proxyfrag)) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
138 handler = urllib2.ProxyHandler({scheme: proxyurl}) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
139 ui.debug(_('proxying through %s\n') % proxyurl) |
321 | 140 |
2337
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
141 # urllib2 takes proxy values from the environment and those |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
142 # will take precedence if found, so drop them |
424
9294dce4b633
Allow override of HTTP_PROXY, http_proxy and no_proxy; make no_proxy work.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
385
diff
changeset
|
143 for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]: |
859
6390c377a9e6
Trap OSError when deleting env vars
Edouard Gomez <ed.gomez@free.fr>
parents:
856
diff
changeset
|
144 try: |
6390c377a9e6
Trap OSError when deleting env vars
Edouard Gomez <ed.gomez@free.fr>
parents:
856
diff
changeset
|
145 if os.environ.has_key(env): |
6390c377a9e6
Trap OSError when deleting env vars
Edouard Gomez <ed.gomez@free.fr>
parents:
856
diff
changeset
|
146 del os.environ[env] |
6390c377a9e6
Trap OSError when deleting env vars
Edouard Gomez <ed.gomez@free.fr>
parents:
856
diff
changeset
|
147 except OSError: |
6390c377a9e6
Trap OSError when deleting env vars
Edouard Gomez <ed.gomez@free.fr>
parents:
856
diff
changeset
|
148 pass |
321 | 149 |
2337
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
150 passmgr = passwordmgr(ui) |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
151 if user: |
2447
cd00531ecc16
httprepo: make "http://user:pass@host/" urls work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2446
diff
changeset
|
152 ui.debug(_('will use user %s, password %s for http auth\n') % |
cd00531ecc16
httprepo: make "http://user:pass@host/" urls work
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2446
diff
changeset
|
153 (user, '*' * len(passwd))) |
2337
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
154 passmgr.add_password(None, host, user, passwd or '') |
321 | 155 |
2337
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
156 opener = urllib2.build_opener( |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
157 handler, |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
158 urllib2.HTTPBasicAuthHandler(passmgr), |
3f24bc5dee81
http: fix many problems with url parsing and auth. added proxy test.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2336
diff
changeset
|
159 urllib2.HTTPDigestAuthHandler(passmgr)) |
2281
7761597b5da3
prompt user for http authentication info
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2015
diff
changeset
|
160 |
1359
51ac9a79f3e5
Set the user agent for httprepo communication
Matt Mackall <mpm@selenic.com>
parents:
1251
diff
changeset
|
161 # 1.0 here is the _protocol_ version |
51ac9a79f3e5
Set the user agent for httprepo communication
Matt Mackall <mpm@selenic.com>
parents:
1251
diff
changeset
|
162 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] |
321 | 163 urllib2.install_opener(opener) |
60 | 164 |
2442
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
165 # look up capabilities only when needed |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
166 |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
167 def get_caps(self): |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
168 if self.caps is None: |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
169 try: |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
170 self.caps = self.do_read('capabilities').split() |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
171 except hg.RepoError: |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
172 self.caps = () |
2465
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
173 self.ui.debug(_('capabilities: %s\n') % |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
174 (' '.join(self.caps or ['none']))) |
2442
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
175 return self.caps |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
176 |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
177 capabilities = property(get_caps) |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
178 |
634
da5378d39269
Add a repo method to report repo device
Matt Mackall <mpm@selenic.com>
parents:
627
diff
changeset
|
179 def dev(self): |
da5378d39269
Add a repo method to report repo device
Matt Mackall <mpm@selenic.com>
parents:
627
diff
changeset
|
180 return -1 |
da5378d39269
Add a repo method to report repo device
Matt Mackall <mpm@selenic.com>
parents:
627
diff
changeset
|
181 |
1870
8a8ab47cccde
make push over http print good error message.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
182 def lock(self): |
8a8ab47cccde
make push over http print good error message.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
183 raise util.Abort(_('operation not supported over http')) |
8a8ab47cccde
make push over http print good error message.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
184 |
60 | 185 def do_cmd(self, cmd, **args): |
2465
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
186 data = args.pop('data', None) |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
187 headers = args.pop('headers', {}) |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
188 self.ui.debug(_("sending %s command\n") % cmd) |
60 | 189 q = {"cmd": cmd} |
190 q.update(args) | |
191 qs = urllib.urlencode(q) | |
192 cu = "%s?%s" % (self.url, qs) | |
2294
ce67fa312f61
Catch urllib's HTTPException and give a meaningful error message to the user.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2281
diff
changeset
|
193 try: |
2465
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
194 resp = urllib2.urlopen(urllib2.Request(cu, data, headers)) |
2294
ce67fa312f61
Catch urllib's HTTPException and give a meaningful error message to the user.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2281
diff
changeset
|
195 except httplib.HTTPException, inst: |
2336
f77edcffb837
http: print better error if exception happens.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2294
diff
changeset
|
196 self.ui.debug(_('http error while sending %s command\n') % cmd) |
f77edcffb837
http: print better error if exception happens.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2294
diff
changeset
|
197 self.ui.print_exc() |
f77edcffb837
http: print better error if exception happens.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2294
diff
changeset
|
198 raise IOError(None, inst) |
2435
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
199 try: |
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
200 proto = resp.getheader('content-type') |
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
201 except AttributeError: |
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
202 proto = resp.headers['content-type'] |
752 | 203 |
753 | 204 # accept old "text/plain" and "application/hg-changegroup" for now |
205 if not proto.startswith('application/mercurial') and \ | |
206 not proto.startswith('text/plain') and \ | |
207 not proto.startswith('application/hg-changegroup'): | |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
208 raise hg.RepoError(_("'%s' does not appear to be an hg repository") % |
1251
84cf8834efb5
Fix lots of exception-related problems.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1089
diff
changeset
|
209 self.url) |
752 | 210 |
753 | 211 if proto.startswith('application/mercurial'): |
212 version = proto[22:] | |
213 if float(version) > 0.1: | |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
214 raise hg.RepoError(_("'%s' uses newer protocol %s") % |
1251
84cf8834efb5
Fix lots of exception-related problems.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1089
diff
changeset
|
215 (self.url, version)) |
753 | 216 |
752 | 217 return resp |
60 | 218 |
2435
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
219 def do_read(self, cmd, **args): |
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
220 fp = self.do_cmd(cmd, **args) |
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
221 try: |
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
222 return fp.read() |
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
223 finally: |
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
224 # if using keepalive, allow connection to be reused |
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
225 fp.close() |
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
226 |
222 | 227 def heads(self): |
2435
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
228 d = self.do_read("heads") |
222 | 229 try: |
230 return map(bin, d[:-1].split(" ")) | |
231 except: | |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
232 self.ui.warn(_("unexpected response:\n") + d[:400] + "\n...\n") |
222 | 233 raise |
234 | |
60 | 235 def branches(self, nodes): |
236 n = " ".join(map(hex, nodes)) | |
2435
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
237 d = self.do_read("branches", nodes=n) |
217 | 238 try: |
239 br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] | |
240 return br | |
241 except: | |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
242 self.ui.warn(_("unexpected response:\n") + d[:400] + "\n...\n") |
217 | 243 raise |
60 | 244 |
245 def between(self, pairs): | |
246 n = "\n".join(["-".join(map(hex, p)) for p in pairs]) | |
2435
ff2bac730b99
http client: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2337
diff
changeset
|
247 d = self.do_read("between", pairs=n) |
217 | 248 try: |
249 p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] | |
250 return p | |
251 except: | |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
252 self.ui.warn(_("unexpected response:\n") + d[:400] + "\n...\n") |
217 | 253 raise |
60 | 254 |
1736
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1402
diff
changeset
|
255 def changegroup(self, nodes, kind): |
60 | 256 n = " ".join(map(hex, nodes)) |
752 | 257 f = self.do_cmd("changegroup", roots=n) |
192 | 258 bytes = 0 |
635
85e2209d401c
Protocol switch from using generators to stream-like objects.
Matt Mackall <mpm@selenic.com>
parents:
634
diff
changeset
|
259 |
1376
524ca4a06f70
Fix same performance bug as c3654cfaa77 but for httprepo.py instead.
Eric Hopper <hopper@omnifarious.org>
parents:
1359
diff
changeset
|
260 def zgenerator(f): |
524ca4a06f70
Fix same performance bug as c3654cfaa77 but for httprepo.py instead.
Eric Hopper <hopper@omnifarious.org>
parents:
1359
diff
changeset
|
261 zd = zlib.decompressobj() |
2015
1a09814a5b1f
Catch HTTPException when reading from remote http repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1870
diff
changeset
|
262 try: |
1a09814a5b1f
Catch HTTPException when reading from remote http repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1870
diff
changeset
|
263 for chnk in f: |
1a09814a5b1f
Catch HTTPException when reading from remote http repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1870
diff
changeset
|
264 yield zd.decompress(chnk) |
1a09814a5b1f
Catch HTTPException when reading from remote http repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1870
diff
changeset
|
265 except httplib.HTTPException, inst: |
1a09814a5b1f
Catch HTTPException when reading from remote http repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1870
diff
changeset
|
266 raise IOError(None, _('connection ended unexpectedly')) |
1376
524ca4a06f70
Fix same performance bug as c3654cfaa77 but for httprepo.py instead.
Eric Hopper <hopper@omnifarious.org>
parents:
1359
diff
changeset
|
267 yield zd.flush() |
635
85e2209d401c
Protocol switch from using generators to stream-like objects.
Matt Mackall <mpm@selenic.com>
parents:
634
diff
changeset
|
268 |
1376
524ca4a06f70
Fix same performance bug as c3654cfaa77 but for httprepo.py instead.
Eric Hopper <hopper@omnifarious.org>
parents:
1359
diff
changeset
|
269 return util.chunkbuffer(zgenerator(util.filechunkiter(f))) |
635
85e2209d401c
Protocol switch from using generators to stream-like objects.
Matt Mackall <mpm@selenic.com>
parents:
634
diff
changeset
|
270 |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2435
diff
changeset
|
271 def unbundle(self, cg, heads, source): |
2465
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
272 # have to stream bundle to a temp file because we do not have |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
273 # http 1.1 chunked transfer. |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
274 |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
275 fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-') |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
276 fp = os.fdopen(fd, 'wb+') |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
277 try: |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
278 for chunk in util.filechunkiter(cg): |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
279 fp.write(chunk) |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
280 length = fp.tell() |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
281 rfp = self.do_cmd( |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
282 'unbundle', data=fp, |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
283 headers={'content-length': length, |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
284 'content-type': 'application/octet-stream'}, |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
285 heads=' '.join(map(hex, heads))) |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
286 try: |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
287 ret = int(rfp.readline()) |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
288 self.ui.write(rfp.read()) |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
289 return ret |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
290 finally: |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
291 rfp.close() |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
292 finally: |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
293 fp.close() |
c91118f425d0
push over http: client support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2447
diff
changeset
|
294 os.unlink(tempname) |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2435
diff
changeset
|
295 |
923 | 296 class httpsrepository(httprepository): |
297 pass |