annotate mercurial/statichttprepo.py @ 31601:8e7feaad2d8d

logtoprocess: use lowercase for docstring title
author Jun Wu <quark@fb.com>
date Thu, 23 Mar 2017 21:16:55 -0700
parents 591fda751c6b
children b8ff7d0ff361
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
1 # statichttprepo.py - simple http repository class for mercurial
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
2 #
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
3 # This provides read-only repo access to repositories exported via static http
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
4 #
4635
63b9d2deed48 Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4258
diff changeset
5 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
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
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9146
diff changeset
8 # GNU General Public License version 2 or any later version.
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
9
25978
762f4c6df6b1 statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25670
diff changeset
10 from __future__ import absolute_import
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 import os
762f4c6df6b1 statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25670
diff changeset
14
762f4c6df6b1 statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25670
diff changeset
15 from .i18n import _
762f4c6df6b1 statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25670
diff changeset
16 from . import (
762f4c6df6b1 statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25670
diff changeset
17 byterange,
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,
762f4c6df6b1 statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25670
diff changeset
23 scmutil,
762f4c6df6b1 statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25670
diff changeset
24 store,
762f4c6df6b1 statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25670
diff changeset
25 url,
762f4c6df6b1 statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25670
diff changeset
26 util,
31241
591fda751c6b vfs: use 'vfs' module directly in 'mercurial.statichttprepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31148
diff changeset
27 vfs as vfsmod,
25978
762f4c6df6b1 statichttprepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25670
diff changeset
28 )
1325
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
29
28883
032c4c2f802a pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents: 27705
diff changeset
30 urlerr = util.urlerr
032c4c2f802a pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents: 27705
diff changeset
31 urlreq = util.urlreq
032c4c2f802a pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents: 27705
diff changeset
32
7274
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
33 class httprangereader(object):
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
34 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
35 # 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
36 self.url = url
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
37 self.pos = 0
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
38 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
39 self.name = url
27705
2380889f8f52 statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26587
diff changeset
40
2380889f8f52 statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26587
diff changeset
41 def __enter__(self):
2380889f8f52 statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26587
diff changeset
42 return self
2380889f8f52 statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26587
diff changeset
43
2380889f8f52 statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26587
diff changeset
44 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
45 self.close()
2380889f8f52 statichttprepo: implement __enter__ and __exit__ on httprangeheader
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26587
diff changeset
46
7274
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
47 def seek(self, pos):
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
48 self.pos = pos
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
49 def read(self, bytes=None):
28883
032c4c2f802a pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents: 27705
diff changeset
50 req = urlreq.request(self.url)
7274
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
51 end = ''
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
52 if bytes:
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
53 end = self.pos + bytes - 1
16882
a2d6e336e9cc statichttprepo: don't send Range header when requesting entire file
Alexander Boyd <alex@opengroove.org>
parents: 16115
diff changeset
54 if self.pos or end:
a2d6e336e9cc statichttprepo: don't send Range header when requesting entire file
Alexander Boyd <alex@opengroove.org>
parents: 16115
diff changeset
55 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
56
1325
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
57 try:
7274
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
58 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
59 data = f.read()
25196
7a1af58ab242 statichttprepo: remove wrong getattr ladder
Augie Fackler <raf@durin42.com>
parents: 24377
diff changeset
60 code = f.code
28883
032c4c2f802a pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents: 27705
diff changeset
61 except urlerr.httperror as inst:
6028
6605a03cbf87 make static-http work with empty repos (issue965)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5321
diff changeset
62 num = inst.code == 404 and errno.ENOENT or None
6605a03cbf87 make static-http work with empty repos (issue965)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5321
diff changeset
63 raise IOError(num, inst)
28883
032c4c2f802a pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents: 27705
diff changeset
64 except urlerr.urlerror as inst:
1821
0b3f4be5c5bf Catch urllib errors for old-http in a nicer way.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1598
diff changeset
65 raise IOError(None, inst.reason[1])
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
66
8612
e10e984bea46 statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents: 8225
diff changeset
67 if code == 200:
e10e984bea46 statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents: 8225
diff changeset
68 # 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
69 # Range headers and returns the full entity. Let's slice it.
e10e984bea46 statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents: 8225
diff changeset
70 if bytes:
e10e984bea46 statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents: 8225
diff changeset
71 data = data[self.pos:self.pos + bytes]
e10e984bea46 statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents: 8225
diff changeset
72 else:
e10e984bea46 statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents: 8225
diff changeset
73 data = data[self.pos:]
e10e984bea46 statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents: 8225
diff changeset
74 elif bytes:
7274
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
75 data = data[:bytes]
8612
e10e984bea46 statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents: 8225
diff changeset
76 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
77 return data
20055
6bb9de1e4d16 statichttprepo.httprangeheader: implement readlines
Siddharth Agarwal <sid0@fb.com>
parents: 20054
diff changeset
78 def readlines(self):
6bb9de1e4d16 statichttprepo.httprangeheader: implement readlines
Siddharth Agarwal <sid0@fb.com>
parents: 20054
diff changeset
79 return self.read().splitlines(True)
11066
26abd91d9e84 static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10263
diff changeset
80 def __iter__(self):
20055
6bb9de1e4d16 statichttprepo.httprangeheader: implement readlines
Siddharth Agarwal <sid0@fb.com>
parents: 20054
diff changeset
81 return iter(self.readlines())
11066
26abd91d9e84 static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10263
diff changeset
82 def close(self):
26abd91d9e84 static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10263
diff changeset
83 pass
7274
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
84
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
85 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
86 # 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
87 urlopener = url.opener(ui, authinfo)
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
88 urlopener.add_handler(byterange.HTTPRangeHandler())
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
89
31241
591fda751c6b vfs: use 'vfs' module directly in 'mercurial.statichttprepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31148
diff changeset
90 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
91 def __init__(self, base):
0aa60e4e0b76 statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 14076
diff changeset
92 self.base = base
0aa60e4e0b76 statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 14076
diff changeset
93
23552
72319005f5fb statichttprepo: update profile of __call__ in mock vfs object
Mads Kiilerich <madski@unity3d.com>
parents: 20962
diff changeset
94 def __call__(self, path, mode='r', *args, **kw):
13533
b4f5f76386f2 statichttprepo: abort if opener mode is 'r+' or 'rb+'
Adrian Buehlmann <adrian@cadifra.com>
parents: 13447
diff changeset
95 if mode not in ('r', 'rb'):
11066
26abd91d9e84 static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10263
diff changeset
96 raise IOError('Permission denied')
28883
032c4c2f802a pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents: 27705
diff changeset
97 f = "/".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
98 return httprangereader(f, urlopener)
95f3694cc5a4 statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7211
diff changeset
99
17725
ffd589d4b785 vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17649
diff changeset
100 def join(self, path):
ffd589d4b785 vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17649
diff changeset
101 if path:
ffd589d4b785 vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17649
diff changeset
102 return os.path.join(self.base, path)
ffd589d4b785 vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17649
diff changeset
103 else:
ffd589d4b785 vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17649
diff changeset
104 return self.base
ffd589d4b785 vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17649
diff changeset
105
17649
f65c6a5f256c scmutil: rename classes from "opener" to "vfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17193
diff changeset
106 return statichttpvfs
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
107
17192
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
108 class statichttppeer(localrepo.localpeer):
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
109 def local(self):
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
110 return None
17193
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17192
diff changeset
111 def canpush(self):
1d710fe5ee0e peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents: 17192
diff changeset
112 return False
17192
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
113
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
114 class statichttprepository(localrepo.localrepository):
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 18915
diff changeset
115 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
116
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
117 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
118 self._url = path
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
119 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
120
11066
26abd91d9e84 static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10263
diff changeset
121 self.root = path
14076
924c82157d46 url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents: 13819
diff changeset
122 u = util.url(path.rstrip('/') + "/.hg")
13819
d16894e29f91 httprepo/sshrepo: use url.url
Brodie Rao <brodie@bitheap.org>
parents: 13533
diff changeset
123 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
124
31147
e04ab2a5bf90 statichttp: use 'repo.vfs' as the main attribute
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30219
diff changeset
125 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
126 self.vfs = vfsclass(self.path)
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
127 self._phasedefaults = []
6028
6605a03cbf87 make static-http work with empty repos (issue965)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5321
diff changeset
128
23561
3c2419e07df5 namespaces: remove weakref; always pass in repo
Ryan McElroy <rmcelroy@fb.com>
parents: 23558
diff changeset
129 self.names = namespaces.namespaces()
23558
3198aac7a95d namespaces: add bookmarks to the names data structure
Sean Farley <sean.michael.farley@gmail.com>
parents: 23552
diff changeset
130
3851
8f18e31c4441 add "requires" file to the repo, specifying the requirements
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3794
diff changeset
131 try:
23877
7cc77030c557 localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents: 23561
diff changeset
132 requirements = scmutil.readrequires(self.vfs, self.supported)
25660
328739ea70c3 global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25196
diff changeset
133 except IOError as inst:
7178
98b6c3dde237 Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6312
diff changeset
134 if inst.errno != errno.ENOENT:
98b6c3dde237 Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6312
diff changeset
135 raise
14482
58b36e9ea783 introduce new function scmutil.readrequires
Adrian Buehlmann <adrian@cadifra.com>
parents: 14168
diff changeset
136 requirements = set()
58b36e9ea783 introduce new function scmutil.readrequires
Adrian Buehlmann <adrian@cadifra.com>
parents: 14168
diff changeset
137
7178
98b6c3dde237 Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6312
diff changeset
138 # 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
139 try:
23877
7cc77030c557 localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents: 23561
diff changeset
140 fp = self.vfs("00changelog.i")
13400
14f3795a5ed7 explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 13253
diff changeset
141 fp.read(1)
14f3795a5ed7 explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 13253
diff changeset
142 fp.close()
25660
328739ea70c3 global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25196
diff changeset
143 except IOError as inst:
7178
98b6c3dde237 Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6312
diff changeset
144 if inst.errno != errno.ENOENT:
98b6c3dde237 Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6312
diff changeset
145 raise
98b6c3dde237 Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6312
diff changeset
146 # we do not care about empty old-style repositories here
6028
6605a03cbf87 make static-http work with empty repos (issue965)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5321
diff changeset
147 msg = _("'%s' does not appear to be an hg repository") % path
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7274
diff changeset
148 raise error.RepoError(msg)
3851
8f18e31c4441 add "requires" file to the repo, specifying the requirements
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3794
diff changeset
149
8f18e31c4441 add "requires" file to the repo, specifying the requirements
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3794
diff changeset
150 # setup store
31147
e04ab2a5bf90 statichttp: use 'repo.vfs' as the main attribute
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30219
diff changeset
151 self.store = store.store(requirements, self.path, vfsclass)
6897
faea0d27e38f statichttp: use store class
Matt Mackall <mpm@selenic.com>
parents: 6840
diff changeset
152 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
153 self.svfs = self.store.opener
6897
faea0d27e38f statichttp: use store class
Matt Mackall <mpm@selenic.com>
parents: 6840
diff changeset
154 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
155 self._filecache = {}
17192
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
156 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
157
30219
3c8811efdddc manifest: make manifestlog a storecache
Durham Goode <durham@fb.com>
parents: 29738
diff changeset
158 self.manifestlog = manifest.manifestlog(self.svfs, self)
23878
37a92908a382 localrepo: remove all external users of localrepo.sopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents: 23877
diff changeset
159 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
160 self._tags = None
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
161 self.nodetagscache = None
18189
b9026ba002f6 branchmap: enable caching for filtered version too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18125
diff changeset
162 self._branchcaches = {}
24373
59cc09240afb revbranchcache: move out of branchmap onto localrepo
Durham Goode <durham@fb.com>
parents: 23878
diff changeset
163 self._revbranchcache = None
1598
14d1f1868bf6 cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1325
diff changeset
164 self.encodepats = None
14d1f1868bf6 cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1325
diff changeset
165 self.decodepats = None
24377
656f93ce66d5 revbranchcache: move cache writing to the transaction finalizer
Durham Goode <durham@fb.com>
parents: 24373
diff changeset
166 self._transref = None
17192
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
167
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
168 def _restrictcapabilities(self, caps):
20962
af4158b8876b statichttp: respect localrepo _restrictcapabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 20055
diff changeset
169 caps = super(statichttprepository, self)._restrictcapabilities(caps)
17192
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
170 return caps.difference(["pushkey"])
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
171
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2072
diff changeset
172 def url(self):
7211
25c0dee16ee0 Autodetect static-http
Matt Mackall <mpm@selenic.com>
parents: 7179
diff changeset
173 return self._url
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2072
diff changeset
174
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
175 def local(self):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
176 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
177
17192
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
178 def peer(self):
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
179 return statichttppeer(self)
1ac628cd7113 peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 17156
diff changeset
180
7005
7739b61897df do not pretend to lock static-http repositories (issue994)
Martin Geisler <mg@daimi.au.dk>
parents: 6988
diff changeset
181 def lock(self, wait=True):
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25978
diff changeset
182 raise error.Abort(_('cannot lock static-http repository'))
7005
7739b61897df do not pretend to lock static-http repositories (issue994)
Martin Geisler <mg@daimi.au.dk>
parents: 6988
diff changeset
183
29738
c1696430254f statichttprepo: do not try to write caches
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28883
diff changeset
184 def _writecaches(self):
c1696430254f statichttprepo: do not try to write caches
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28883
diff changeset
185 pass # statichttprepository are read only
c1696430254f statichttprepo: do not try to write caches
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 28883
diff changeset
186
2740
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
187 def instance(ui, path, create):
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
188 if create:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25978
diff changeset
189 raise error.Abort(_('cannot create new static-http repository'))
4853
bf10a03a6b24 Removed deprecated hg:// and old-http:// protocols (issue406)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4635
diff changeset
190 return statichttprepository(ui, path[7:])