annotate mercurial/hgweb.py @ 131:c9d51742471c

moving hgweb to mercurial subdir
author jake@edge2.net
date Sat, 21 May 2005 11:35:26 -0700
parents
children 210eeb6f5197
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 #
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
3 # hgweb.py - 0.1 - 9 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
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 repo_path = "." # change as needed
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
17
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
18 def nl2br(text):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
19 return re.sub('\n', '<br />', text)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
20
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
21 def obfuscate(text):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
22 l = []
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
23 for c in text:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
24 l.append('&#%d;' % ord(c))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
25 return ''.join(l)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
26
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
27 def httphdr(type):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
28 print 'Content-type: %s\n' % type
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
29
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
30 class page:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
31 def __init__(self, type="text/html", title="Mercurial Web",
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
32 charset="ISO-8859-1"):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
33 print 'Content-type: %s; charset=%s\n' % (type, charset)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
34 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
35 print '<HTML>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
36 print '<!-- created by hgweb 0.1 - jake@edge2.net -->'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
37 print '<HEAD><TITLE>%s</TITLE>' % title
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
38 print '<style type="text/css">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
39 print 'body { font-family: sans-serif; font-size: 12px; }'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
40 print 'table { font-size: 12px; }'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
41 print '.errmsg { font-size: 200%; color: red; }'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
42 print '.filename { font-size: 150%; color: purple; }'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
43 print '.manifest { font-size: 150%; color: purple; }'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
44 print '.filehist { font-size: 150%; color: purple; }'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
45 print '.plusline { color: green; }'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
46 print '.minusline { color: red; }'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
47 print '.atline { color: purple; }'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
48 print '</style>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
49 print '</HEAD>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
50 print '<BODY>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
51
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
52 def endpage(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
53 print '</BODY>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
54 print '</HTML>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
55
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
56 def show_diff(self, a, b, fn):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
57 a = a.splitlines(1)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
58 b = b.splitlines(1)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
59 l = difflib.unified_diff(a, b, fn, fn)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
60 print '<pre>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
61 for line in l:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
62 line = cgi.escape(line[:-1])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
63 if line.startswith('+'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
64 print '<span class="plusline">%s</span>' % (line, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
65 elif line.startswith('-'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
66 print '<span class="minusline">%s</span>' % (line, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
67 elif line.startswith('@'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
68 print '<span class="atline">%s</span>' % (line, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
69 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
70 print line
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
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
73 class errpage(page):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
74 def __init__(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
75 page.__init__(self, title="Mercurial Web Error Page")
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
76
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
77 class change_list(page):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
78
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
79 numchanges = 50 # number of changes to show
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
80
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
81 def __init__(self, repo, reponame):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
82 page.__init__(self)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
83 self.repo = repo
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
84 print '<h3>Changes For: %s</h3>' % reponame
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
85
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
86 def content(self, hi=None):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
87 cl = []
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
88 count = self.repo.changelog.count()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
89 if not hi:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
90 hi = count
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
91 elif hi < self.numchanges:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
92 hi = self.numchanges
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
93
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
94 start = 0
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
95 if hi - self.numchanges >= 0:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
96 start = hi - self.numchanges
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
97
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
98 nav = "Displaying Revisions: %d-%d" % (start, hi-1)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
99 if start != 0:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
100 nav = ('<a href="?cmd=changes;hi=%d">Previous %d</a>&nbsp;&nbsp;' \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
101 % (start, self.numchanges)) + nav
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
102 if hi != count:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
103 if hi + self.numchanges <= count:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
104 nav += '&nbsp;&nbsp;<a href="?cmd=changes;hi=%d">Next %d</a>' \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
105 % (hi + self.numchanges, self.numchanges)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
106 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
107 nav += '&nbsp;&nbsp;<a href="?cmd=changes">Next %d</a>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
108 self.numchanges
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
109
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
110 print '<center>%s</center>' % nav
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
111
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
112 for i in xrange(start, hi):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
113 n = self.repo.changelog.node(i)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
114 cl.append((n, self.repo.changelog.read(n)))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
115 cl.reverse()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
116
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
117 print '<table summary="" width="100%" align="center">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
118 for n, ch in cl:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
119 print '<tr><td>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
120 self.change_table(n, ch)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
121 print '</td></tr>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
122 print '</table>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
123
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
124 print '<center>%s</center>' % nav
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 def change_table(self, nodeid, changes):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
127 hn = hg.hex(nodeid)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
128 i = self.repo.changelog.rev(nodeid)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
129 (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
130 datestr = time.asctime(time.gmtime(float(changes[2].split(' ')[0])))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
131 print '<table summary="" width="100%" border="1">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
132 print '\t<tr><td valign="top" width="10%">author:</td>' + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
133 '<td valign="top" width="20%%">%s</td>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
134 (obfuscate(changes[1]), )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
135 print '\t\t<td valign="top" width="10%">description:</td>' + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
136 '<td width="60%">' + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
137 '<a href="?cmd=chkin;nd=%s">%s</a></td></tr>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
138 (hn, nl2br(cgi.escape(changes[4])), )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
139 print '\t<tr><td>date:</td><td>%s UTC</td>' % (datestr, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
140 print '\t\t<td valign="top">files:</td><td valign="top">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
141 for f in changes[3]:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
142 print '\t\t<a href="?cmd=file;cs=%s;fn=%s">%s</a>&nbsp;&nbsp;' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
143 (hn, f, cgi.escape(f), )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
144 print '\t</td></tr>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
145 print '\t<tr><td>revision:</td><td colspan="3">%d:<a ' % (i, ) + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
146 'href="?cmd=chkin;nd=%s">%s</a></td></tr>' % (hn, hn, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
147 print '</table><br />'
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):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
150 def __init__(self, repo, nodestr):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
151 page.__init__(self)
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])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
165 print '<table summary="" width="100%" border="1">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
166 print '\t<tr><td>revision:</td><td colspan="3">%d:' % (i, ),
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
167 print '<a href="?cmd=chkin;nd=%s">%s</a></td></tr>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
168 (self.nodestr, self.nodestr, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
169 print '\t<tr><td>parent(s):</td><td colspan="3">%d:' % (i1, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
170 print '<a href="?cmd=chkin;nd=%s">%s</a>' % (h1, h1, ),
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
171 if i2 != -1:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
172 print '&nbsp;&nbsp;%d:<a href="?cmd=chkin;nd=%s">%s</a>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
173 (i2, h2, h2, ),
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
174 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
175 print '&nbsp;&nbsp;%d:%s' % (i2, h2, ),
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
176 print '</td></tr>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
177 print '\t<tr><td>manifest:</td><td colspan="3">%d:' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
178 (self.repo.manifest.rev(changes[0]), ),
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
179 print '<a href="?cmd=mf;nd=%s">%s</a></td></tr>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
180 (hg.hex(changes[0]), hg.hex(changes[0]), )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
181 print '\t<tr><td valign="top" width="10%">author:</td>' + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
182 '<td valign="top" width="20%%">%s</td>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
183 (obfuscate(changes[1]), )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
184 print '\t\t<td valign="top" width="10%">description:</td>' + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
185 '<td width="60%">' + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
186 '<a href="?cmd=chkin;nd=%s">%s</a></td></tr>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
187 (self.nodestr, nl2br(cgi.escape(changes[4])), )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
188 print '\t<tr><td>date:</td><td>%s UTC</td>' % (datestr, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
189 print '\t\t<td valign="top">files:</td><td valign="top">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
190 for f in changes[3]:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
191 print '\t\t<a href="?cmd=file;nd=%s&fn=%s">%s</a>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
192 (hg.hex(mf[f]), f, cgi.escape(f), ),
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
193 print '&nbsp;&nbsp;'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
194 print '\t</td></tr>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
195 print '</table><br />'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
196
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
197 (c, a, d) = self.repo.diffrevs(parents[0], self.node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
198 change = self.repo.changelog.read(parents[0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
199 mf2 = self.repo.manifest.read(change[0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
200 for f in c:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
201 self.show_diff(self.repo.file(f).read(mf2[f]), \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
202 self.repo.file(f).read(mf[f]), f)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
203 for f in a:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
204 self.show_diff('', self.repo.file(f).read(mf[f]), f)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
205 for f in d:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
206 self.show_diff(self.repo.file(f).read(mf2[f]), '', f)
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 class filepage(page):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
209 def __init__(self, repo, fn, node=None, cs=None):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
210 page.__init__(self)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
211 self.repo = repo
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
212 self.fn = fn
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
213 if cs:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
214 chng = self.repo.changelog.read(hg.bin(cs))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
215 mf = self.repo.manifest.read(chng[0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
216 self.node = mf[self.fn]
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
217 self.nodestr = hg.hex(self.node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
218 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
219 self.nodestr = node
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
220 self.node = hg.bin(node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
221 print '<div class="filename">%s (%s)</div>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
222 (cgi.escape(self.fn), self.nodestr, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
223 print '<a href="?cmd=hist;fn=%s">history</a><br />' % self.fn
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
224
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
225 def content(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
226 print '<pre>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
227 print cgi.escape(self.repo.file(self.fn).read(self.node))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
228 print '</pre>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
229
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
230 class mfpage(page):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
231 def __init__(self, repo, node):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
232 page.__init__(self)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
233 self.repo = repo
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
234 self.nodestr = node
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
235 self.node = hg.bin(node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
236
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
237 def content(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
238 mf = self.repo.manifest.read(self.node)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
239 fns = mf.keys()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
240 fns.sort()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
241 print '<div class="manifest">Manifest (%s)</div>' % self.nodestr
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
242 for f in fns:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
243 print '<a href="?cmd=file;fn=%s;nd=%s">%s</a><br />' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
244 (f, hg.hex(mf[f]), f)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
245
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
246 class histpage(page):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
247 def __init__(self, repo, fn):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
248 page.__init__(self)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
249 self.repo = repo
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
250 self.fn = fn
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
251
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
252 def content(self):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
253 print '<div class="filehist">File History: %s</div>' % self.fn
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
254 r = self.repo.file(self.fn)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
255 print '<br />'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
256 print '<table summary="" width="100%" align="center">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
257 for i in xrange(r.count()-1, -1, -1):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
258 n = r.node(i)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
259 (p1, p2) = r.parents(n)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
260 (h, h1, h2) = map(hg.hex, (n, p1, p2))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
261 (i1, i2) = map(r.rev, (p1, p2))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
262 ci = r.linkrev(n)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
263 cn = self.repo.changelog.node(ci)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
264 cs = hg.hex(cn)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
265 changes = self.repo.changelog.read(cn)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
266 print '<tr><td>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
267 self.hist_ent(i, h, i1, h1, i2, h2, ci, cs, changes)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
268 print '</tr></td>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
269 print '</table>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
270
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
271 def hist_ent(self, revi, revs, p1i, p1s, p2i, p2s, ci, cs, changes):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
272 datestr = time.asctime(time.gmtime(float(changes[2].split(' ')[0])))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
273 print '<table summary="" width="100%" border="1">'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
274 print '\t<tr><td valign="top" width="10%">author:</td>' + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
275 '<td valign="top" width="20%%">%s</td>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
276 (obfuscate(changes[1]), )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
277 print '\t\t<td valign="top" width="10%">description:</td>' + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
278 '<td width="60%">' + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
279 '<a href="?cmd=chkin;nd=%s">%s</a></td></tr>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
280 (cs, nl2br(cgi.escape(changes[4])), )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
281 print '\t<tr><td>date:</td><td>%s UTC</td>' % (datestr, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
282 print '\t\t<td>revision:</td><td>%d:<a ' % (revi, ) + \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
283 'href="?cmd=file;cs=%s;fn=%s">%s</a></td></tr>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
284 (cs, self.fn, revs )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
285 print '\t<tr><td>parent(s):</td><td colspan="3">%d:' % (p1i, )
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
286 print '<a href="?cmd=file;nd=%s;fn=%s">%s</a>' % (p1s, self.fn, p1s, ),
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
287 if p2i != -1:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
288 print '&nbsp;&nbsp;%d:<a href="?cmd=file;nd=%s;fn=%s">%s</a>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
289 (p2i, p2s, self.fn, p2s ),
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
290 print '</td></tr>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
291 print '</table><br />'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
292
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
293 args = cgi.parse()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
294
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
295 ui = hg.ui()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
296 repo = hg.repository(ui, repo_path)
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
297
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
298 if not args.has_key('cmd') or args['cmd'][0] == 'changes':
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
299 page = change_list(repo, 'Mercurial')
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
300 hi = args.get('hi', ( repo.changelog.count(), ))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
301 page.content(hi = int(hi[0]))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
302 page.endpage()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
303
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
304 elif args['cmd'][0] == 'chkin':
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
305 if not args.has_key('nd'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
306 page = errpage()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
307 print '<div class="errmsg">No Node!</div>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
308 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
309 page = checkin(repo, args['nd'][0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
310 page.content()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
311 page.endpage()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
312
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
313 elif args['cmd'][0] == 'file':
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
314 if not (args.has_key('nd') and args.has_key('fn')) and \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
315 not (args.has_key('cs') and args.has_key('fn')):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
316 page = errpage()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
317 print '<div class="errmsg">Invalid Args!</div>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
318 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
319 if args.has_key('nd'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
320 page = filepage(repo, args['fn'][0], node=args['nd'][0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
321 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
322 page = filepage(repo, args['fn'][0], cs=args['cs'][0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
323 page.content()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
324 page.endpage()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
325
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
326 elif args['cmd'][0] == 'mf':
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
327 if not args.has_key('nd'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
328 page = errpage()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
329 print '<div class="errmsg">No Node!</div>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
330 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
331 page = mfpage(repo, args['nd'][0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
332 page.content()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
333 page.endpage()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
334
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
335 elif args['cmd'][0] == 'hist':
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
336 if not args.has_key('fn'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
337 page = errpage()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
338 print '<div class="errmsg">No Filename!</div>'
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
339 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
340 page = histpage(repo, args['fn'][0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
341 page.content()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
342 page.endpage()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
343
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
344 elif args['cmd'][0] == 'branches':
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
345 httphdr("text/plain")
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
346 nodes = []
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
347 if args.has_key('nodes'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
348 nodes = map(hg.bin, args['nodes'][0].split(" "))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
349 for b in repo.branches(nodes):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
350 print " ".join(map(hg.hex, b))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
351
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
352 elif args['cmd'][0] == 'between':
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
353 httphdr("text/plain")
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
354 nodes = []
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
355 if args.has_key('pairs'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
356 pairs = [ map(hg.bin, p.split("-"))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
357 for p in args['pairs'][0].split(" ") ]
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
358 for b in repo.between(pairs):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
359 print " ".join(map(hg.hex, b))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
360
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
361 elif args['cmd'][0] == 'changegroup':
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
362 httphdr("application/hg-changegroup")
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
363 nodes = []
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
364 if args.has_key('roots'):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
365 nodes = map(hg.bin, args['roots'][0].split(" "))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
366
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
367 z = zlib.compressobj()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
368 for chunk in repo.changegroup(nodes):
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
369 sys.stdout.write(z.compress(chunk))
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
370
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
371 sys.stdout.write(z.flush())
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
372
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
373 else:
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
374 page = errpage()
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
375 print '<div class="errmsg">unknown command: %s</div>' % \
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
376 cgi.escape(args['cmd'][0])
c9d51742471c moving hgweb to mercurial subdir
jake@edge2.net
parents:
diff changeset
377 page.endpage()