annotate mercurial/hgweb.py @ 135:c0faf50822ea

change template to a generator add write call to output generator
author jake@edge2.net
date Sat, 21 May 2005 20:31:54 -0700
parents 13d609f8d830
children 0e8d60d2bb2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
1 #!/usr/bin/env python
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
2 #
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
3 # hgweb.py - 0.2 - 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
4 # - web interface to a mercurial repository
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
5 #
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
6 # This software may be used and distributed according to the terms
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
7 # of the GNU General Public License, incorporated herein by reference.
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
8
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
9 # useful for debugging
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
10 import cgitb
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
11 cgitb.enable()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
12
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
13 import os, cgi, time, re, difflib, sys, zlib
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
14 from mercurial import hg, mdiff
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
15
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
16 def nl2br(text):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
17 return re.sub('\n', '<br />', text)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
18
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
19 def obfuscate(text):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
20 l = []
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
21 for c in text:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
22 l.append('&#%d;' % ord(c))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
23 return ''.join(l)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
24
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
25 def httphdr(type):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
26 print 'Content-type: %s\n' % type
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
27
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
28 def write(*things):
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
29 for thing in things:
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
30 if hasattr(thing, "__iter__"):
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
31 for part in thing:
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
32 write(part)
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
33 else:
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
34 sys.stdout.write(str(thing))
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
35
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
36 class template:
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
37 def __init__(self, tmpl_dir):
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
38 self.tmpl_dir = tmpl_dir
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
39 def do_page(self, tmpl_fn, **map):
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
40 txt = file(os.path.join(self.tmpl_dir, tmpl_fn)).read()
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
41 while txt:
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
42 m = re.search(r"#([a-zA-Z0-9]+)#", txt)
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
43 if m:
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
44 yield txt[:m.start(0)]
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
45 v = map.get(m.group(1), "")
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
46 if callable(v):
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
47 for y in v(**map): yield y
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
48 else:
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
49 yield v
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
50 txt = txt[m.end(0):]
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
51 else:
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
52 yield txt
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
53 txt = ''
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
54
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
55 class page:
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
56 def __init__(self, tmpl_dir = "", type="text/html", title="Mercurial Web",
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
57 charset="ISO-8859-1"):
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
58 self.tmpl = template(tmpl_dir)
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
59
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
60 print 'Content-type: %s; charset=%s\n' % (type, charset)
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
61 write(self.tmpl.do_page('htmlstart.tmpl', title = title))
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
62
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
63 def endpage(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
64 print '</BODY>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
65 print '</HTML>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
66
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
67 def show_diff(self, a, b, fn):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
68 a = a.splitlines(1)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
69 b = b.splitlines(1)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
70 l = difflib.unified_diff(a, b, fn, fn)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
71 print '<pre>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
72 for line in l:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
73 line = cgi.escape(line[:-1])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
74 if line.startswith('+'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
75 print '<span class="plusline">%s</span>' % (line, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
76 elif line.startswith('-'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
77 print '<span class="minusline">%s</span>' % (line, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
78 elif line.startswith('@'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
79 print '<span class="atline">%s</span>' % (line, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
80 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
81 print line
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
82 print '</pre>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
83
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
84 class errpage(page):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
85 def __init__(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
86 page.__init__(self, title="Mercurial Web Error Page")
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
87
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
88 class change_list(page):
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
89 def __init__(self, repo, tmpl_dir, reponame, numchanges = 50):
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
90 page.__init__(self, tmpl_dir)
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
91 self.repo = repo
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
92 self.numchanges = numchanges
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
93 write(self.tmpl.do_page('changestitle.tmpl', reponame=reponame))
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
94
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
95 def content(self, hi=None):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
96 cl = []
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
97 count = self.repo.changelog.count()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
98 if not hi:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
99 hi = count
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
100 elif hi < self.numchanges:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
101 hi = self.numchanges
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
102
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
103 start = 0
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
104 if hi - self.numchanges >= 0:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
105 start = hi - self.numchanges
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
106
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
107 nav = "Displaying Revisions: %d-%d" % (start, hi-1)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
108 if start != 0:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
109 nav = ('<a href="?cmd=changes;hi=%d">Previous %d</a>&nbsp;&nbsp;' \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
110 % (start, self.numchanges)) + nav
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
111 if hi != count:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
112 if hi + self.numchanges <= count:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
113 nav += '&nbsp;&nbsp;<a href="?cmd=changes;hi=%d">Next %d</a>' \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
114 % (hi + self.numchanges, self.numchanges)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
115 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
116 nav += '&nbsp;&nbsp;<a href="?cmd=changes">Next %d</a>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
117 self.numchanges
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
118
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
119 print '<center>%s</center>' % nav
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
120
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
121 for i in xrange(start, hi):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
122 n = self.repo.changelog.node(i)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
123 cl.append((n, self.repo.changelog.read(n)))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
124 cl.reverse()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
125
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
126 print '<table summary="" width="100%" align="center">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
127 for n, ch in cl:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
128 print '<tr><td>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
129 self.change_table(n, ch)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
130 print '</td></tr>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
131 print '</table>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
132
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
133 print '<center>%s</center>' % nav
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
134
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
135 def change_table(self, nodeid, changes):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
136 hn = hg.hex(nodeid)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
137 i = self.repo.changelog.rev(nodeid)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
138 (h1, h2) = [ hg.hex(x) for x in self.repo.changelog.parents(nodeid) ]
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
139 datestr = time.asctime(time.gmtime(float(changes[2].split(' ')[0])))
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
140 files = []
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
141 for f in changes[3]:
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
142 files.append('<a href="?cmd=file;cs=%s;fn=%s">%s</a>&nbsp;&nbsp;' \
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
143 % (hn, f, cgi.escape(f)))
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
144 write(self.tmpl.do_page('change_table.tmpl',
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
145 author=obfuscate(changes[1]),
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
146 desc=nl2br(cgi.escape(changes[4])), date=datestr,
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
147 files=' '.join(files), revnum=i, revnode=hn))
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
148
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
149 class checkin(page):
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
150 def __init__(self, repo, tmpl_dir, nodestr):
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
151 page.__init__(self, tmpl_dir)
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
152 self.repo = repo
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
153 self.node = hg.bin(nodestr)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
154 self.nodestr = nodestr
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
155 print '<h3>Checkin: %s</h3>' % nodestr
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
156
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
157 def content(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
158 changes = self.repo.changelog.read(self.node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
159 i = self.repo.changelog.rev(self.node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
160 parents = self.repo.changelog.parents(self.node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
161 (h1, h2) = [ hg.hex(x) for x in parents ]
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
162 (i1, i2) = [ self.repo.changelog.rev(x) for x in parents ]
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
163 datestr = time.asctime(time.gmtime(float(changes[2].split(' ')[0])))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
164 mf = self.repo.manifest.read(changes[0])
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
165 files = []
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
166 for f in changes[3]:
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
167 files.append('<a href="?cmd=file;nd=%s;fn=%s">%s</a>&nbsp;&nbsp;' \
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
168 % (hg.hex(mf[f]), f, cgi.escape(f)))
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
169 p2link = h2
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
170 if i2 != -1:
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
171 p2link = '<a href="?cmd=chkin;nd=%s">%s</a>' % (h2, h2)
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
172
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
173 write(self.tmpl.do_page('checkin.tmpl', revnum=i, revnode=self.nodestr,
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
174 p1num=i1, p1node=h1, p2num=i2, p2node=h2, p2link=p2link,
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
175 mfnum=self.repo.manifest.rev(changes[0]),
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
176 mfnode=hg.hex(changes[0]), author=obfuscate(changes[1]),
134
13d609f8d830 fix problem with non wrapping file list
jake@edge2.net
parents: 133
diff changeset
177 desc=nl2br(cgi.escape(changes[4])), date=datestr,
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
178 files=' '.join(files)))
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
179
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
180 (c, a, d) = self.repo.diffrevs(parents[0], self.node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
181 change = self.repo.changelog.read(parents[0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
182 mf2 = self.repo.manifest.read(change[0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
183 for f in c:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
184 self.show_diff(self.repo.file(f).read(mf2[f]), \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
185 self.repo.file(f).read(mf[f]), f)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
186 for f in a:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
187 self.show_diff('', self.repo.file(f).read(mf[f]), f)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
188 for f in d:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
189 self.show_diff(self.repo.file(f).read(mf2[f]), '', f)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
190
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
191 class filepage(page):
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
192 def __init__(self, repo, tmpl_dir, fn, node=None, cs=None):
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
193 page.__init__(self, tmpl_dir)
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
194 self.repo = repo
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
195 self.fn = fn
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
196 if cs:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
197 chng = self.repo.changelog.read(hg.bin(cs))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
198 mf = self.repo.manifest.read(chng[0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
199 self.node = mf[self.fn]
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
200 self.nodestr = hg.hex(self.node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
201 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
202 self.nodestr = node
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
203 self.node = hg.bin(node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
204 print '<div class="filename">%s (%s)</div>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
205 (cgi.escape(self.fn), self.nodestr, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
206 print '<a href="?cmd=hist;fn=%s">history</a><br />' % self.fn
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
207
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
208 def content(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
209 print '<pre>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
210 print cgi.escape(self.repo.file(self.fn).read(self.node))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
211 print '</pre>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
212
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
213 class mfpage(page):
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
214 def __init__(self, repo, tmpl_dir, node):
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
215 page.__init__(self, tmpl_dir)
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
216 self.repo = repo
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
217 self.nodestr = node
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
218 self.node = hg.bin(node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
219
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
220 def content(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
221 mf = self.repo.manifest.read(self.node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
222 fns = mf.keys()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
223 fns.sort()
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
224 write(self.tmpl.do_page('mftitle.tmpl', node = self.nodestr))
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
225 for f in fns:
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
226 write(self.tmpl.do_page('mfentry.tmpl', fn=f, node=hg.hex(mf[f])))
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
227
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
228 class histpage(page):
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
229 def __init__(self, repo, tmpl_dir, fn):
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
230 page.__init__(self, tmpl_dir)
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
231 self.repo = repo
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
232 self.fn = fn
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
233
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
234 def content(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
235 print '<div class="filehist">File History: %s</div>' % self.fn
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
236 r = self.repo.file(self.fn)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
237 print '<br />'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
238 print '<table summary="" width="100%" align="center">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
239 for i in xrange(r.count()-1, -1, -1):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
240 print '<tr><td>'
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
241 self.hist_ent(i, r)
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
242 print '</tr></td>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
243 print '</table>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
244
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
245 def hist_ent(self, i, r):
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
246 n = r.node(i)
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
247 (p1, p2) = r.parents(n)
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
248 (h, h1, h2) = map(hg.hex, (n, p1, p2))
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
249 (i1, i2) = map(r.rev, (p1, p2))
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
250 ci = r.linkrev(n)
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
251 cn = self.repo.changelog.node(ci)
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
252 cs = hg.hex(cn)
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
253 changes = self.repo.changelog.read(cn)
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
254 datestr = time.asctime(time.gmtime(float(changes[2].split(' ')[0])))
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
255 p2entry = ''
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
256 if i2 != -1:
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
257 p2entry = '&nbsp;&nbsp;%d:<a href="?cmd=file;nd=%s;fn=%s">%s</a>' \
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
258 % (i2, h2, self.fn, h2 ),
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
259 write(self.tmpl.do_page('hist_ent.tmpl', author=obfuscate(changes[1]),
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
260 csnode=cs, desc=nl2br(cgi.escape(changes[4])),
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
261 date = datestr, fn=self.fn, revnode=h, p1num = i1,
135
c0faf50822ea change template to a generator
jake@edge2.net
parents: 134
diff changeset
262 p1node=h1, p2entry=p2entry))
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
263
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
264 class hgweb:
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
265 repo_path = "."
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
266 numchanges = 50
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
267 tmpl_dir = "templates"
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
268
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
269 def __init__(self):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
270 pass
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
271
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
272 def run(self):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
273
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
274 args = cgi.parse()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
275
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
276 ui = hg.ui()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
277 repo = hg.repository(ui, self.repo_path)
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
278
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
279 if not args.has_key('cmd') or args['cmd'][0] == 'changes':
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
280 page = change_list(repo, self.tmpl_dir, 'Mercurial',
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
281 self.numchanges)
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
282 hi = args.get('hi', ( repo.changelog.count(), ))
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
283 page.content(hi = int(hi[0]))
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
284 page.endpage()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
285
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
286 elif args['cmd'][0] == 'chkin':
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
287 if not args.has_key('nd'):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
288 page = errpage()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
289 print '<div class="errmsg">No Node!</div>'
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
290 else:
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
291 page = checkin(repo, self.tmpl_dir, args['nd'][0])
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
292 page.content()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
293 page.endpage()
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
294
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
295 elif args['cmd'][0] == 'file':
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
296 if not (args.has_key('nd') and args.has_key('fn')) and \
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
297 not (args.has_key('cs') and args.has_key('fn')):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
298 page = errpage()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
299 print '<div class="errmsg">Invalid Args!</div>'
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
300 else:
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
301 if args.has_key('nd'):
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
302 page = filepage(repo, self.tmpl_dir,
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
303 args['fn'][0], node=args['nd'][0])
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
304 else:
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
305 page = filepage(repo, self.tmpl_dir,
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
306 args['fn'][0], cs=args['cs'][0])
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
307 page.content()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
308 page.endpage()
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
309
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
310 elif args['cmd'][0] == 'mf':
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
311 if not args.has_key('nd'):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
312 page = errpage()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
313 print '<div class="errmsg">No Node!</div>'
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
314 else:
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
315 page = mfpage(repo, self.tmpl_dir, args['nd'][0])
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
316 page.content()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
317 page.endpage()
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
318
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
319 elif args['cmd'][0] == 'hist':
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
320 if not args.has_key('fn'):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
321 page = errpage()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
322 print '<div class="errmsg">No Filename!</div>'
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
323 else:
133
fb84d3e71042 added template support for some hgweb output, also, template files for
jake@edge2.net
parents: 132
diff changeset
324 page = histpage(repo, self.tmpl_dir, args['fn'][0])
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
325 page.content()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
326 page.endpage()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
327
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
328 elif args['cmd'][0] == 'branches':
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
329 httphdr("text/plain")
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
330 nodes = []
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
331 if args.has_key('nodes'):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
332 nodes = map(hg.bin, args['nodes'][0].split(" "))
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
333 for b in repo.branches(nodes):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
334 print " ".join(map(hg.hex, b))
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
335
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
336 elif args['cmd'][0] == 'between':
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
337 httphdr("text/plain")
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
338 nodes = []
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
339 if args.has_key('pairs'):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
340 pairs = [ map(hg.bin, p.split("-"))
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
341 for p in args['pairs'][0].split(" ") ]
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
342 for b in repo.between(pairs):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
343 print " ".join(map(hg.hex, b))
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
344
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
345 elif args['cmd'][0] == 'changegroup':
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
346 httphdr("application/hg-changegroup")
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
347 nodes = []
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
348 if args.has_key('roots'):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
349 nodes = map(hg.bin, args['roots'][0].split(" "))
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
350
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
351 z = zlib.compressobj()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
352 for chunk in repo.changegroup(nodes):
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
353 sys.stdout.write(z.compress(chunk))
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
354
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
355 sys.stdout.write(z.flush())
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
356
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
357 else:
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
358 page = errpage()
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
359 print '<div class="errmsg">unknown command: %s</div>' % \
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
360 cgi.escape(args['cmd'][0])
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
361 page.endpage()
131
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
362
132
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
363 if __name__ == "__main__":
210eeb6f5197 making hgweb class
jake@edge2.net
parents: 131
diff changeset
364 hgweb().run()