annotate mercurial/statichttprepo.py @ 2786:a9fadbef21e9

fix output of test-backout.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Fri, 04 Aug 2006 10:37:40 -0700
parents 386f04d6ecb3
children 345bac2bc4ec
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 #
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
5 # Copyright 2005 Matt Mackall <mpm@selenic.com>
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
6 #
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
7 # This software may be used and distributed according to the terms
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
8 # of the GNU General Public License, incorporated herein by reference.
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
9
2740
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
10 from demandload import *
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
11 from i18n import gettext as _
1325
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
12 demandload(globals(), "changelog filelog httprangereader")
2740
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
13 demandload(globals(), "localrepo manifest os urllib urllib2 util")
1325
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
14
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
15 class rangereader(httprangereader.httprangereader):
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
16 def read(self, size=None):
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
17 try:
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
18 return httprangereader.httprangereader.read(self, size)
1821
0b3f4be5c5bf Catch urllib errors for old-http in a nicer way.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1598
diff changeset
19 except urllib2.HTTPError, inst:
0b3f4be5c5bf Catch urllib errors for old-http in a nicer way.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1598
diff changeset
20 raise IOError(None, inst)
1325
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
21 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
22 raise IOError(None, inst.reason[1])
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
23
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
24 def opener(base):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
25 """return a function that opens files over http"""
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
26 p = base
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
27 def o(path, mode="r"):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
28 f = os.path.join(p, urllib.quote(path))
1325
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
29 return rangereader(f)
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
30 return o
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
31
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
32 class statichttprepository(localrepo.localrepository):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
33 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
34 self._url = path
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
35 self.path = (path + "/.hg")
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
36 self.ui = ui
2072
74d3f5336b66 Implement revlogng.
mason@suse.com
parents: 1821
diff changeset
37 self.revlogversion = 0
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
38 self.opener = opener(self.path)
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
39 self.manifest = manifest.manifest(self.opener)
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
40 self.changelog = changelog.changelog(self.opener)
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
41 self.tagscache = None
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
42 self.nodetagscache = None
1598
14d1f1868bf6 cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1325
diff changeset
43 self.encodepats = None
14d1f1868bf6 cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1325
diff changeset
44 self.decodepats = None
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
45
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2072
diff changeset
46 def url(self):
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2072
diff changeset
47 return 'static-' + self._url
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2072
diff changeset
48
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
49 def dev(self):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
50 return -1
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
51
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
52 def local(self):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
53 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
54
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
55 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
56 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
57 raise util.Abort(_('cannot create new static-http repository'))
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
58 if path.startswith('old-http:'):
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
59 ui.warn(_("old-http:// syntax is deprecated, "
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
60 "please use static-http:// instead\n"))
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
61 path = path[4:]
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
62 else:
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
63 path = path[7:]
386f04d6ecb3 clean up hg.py: move repo constructor code into each repo module
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
64 return statichttprepository(ui, path)