Mercurial > hg
annotate mercurial/statichttprepo.py @ 52164:e01e84e5e426
rust-revlog: add a Rust-only `InnerRevlog`
This mirrors the Python `InnerRevlog` and will be used in a future patch
to replace said Python implementation. This allows us to start doing more
things in pure Rust, in particular reading and writing operations.
A lot of changes have to be introduced all at once, it wouldn't be very
useful to separate this patch IMO since all of them are either interlocked
or only useful with the rest.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Thu, 10 Oct 2024 10:34:51 +0200 |
parents | 6641a3ae8313 |
children | 7346f93be7a4 |
rev | line source |
---|---|
1101 | 1 # statichttprepo.py - simple http repository class for mercurial |
2 # | |
3 # This provides read-only repo access to repositories exported via static http | |
4 # | |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
46780
diff
changeset
|
5 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> |
1101 | 6 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
7873
diff
changeset
|
7 # This software may be used and distributed according to the terms of the |
10263 | 8 # GNU General Public License version 2 or any later version. |
1101 | 9 |
51863
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51826
diff
changeset
|
10 from __future__ import annotations |
25978
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
11 |
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
12 import errno |
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
13 |
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
14 from .i18n import _ |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
15 from .node import sha1nodeconstants |
25978
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
16 from . import ( |
41615
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41407
diff
changeset
|
17 branchmap, |
25978
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
18 changelog, |
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
19 error, |
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
20 localrepo, |
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
21 manifest, |
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
22 namespaces, |
34943
3423f7e2d287
statichttprepo: do not use platform path separator to build a URL
Yuya Nishihara <yuya@tcha.org>
parents:
33604
diff
changeset
|
23 pathutil, |
41407
6e9bebb65ce7
statichttprepo: use str to appease Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41406
diff
changeset
|
24 pycompat, |
48668
4a9570e389b2
share-safe: add support for static-http repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47225
diff
changeset
|
25 requirements as requirementsmod, |
25978
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
26 url, |
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
27 util, |
31241
591fda751c6b
vfs: use 'vfs' module directly in 'mercurial.statichttprepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31148
diff
changeset
|
28 vfs as vfsmod, |
25978
762f4c6df6b1
statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25670
diff
changeset
|
29 ) |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
30 from .utils import ( |
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
31 urlutil, |
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
32 ) |
1325
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
33 |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
27705
diff
changeset
|
34 urlerr = util.urlerr |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
27705
diff
changeset
|
35 urlreq = util.urlreq |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
27705
diff
changeset
|
36 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
37 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
38 class httprangereader: |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
39 def __init__(self, url, opener): |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
40 # we assume opener has HTTPRangeHandler |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
41 self.url = url |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
42 self.pos = 0 |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
43 self.opener = opener |
11066
26abd91d9e84
static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10263
diff
changeset
|
44 self.name = url |
27705
2380889f8f52
statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
45 |
2380889f8f52
statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
46 def __enter__(self): |
2380889f8f52
statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
47 return self |
2380889f8f52
statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
48 |
2380889f8f52
statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
49 def __exit__(self, exc_type, exc_value, traceback): |
2380889f8f52
statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
50 self.close() |
2380889f8f52
statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
51 |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
52 def seek(self, pos): |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
53 self.pos = pos |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
54 |
51900
77a9c7d8a7ba
statichttprepo: stop shadowing the `bytes` builtin
Matt Harbison <matt_harbison@yahoo.com>
parents:
51899
diff
changeset
|
55 def read(self, n: int = -1): |
41407
6e9bebb65ce7
statichttprepo: use str to appease Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41406
diff
changeset
|
56 req = urlreq.request(pycompat.strurl(self.url)) |
51899
e26a08563223
statichttprepo: fix `httprangereader.read()` for py3
Matt Harbison <matt_harbison@yahoo.com>
parents:
51898
diff
changeset
|
57 end = '' |
e26a08563223
statichttprepo: fix `httprangereader.read()` for py3
Matt Harbison <matt_harbison@yahoo.com>
parents:
51898
diff
changeset
|
58 |
51900
77a9c7d8a7ba
statichttprepo: stop shadowing the `bytes` builtin
Matt Harbison <matt_harbison@yahoo.com>
parents:
51899
diff
changeset
|
59 if n == 0: |
51899
e26a08563223
statichttprepo: fix `httprangereader.read()` for py3
Matt Harbison <matt_harbison@yahoo.com>
parents:
51898
diff
changeset
|
60 return b'' |
51900
77a9c7d8a7ba
statichttprepo: stop shadowing the `bytes` builtin
Matt Harbison <matt_harbison@yahoo.com>
parents:
51899
diff
changeset
|
61 elif n > 0: |
77a9c7d8a7ba
statichttprepo: stop shadowing the `bytes` builtin
Matt Harbison <matt_harbison@yahoo.com>
parents:
51899
diff
changeset
|
62 end = "%d" % (self.pos + n - 1) |
16882
a2d6e336e9cc
statichttprepo: don't send Range header when requesting entire file
Alexander Boyd <alex@opengroove.org>
parents:
16115
diff
changeset
|
63 if self.pos or end: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
64 req.add_header('Range', 'bytes=%d-%s' % (self.pos, end)) |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
65 |
1325
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
66 try: |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
67 f = self.opener.open(req) |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
68 data = f.read() |
25196
7a1af58ab242
statichttprepo: remove wrong getattr ladder
Augie Fackler <raf@durin42.com>
parents:
24377
diff
changeset
|
69 code = f.code |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
27705
diff
changeset
|
70 except urlerr.httperror as inst: |
6028
6605a03cbf87
make static-http work with empty repos (issue965)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5321
diff
changeset
|
71 num = inst.code == 404 and errno.ENOENT or None |
46202
5135b393884b
statichttprepo: explicitly convert error message to str (issue6247)
Joerg Sonnenberger <joerg@bec.de>
parents:
45434
diff
changeset
|
72 # Explicitly convert the exception to str as Py3 will try |
5135b393884b
statichttprepo: explicitly convert error message to str (issue6247)
Joerg Sonnenberger <joerg@bec.de>
parents:
45434
diff
changeset
|
73 # convert it to local encoding and with as the HTTPResponse |
5135b393884b
statichttprepo: explicitly convert error message to str (issue6247)
Joerg Sonnenberger <joerg@bec.de>
parents:
45434
diff
changeset
|
74 # instance doesn't support encode. |
5135b393884b
statichttprepo: explicitly convert error message to str (issue6247)
Joerg Sonnenberger <joerg@bec.de>
parents:
45434
diff
changeset
|
75 raise IOError(num, str(inst)) |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
27705
diff
changeset
|
76 except urlerr.urlerror as inst: |
41406
2bf689b13a17
statichttprepo: use URLError.reason directly
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41038
diff
changeset
|
77 raise IOError(None, inst.reason) |
1101 | 78 |
8612
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
79 if code == 200: |
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
80 # HTTPRangeHandler does nothing if remote does not support |
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
81 # Range headers and returns the full entity. Let's slice it. |
51900
77a9c7d8a7ba
statichttprepo: stop shadowing the `bytes` builtin
Matt Harbison <matt_harbison@yahoo.com>
parents:
51899
diff
changeset
|
82 if n > 0 and (self.pos + n) < len(data): |
77a9c7d8a7ba
statichttprepo: stop shadowing the `bytes` builtin
Matt Harbison <matt_harbison@yahoo.com>
parents:
51899
diff
changeset
|
83 data = data[self.pos : self.pos + n] |
51899
e26a08563223
statichttprepo: fix `httprangereader.read()` for py3
Matt Harbison <matt_harbison@yahoo.com>
parents:
51898
diff
changeset
|
84 elif self.pos < len(data): |
e26a08563223
statichttprepo: fix `httprangereader.read()` for py3
Matt Harbison <matt_harbison@yahoo.com>
parents:
51898
diff
changeset
|
85 data = data[self.pos :] |
8612
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
86 else: |
51899
e26a08563223
statichttprepo: fix `httprangereader.read()` for py3
Matt Harbison <matt_harbison@yahoo.com>
parents:
51898
diff
changeset
|
87 data = b'' |
51900
77a9c7d8a7ba
statichttprepo: stop shadowing the `bytes` builtin
Matt Harbison <matt_harbison@yahoo.com>
parents:
51899
diff
changeset
|
88 elif 0 < n < len(data): |
77a9c7d8a7ba
statichttprepo: stop shadowing the `bytes` builtin
Matt Harbison <matt_harbison@yahoo.com>
parents:
51899
diff
changeset
|
89 data = data[:n] |
8612
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
90 self.pos += len(data) |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
91 return data |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
92 |
20055
6bb9de1e4d16
statichttprepo.httprangeheader: implement readlines
Siddharth Agarwal <sid0@fb.com>
parents:
20054
diff
changeset
|
93 def readlines(self): |
6bb9de1e4d16
statichttprepo.httprangeheader: implement readlines
Siddharth Agarwal <sid0@fb.com>
parents:
20054
diff
changeset
|
94 return self.read().splitlines(True) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
95 |
11066
26abd91d9e84
static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10263
diff
changeset
|
96 def __iter__(self): |
20055
6bb9de1e4d16
statichttprepo.httprangeheader: implement readlines
Siddharth Agarwal <sid0@fb.com>
parents:
20054
diff
changeset
|
97 return iter(self.readlines()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
98 |
11066
26abd91d9e84
static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10263
diff
changeset
|
99 def close(self): |
26abd91d9e84
static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10263
diff
changeset
|
100 pass |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
101 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
102 |
36425
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
103 # _RangeError and _HTTPRangeHandler were originally in byterange.py, |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
104 # which was itself extracted from urlgrabber. See the last version of |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
105 # byterange.py from history if you need more information. |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
106 class _RangeError(IOError): |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
107 """Error raised when an unsatisfiable range is requested.""" |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
108 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
109 |
36425
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
110 class _HTTPRangeHandler(urlreq.basehandler): |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
111 """Handler that enables HTTP Range headers. |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
112 |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
113 This was extremely simple. The Range header is a HTTP feature to |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
114 begin with so all this class does is tell urllib2 that the |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
115 "206 Partial Content" response from the HTTP server is what we |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
116 expected. |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
117 """ |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
118 |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
119 def http_error_206(self, req, fp, code, msg, hdrs): |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
120 # 206 Partial Content Response |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
121 r = urlreq.addinfourl(fp, hdrs, req.get_full_url()) |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
122 r.code = code |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
123 r.msg = msg |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
124 return r |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
125 |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
126 def http_error_416(self, req, fp, code, msg, hdrs): |
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
127 # HTTP's Range Not Satisfiable error |
50379
3eacb4a54313
statichttprepo: unbyteify several IOError messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
50378
diff
changeset
|
128 raise _RangeError('Requested Range Not Satisfiable') |
36425
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
129 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
130 |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
131 def build_opener(ui, authinfo): |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
132 # urllib cannot handle URLs with embedded user or passwd |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
133 urlopener = url.opener(ui, authinfo) |
36425
24c2c760c1cb
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
Augie Fackler <augie@google.com>
parents:
35248
diff
changeset
|
134 urlopener.add_handler(_HTTPRangeHandler()) |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
135 |
31241
591fda751c6b
vfs: use 'vfs' module directly in 'mercurial.statichttprepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31148
diff
changeset
|
136 class statichttpvfs(vfsmod.abstractvfs): |
14091
0aa60e4e0b76
statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14076
diff
changeset
|
137 def __init__(self, base): |
0aa60e4e0b76
statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14076
diff
changeset
|
138 self.base = base |
43025
3518da504303
vfs: give all vfs an options attribute by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42231
diff
changeset
|
139 self.options = {} |
14091
0aa60e4e0b76
statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14076
diff
changeset
|
140 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
141 def __call__(self, path, mode=b'r', *args, **kw): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
142 if mode not in (b'r', b'rb'): |
50379
3eacb4a54313
statichttprepo: unbyteify several IOError messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
50378
diff
changeset
|
143 raise IOError('Permission denied') |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
144 f = b"/".join((self.base, urlreq.quote(path))) |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
145 return httprangereader(f, urlopener) |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
146 |
51884
f79f98733a5b
vfs: use @abstractmethod instead of homebrewing abstract methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
147 def _auditpath(self, path: bytes, mode: bytes) -> None: |
f79f98733a5b
vfs: use @abstractmethod instead of homebrewing abstract methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
148 raise NotImplementedError |
f79f98733a5b
vfs: use @abstractmethod instead of homebrewing abstract methods
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
149 |
50378
ebf1a07539b9
statichttprepo: fix the vfs.join() method to match the base class definition
Matt Harbison <matt_harbison@yahoo.com>
parents:
50128
diff
changeset
|
150 def join(self, path, *insidef): |
17725
ffd589d4b785
vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17649
diff
changeset
|
151 if path: |
50378
ebf1a07539b9
statichttprepo: fix the vfs.join() method to match the base class definition
Matt Harbison <matt_harbison@yahoo.com>
parents:
50128
diff
changeset
|
152 return pathutil.join(self.base, path, *insidef) |
17725
ffd589d4b785
vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17649
diff
changeset
|
153 else: |
ffd589d4b785
vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17649
diff
changeset
|
154 return self.base |
ffd589d4b785
vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17649
diff
changeset
|
155 |
17649
f65c6a5f256c
scmutil: rename classes from "opener" to "vfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17193
diff
changeset
|
156 return statichttpvfs |
1101 | 157 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
158 |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
159 class statichttppeer(localrepo.localpeer): |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
160 def local(self): |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
161 return None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
162 |
17193
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17192
diff
changeset
|
163 def canpush(self): |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17192
diff
changeset
|
164 return False |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
165 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
166 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
167 class statichttprepository( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
168 localrepo.localrepository, localrepo.revlogfilestorage |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
169 ): |
19778
55ef79031009
localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18915
diff
changeset
|
170 supported = localrepo.localrepository._basesupported |
55ef79031009
localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18915
diff
changeset
|
171 |
52070
6641a3ae8313
manifest: drop the CamelCase name for `manifest.manifestlog`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51900
diff
changeset
|
172 manifestlog: manifest.manifestlog |
51826
0338fb200a30
typing: lock in new pytype gains from making revlog related classes typeable
Matt Harbison <matt_harbison@yahoo.com>
parents:
51286
diff
changeset
|
173 |
1101 | 174 def __init__(self, ui, path): |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2072
diff
changeset
|
175 self._url = path |
1101 | 176 self.ui = ui |
3853
c0b449154a90
switch to the .hg/store layout, fix the tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3851
diff
changeset
|
177 |
11066
26abd91d9e84
static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10263
diff
changeset
|
178 self.root = path |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
179 u = urlutil.url(path.rstrip(b'/') + b"/.hg") |
13819
d16894e29f91
httprepo/sshrepo: use url.url
Brodie Rao <brodie@bitheap.org>
parents:
13533
diff
changeset
|
180 self.path, authinfo = u.authinfo() |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
181 |
31147
e04ab2a5bf90
statichttp: use 'repo.vfs' as the main attribute
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30219
diff
changeset
|
182 vfsclass = build_opener(ui, authinfo) |
e04ab2a5bf90
statichttp: use 'repo.vfs' as the main attribute
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30219
diff
changeset
|
183 self.vfs = vfsclass(self.path) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
184 self.cachevfs = vfsclass(self.vfs.join(b'cache')) |
15922
23921c17299a
phases: mechanism to allow extension to alter initial computation of phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
14962
diff
changeset
|
185 self._phasedefaults = [] |
6028
6605a03cbf87
make static-http work with empty repos (issue965)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5321
diff
changeset
|
186 |
23561
3c2419e07df5
namespaces: remove weakref; always pass in repo
Ryan McElroy <rmcelroy@fb.com>
parents:
23558
diff
changeset
|
187 self.names = namespaces.namespaces() |
32730
b8ff7d0ff361
localrepo: move filtername to __init__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31241
diff
changeset
|
188 self.filtername = None |
42231
d345627d104b
repoview: introduce a `experimental.extra-filter-revs` config
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41615
diff
changeset
|
189 self._extrafilterid = None |
46713
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46202
diff
changeset
|
190 self._wanted_sidedata = set() |
47225
d00177d08139
statichttp: add the missing `features` attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46907
diff
changeset
|
191 self.features = set() |
23558
3198aac7a95d
namespaces: add bookmarks to the names data structure
Sean Farley <sean.michael.farley@gmail.com>
parents:
23552
diff
changeset
|
192 |
3851
8f18e31c4441
add "requires" file to the repo, specifying the requirements
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3794
diff
changeset
|
193 try: |
39694
6192980553b4
statichttprepo: use new functions for requirements validation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39549
diff
changeset
|
194 requirements = set(self.vfs.read(b'requires').splitlines()) |
49306
2e726c934fcd
py3: catch FileNotFoundError instead of checking errno == ENOENT
Manuel Jacob <me@manueljacob.de>
parents:
48946
diff
changeset
|
195 except FileNotFoundError: |
14482
58b36e9ea783
introduce new function scmutil.readrequires
Adrian Buehlmann <adrian@cadifra.com>
parents:
14168
diff
changeset
|
196 requirements = set() |
58b36e9ea783
introduce new function scmutil.readrequires
Adrian Buehlmann <adrian@cadifra.com>
parents:
14168
diff
changeset
|
197 |
7178
98b6c3dde237
Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6312
diff
changeset
|
198 # check if it is a non-empty old-style repository |
98b6c3dde237
Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6312
diff
changeset
|
199 try: |
51898
159854151f0f
statichttprepo: use a context manager to handle a file descriptor
Matt Harbison <matt_harbison@yahoo.com>
parents:
51884
diff
changeset
|
200 with self.vfs(b"00changelog.i") as fp: |
159854151f0f
statichttprepo: use a context manager to handle a file descriptor
Matt Harbison <matt_harbison@yahoo.com>
parents:
51884
diff
changeset
|
201 fp.read(1) |
49306
2e726c934fcd
py3: catch FileNotFoundError instead of checking errno == ENOENT
Manuel Jacob <me@manueljacob.de>
parents:
48946
diff
changeset
|
202 except FileNotFoundError: |
7178
98b6c3dde237
Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6312
diff
changeset
|
203 # we do not care about empty old-style repositories here |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
204 msg = _(b"'%s' does not appear to be an hg repository") % path |
7637 | 205 raise error.RepoError(msg) |
48668
4a9570e389b2
share-safe: add support for static-http repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47225
diff
changeset
|
206 if requirementsmod.SHARESAFE_REQUIREMENT in requirements: |
4a9570e389b2
share-safe: add support for static-http repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47225
diff
changeset
|
207 storevfs = vfsclass(self.vfs.join(b'store')) |
4a9570e389b2
share-safe: add support for static-http repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47225
diff
changeset
|
208 requirements |= set(storevfs.read(b'requires').splitlines()) |
3851
8f18e31c4441
add "requires" file to the repo, specifying the requirements
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3794
diff
changeset
|
209 |
39694
6192980553b4
statichttprepo: use new functions for requirements validation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39549
diff
changeset
|
210 supportedrequirements = localrepo.gathersupportedrequirements(ui) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
211 localrepo.ensurerequirementsrecognized( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
212 requirements, supportedrequirements |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
213 ) |
39695
cb2dcfa5cade
localrepo: move requirements reasonability testing to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39694
diff
changeset
|
214 localrepo.ensurerequirementscompatible(ui, requirements) |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
215 self.nodeconstants = sha1nodeconstants |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
216 self.nullid = self.nodeconstants.nullid |
39694
6192980553b4
statichttprepo: use new functions for requirements validation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39549
diff
changeset
|
217 |
3851
8f18e31c4441
add "requires" file to the repo, specifying the requirements
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3794
diff
changeset
|
218 # setup store |
39698
f44187605315
localrepo: move store() from store module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39695
diff
changeset
|
219 self.store = localrepo.makestore(requirements, self.path, vfsclass) |
6897
faea0d27e38f
statichttp: use store class
Matt Mackall <mpm@selenic.com>
parents:
6840
diff
changeset
|
220 self.spath = self.store.path |
23878
37a92908a382
localrepo: remove all external users of localrepo.sopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23877
diff
changeset
|
221 self.svfs = self.store.opener |
6897
faea0d27e38f
statichttp: use store class
Matt Mackall <mpm@selenic.com>
parents:
6840
diff
changeset
|
222 self.sjoin = self.store.join |
16115
236bb604dc39
scmutil: update cached copy when filecached attribute is assigned (issue3263)
Idan Kamara <idankk86@gmail.com>
parents:
15922
diff
changeset
|
223 self._filecache = {} |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
224 self.requirements = requirements |
3851
8f18e31c4441
add "requires" file to the repo, specifying the requirements
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3794
diff
changeset
|
225 |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
226 rootmanifest = manifest.manifestrevlog(self.nodeconstants, self.svfs) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
227 self.manifestlog = manifest.manifestlog( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
228 self.svfs, self, rootmanifest, self.narrowmatch() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
229 ) |
23878
37a92908a382
localrepo: remove all external users of localrepo.sopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23877
diff
changeset
|
230 self.changelog = changelog.changelog(self.svfs) |
9146
5614a628d173
localrepo: rename in-memory tag cache instance attributes (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
8612
diff
changeset
|
231 self._tags = None |
1101 | 232 self.nodetagscache = None |
41615
328ca3b9e545
branchmap: encapsulate cache updating in the map itself
Martijn Pieters <mj@octobus.net>
parents:
41407
diff
changeset
|
233 self._branchcaches = branchmap.BranchMapCache() |
24373
59cc09240afb
revbranchcache: move out of branchmap onto localrepo
Durham Goode <durham@fb.com>
parents:
23878
diff
changeset
|
234 self._revbranchcache = None |
1598
14d1f1868bf6
cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1325
diff
changeset
|
235 self.encodepats = None |
14d1f1868bf6
cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1325
diff
changeset
|
236 self.decodepats = None |
24377
656f93ce66d5
revbranchcache: move cache writing to the transaction finalizer
Durham Goode <durham@fb.com>
parents:
24373
diff
changeset
|
237 self._transref = None |
50128
2f60cd6442fd
dirstate: only reload the dirstate when it may have changed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49762
diff
changeset
|
238 self._dirstate = None |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
239 |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
240 def _restrictcapabilities(self, caps): |
20962
af4158b8876b
statichttp: respect localrepo _restrictcapabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20055
diff
changeset
|
241 caps = super(statichttprepository, self)._restrictcapabilities(caps) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
242 return caps.difference([b"pushkey"]) |
1101 | 243 |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2072
diff
changeset
|
244 def url(self): |
7211 | 245 return self._url |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2072
diff
changeset
|
246 |
1101 | 247 def local(self): |
248 return False | |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
249 |
50440
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50379
diff
changeset
|
250 def peer(self, path=None, remotehidden=False): |
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50379
diff
changeset
|
251 return statichttppeer(self, path=path, remotehidden=remotehidden) |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
252 |
33604
8b00c723cee1
statichttprepo: implement wlock() (issue5613)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33533
diff
changeset
|
253 def wlock(self, wait=True): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
254 raise error.LockUnavailable( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
255 0, |
51286
81224afd938d
lock: properly convert error to bytes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50440
diff
changeset
|
256 pycompat.sysstr(_(b'lock not available')), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
257 b'lock', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
258 _(b'cannot lock static-http repository'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
259 ) |
33604
8b00c723cee1
statichttprepo: implement wlock() (issue5613)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33533
diff
changeset
|
260 |
7005
7739b61897df
do not pretend to lock static-http repositories (issue994)
Martin Geisler <mg@daimi.au.dk>
parents:
6988
diff
changeset
|
261 def lock(self, wait=True): |
45434
5523e3e1bc71
statichttprepo: use LockUnavailable() instead of Abort() for lock (API)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
43506
diff
changeset
|
262 raise error.LockUnavailable( |
5523e3e1bc71
statichttprepo: use LockUnavailable() instead of Abort() for lock (API)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
43506
diff
changeset
|
263 0, |
51286
81224afd938d
lock: properly convert error to bytes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50440
diff
changeset
|
264 pycompat.sysstr(_(b'lock not available')), |
45434
5523e3e1bc71
statichttprepo: use LockUnavailable() instead of Abort() for lock (API)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
43506
diff
changeset
|
265 b'lock', |
5523e3e1bc71
statichttprepo: use LockUnavailable() instead of Abort() for lock (API)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
43506
diff
changeset
|
266 _(b'cannot lock static-http repository'), |
5523e3e1bc71
statichttprepo: use LockUnavailable() instead of Abort() for lock (API)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
43506
diff
changeset
|
267 ) |
7005
7739b61897df
do not pretend to lock static-http repositories (issue994)
Martin Geisler <mg@daimi.au.dk>
parents:
6988
diff
changeset
|
268 |
29738
c1696430254f
statichttprepo: do not try to write caches
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
28883
diff
changeset
|
269 def _writecaches(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
270 pass # statichttprepository are read only |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43025
diff
changeset
|
271 |
29738
c1696430254f
statichttprepo: do not try to write caches
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
28883
diff
changeset
|
272 |
50440
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50379
diff
changeset
|
273 def make_peer( |
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50379
diff
changeset
|
274 ui, path, create, intents=None, createopts=None, remotehidden=False |
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50379
diff
changeset
|
275 ): |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
276 if create: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
277 raise error.Abort(_(b'cannot create new static-http repository')) |
49762
c4d587fa161c
peer: pass the `path` to the statichttp peer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49757
diff
changeset
|
278 url = path.loc[7:] |
50440
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50379
diff
changeset
|
279 return statichttprepository(ui, url).peer( |
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50379
diff
changeset
|
280 path=path, remotehidden=remotehidden |
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50379
diff
changeset
|
281 ) |