Mercurial > hg
annotate mercurial/statichttprepo.py @ 23036:19f5273c9f3e
cmdserver: include pid of server handling requests in hello message
Because unix-mode server forks child process per connection, client does not
know the pid of the server that will handle requests. The pid is necessary
to interrupt hung process:
1. client connects to socket server
2. server accepts the connection, forks, and tells pid
3. client requests "runcommand pull"
.. hung ..
4. client sends SIGINT to the (forked) server
5. server returns from I/O wait
Note that getsockopt(SO_PEERCRED) of Linux cannot be used because the server
fork()s after accept().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 18 Oct 2014 12:24:50 +0900 |
parents | af4158b8876b |
children | 72319005f5fb |
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 # | |
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 | 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 |
3891 | 10 from i18n import _ |
7637 | 11 import changelog, byterange, url, error |
14091
0aa60e4e0b76
statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14076
diff
changeset
|
12 import localrepo, manifest, util, scmutil, store |
18915
169030d9255e
statichttprepo: add missing import of os
Bryan O'Sullivan <bryano@fb.com>
parents:
18189
diff
changeset
|
13 import urllib, urllib2, errno, os |
1325
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
14 |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
15 class httprangereader(object): |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
16 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
|
17 # 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
|
18 self.url = url |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
19 self.pos = 0 |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
20 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
|
21 self.name = url |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
22 def seek(self, pos): |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
23 self.pos = pos |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
24 def read(self, bytes=None): |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
25 req = urllib2.Request(self.url) |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
26 end = '' |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
27 if bytes: |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
28 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
|
29 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
|
30 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
|
31 |
1325
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
32 try: |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
33 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
|
34 data = f.read() |
14962
1c917bc66ccc
statichttprepo: replace hasattr with getattr
Augie Fackler <durin42@gmail.com>
parents:
14929
diff
changeset
|
35 # Python 2.6+ defines a getcode() function, and 2.4 and |
1c917bc66ccc
statichttprepo: replace hasattr with getattr
Augie Fackler <durin42@gmail.com>
parents:
14929
diff
changeset
|
36 # 2.5 appear to always have an undocumented code attribute |
1c917bc66ccc
statichttprepo: replace hasattr with getattr
Augie Fackler <durin42@gmail.com>
parents:
14929
diff
changeset
|
37 # set. If we can't read either of those, fall back to 206 |
1c917bc66ccc
statichttprepo: replace hasattr with getattr
Augie Fackler <durin42@gmail.com>
parents:
14929
diff
changeset
|
38 # and hope for the best. |
1c917bc66ccc
statichttprepo: replace hasattr with getattr
Augie Fackler <durin42@gmail.com>
parents:
14929
diff
changeset
|
39 code = getattr(f, 'getcode', lambda : getattr(f, 'code', 206))() |
1821
0b3f4be5c5bf
Catch urllib errors for old-http in a nicer way.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1598
diff
changeset
|
40 except urllib2.HTTPError, inst: |
6028
6605a03cbf87
make static-http work with empty repos (issue965)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5321
diff
changeset
|
41 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
|
42 raise IOError(num, inst) |
1325
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
43 except urllib2.URLError, inst: |
1821
0b3f4be5c5bf
Catch urllib errors for old-http in a nicer way.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1598
diff
changeset
|
44 raise IOError(None, inst.reason[1]) |
1101 | 45 |
8612
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
46 if code == 200: |
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
47 # 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
|
48 # 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
|
49 if bytes: |
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
50 data = data[self.pos:self.pos + bytes] |
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
51 else: |
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
52 data = data[self.pos:] |
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
53 elif bytes: |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
54 data = data[:bytes] |
8612
e10e984bea46
statichttprepo: handle remote not supporting Range headers
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
55 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
|
56 return data |
20055
6bb9de1e4d16
statichttprepo.httprangeheader: implement readlines
Siddharth Agarwal <sid0@fb.com>
parents:
20054
diff
changeset
|
57 def readlines(self): |
6bb9de1e4d16
statichttprepo.httprangeheader: implement readlines
Siddharth Agarwal <sid0@fb.com>
parents:
20054
diff
changeset
|
58 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
|
59 def __iter__(self): |
20055
6bb9de1e4d16
statichttprepo.httprangeheader: implement readlines
Siddharth Agarwal <sid0@fb.com>
parents:
20054
diff
changeset
|
60 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
|
61 def close(self): |
26abd91d9e84
static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10263
diff
changeset
|
62 pass |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
63 |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
64 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
|
65 # 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
|
66 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
|
67 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
|
68 |
17649
f65c6a5f256c
scmutil: rename classes from "opener" to "vfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17193
diff
changeset
|
69 class statichttpvfs(scmutil.abstractvfs): |
14091
0aa60e4e0b76
statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14076
diff
changeset
|
70 def __init__(self, base): |
0aa60e4e0b76
statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14076
diff
changeset
|
71 self.base = base |
0aa60e4e0b76
statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14076
diff
changeset
|
72 |
0aa60e4e0b76
statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14076
diff
changeset
|
73 def __call__(self, path, mode="r", atomictemp=None): |
13533
b4f5f76386f2
statichttprepo: abort if opener mode is 'r+' or 'rb+'
Adrian Buehlmann <adrian@cadifra.com>
parents:
13447
diff
changeset
|
74 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
|
75 raise IOError('Permission denied') |
14091
0aa60e4e0b76
statichttprepo: make the opener a subclass of abstractopener
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14076
diff
changeset
|
76 f = "/".join((self.base, urllib.quote(path))) |
7274
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
77 return httprangereader(f, urlopener) |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
78 |
17725
ffd589d4b785
vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17649
diff
changeset
|
79 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
|
80 if path: |
ffd589d4b785
vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17649
diff
changeset
|
81 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
|
82 else: |
ffd589d4b785
vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17649
diff
changeset
|
83 return self.base |
ffd589d4b785
vfs: define "join()" in each classes derived from "abstractvfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17649
diff
changeset
|
84 |
17649
f65c6a5f256c
scmutil: rename classes from "opener" to "vfs"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17193
diff
changeset
|
85 return statichttpvfs |
1101 | 86 |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
87 class statichttppeer(localrepo.localpeer): |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
88 def local(self): |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
89 return None |
17193
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17192
diff
changeset
|
90 def canpush(self): |
1d710fe5ee0e
peer: introduce canpush and improve error message
Sune Foldager <cryo@cyanite.org>
parents:
17192
diff
changeset
|
91 return False |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
92 |
1101 | 93 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
|
94 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
|
95 |
1101 | 96 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
|
97 self._url = path |
1101 | 98 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
|
99 |
11066
26abd91d9e84
static-http: mimic more closely localrepo (issue2164: allow clone -r )
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10263
diff
changeset
|
100 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
|
101 u = util.url(path.rstrip('/') + "/.hg") |
13819
d16894e29f91
httprepo/sshrepo: use url.url
Brodie Rao <brodie@bitheap.org>
parents:
13533
diff
changeset
|
102 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
|
103 |
95f3694cc5a4
statichttprepo: cleanups, use url.py (proxy, password support)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7211
diff
changeset
|
104 opener = build_opener(ui, authinfo) |
1101 | 105 self.opener = opener(self.path) |
17156
7034365089bf
localrepo: add "vfs" fields to "localrepository" for migration from "opener"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16882
diff
changeset
|
106 self.vfs = self.opener |
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
|
107 self._phasedefaults = [] |
6028
6605a03cbf87
make static-http work with empty repos (issue965)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5321
diff
changeset
|
108 |
3851
8f18e31c4441
add "requires" file to the repo, specifying the requirements
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3794
diff
changeset
|
109 try: |
14482
58b36e9ea783
introduce new function scmutil.readrequires
Adrian Buehlmann <adrian@cadifra.com>
parents:
14168
diff
changeset
|
110 requirements = scmutil.readrequires(self.opener, self.supported) |
6028
6605a03cbf87
make static-http work with empty repos (issue965)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5321
diff
changeset
|
111 except IOError, inst: |
7178
98b6c3dde237
Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6312
diff
changeset
|
112 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
|
113 raise |
14482
58b36e9ea783
introduce new function scmutil.readrequires
Adrian Buehlmann <adrian@cadifra.com>
parents:
14168
diff
changeset
|
114 requirements = set() |
58b36e9ea783
introduce new function scmutil.readrequires
Adrian Buehlmann <adrian@cadifra.com>
parents:
14168
diff
changeset
|
115 |
7178
98b6c3dde237
Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6312
diff
changeset
|
116 # 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
|
117 try: |
13400
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13253
diff
changeset
|
118 fp = self.opener("00changelog.i") |
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13253
diff
changeset
|
119 fp.read(1) |
14f3795a5ed7
explicitly close files
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13253
diff
changeset
|
120 fp.close() |
7178
98b6c3dde237
Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6312
diff
changeset
|
121 except IOError, inst: |
98b6c3dde237
Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6312
diff
changeset
|
122 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
|
123 raise |
98b6c3dde237
Fix Debian bug #494889 (fetching from static-http://... broken)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6312
diff
changeset
|
124 # 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
|
125 msg = _("'%s' does not appear to be an hg repository") % path |
7637 | 126 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
|
127 |
8f18e31c4441
add "requires" file to the repo, specifying the requirements
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3794
diff
changeset
|
128 # setup store |
13426
643b8212813e
store: remove pointless pathjoiner parameter
Adrian Buehlmann <adrian@cadifra.com>
parents:
13400
diff
changeset
|
129 self.store = store.store(requirements, self.path, opener) |
6897
faea0d27e38f
statichttp: use store class
Matt Mackall <mpm@selenic.com>
parents:
6840
diff
changeset
|
130 self.spath = self.store.path |
faea0d27e38f
statichttp: use store class
Matt Mackall <mpm@selenic.com>
parents:
6840
diff
changeset
|
131 self.sopener = self.store.opener |
17156
7034365089bf
localrepo: add "vfs" fields to "localrepository" for migration from "opener"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16882
diff
changeset
|
132 self.svfs = self.sopener |
6897
faea0d27e38f
statichttp: use store class
Matt Mackall <mpm@selenic.com>
parents:
6840
diff
changeset
|
133 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
|
134 self._filecache = {} |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
135 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
|
136 |
3791
8643b9f90b51
introduce localrepo.spath for the store path, sopener fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3457
diff
changeset
|
137 self.manifest = manifest.manifest(self.sopener) |
8643b9f90b51
introduce localrepo.spath for the store path, sopener fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3457
diff
changeset
|
138 self.changelog = changelog.changelog(self.sopener) |
9146
5614a628d173
localrepo: rename in-memory tag cache instance attributes (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
8612
diff
changeset
|
139 self._tags = None |
1101 | 140 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
|
141 self._branchcaches = {} |
1598
14d1f1868bf6
cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1325
diff
changeset
|
142 self.encodepats = None |
14d1f1868bf6
cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1325
diff
changeset
|
143 self.decodepats = None |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
144 |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
145 def _restrictcapabilities(self, caps): |
20962
af4158b8876b
statichttp: respect localrepo _restrictcapabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20055
diff
changeset
|
146 caps = super(statichttprepository, self)._restrictcapabilities(caps) |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
147 return caps.difference(["pushkey"]) |
1101 | 148 |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2072
diff
changeset
|
149 def url(self): |
7211 | 150 return self._url |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2072
diff
changeset
|
151 |
1101 | 152 def local(self): |
153 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
|
154 |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
155 def peer(self): |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
156 return statichttppeer(self) |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
17156
diff
changeset
|
157 |
7005
7739b61897df
do not pretend to lock static-http repositories (issue994)
Martin Geisler <mg@daimi.au.dk>
parents:
6988
diff
changeset
|
158 def lock(self, wait=True): |
7739b61897df
do not pretend to lock static-http repositories (issue994)
Martin Geisler <mg@daimi.au.dk>
parents:
6988
diff
changeset
|
159 raise util.Abort(_('cannot lock static-http repository')) |
7739b61897df
do not pretend to lock static-http repositories (issue994)
Martin Geisler <mg@daimi.au.dk>
parents:
6988
diff
changeset
|
160 |
2740
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
161 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
|
162 if create: |
386f04d6ecb3
clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2673
diff
changeset
|
163 raise util.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
|
164 return statichttprepository(ui, path[7:]) |