annotate mercurial/statichttprepo.py @ 2148:c72e618c1204

Add MOTD display to hgweb and hgwebdir. The hgweb "footer" template now has space for an optional message of the day (MOTD). This is used in two contexts: 1) On the hgwebdir index page 2) On various pages of each individual repo For both cases, the MOTD is read out of an entry named "motd" in the [web] section of a config file -- the only difference is which file is used. For #1, you need to add the section to hgweb.config; for #2, you need to add to the repo's .hgrc file. I suggest something like this: [web] motd = <p>To download these repositories, <a href="http://www.selenic.com/mercurial">get Mercurial</a> and then type something like:</p><p><pre>hg clone http://gs3080.sp.cs.cmu.edu/hg.cgi/cpmpy</pre></p>You can also click the Download links to get an archive of the latest revision. An online sample is available here: http://gs3080.sp.cs.cmu.edu/hg.cgi
author Colin McMillen <mcmillen@cs.cmu.edu>
date Thu, 27 Apr 2006 22:11:13 -0700
parents 74d3f5336b66
children
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
1325
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
10 from demandload import demandload
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
11 demandload(globals(), "changelog filelog httprangereader")
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(), "localrepo manifest os urllib urllib2")
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
13
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
14 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
15 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
16 try:
57220daf40e9 Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1101
diff changeset
17 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
18 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
19 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
20 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
21 raise IOError(None, inst.reason[1])
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
22
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
23 def opener(base):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
24 """return a function that opens files over http"""
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
25 p = base
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
26 def o(path, mode="r"):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
27 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
28 return rangereader(f)
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
29 return o
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
30
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
31 class statichttprepository(localrepo.localrepository):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
32 def __init__(self, ui, path):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
33 self.path = (path + "/.hg")
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
34 self.ui = ui
2072
74d3f5336b66 Implement revlogng.
mason@suse.com
parents: 1821
diff changeset
35 self.revlogversion = 0
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
36 self.opener = opener(self.path)
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
37 self.manifest = manifest.manifest(self.opener)
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
38 self.changelog = changelog.changelog(self.opener)
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
39 self.tagscache = None
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
40 self.nodetagscache = None
1598
14d1f1868bf6 cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1325
diff changeset
41 self.encodepats = None
14d1f1868bf6 cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1325
diff changeset
42 self.decodepats = None
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
43
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
44 def dev(self):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
45 return -1
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
46
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
47 def local(self):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
48 return False