##// END OF EJS Templates
hgweb: fix summary {tags} and {shortlog} to not forcibly expand template...
Yuya Nishihara -
r37419:7d94fe3e default
parent child Browse files
Show More
@@ -1,1492 +1,1493 b''
1 #
1 #
2 # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
2 # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import copy
10 import copy
11 import mimetypes
11 import mimetypes
12 import os
12 import os
13 import re
13 import re
14
14
15 from ..i18n import _
15 from ..i18n import _
16 from ..node import hex, nullid, short
16 from ..node import hex, nullid, short
17
17
18 from .common import (
18 from .common import (
19 ErrorResponse,
19 ErrorResponse,
20 HTTP_FORBIDDEN,
20 HTTP_FORBIDDEN,
21 HTTP_NOT_FOUND,
21 HTTP_NOT_FOUND,
22 get_contact,
22 get_contact,
23 paritygen,
23 paritygen,
24 staticfile,
24 staticfile,
25 )
25 )
26
26
27 from .. import (
27 from .. import (
28 archival,
28 archival,
29 dagop,
29 dagop,
30 encoding,
30 encoding,
31 error,
31 error,
32 graphmod,
32 graphmod,
33 pycompat,
33 pycompat,
34 revset,
34 revset,
35 revsetlang,
35 revsetlang,
36 scmutil,
36 scmutil,
37 smartset,
37 smartset,
38 templater,
38 templater,
39 templateutil,
39 templateutil,
40 )
40 )
41
41
42 from ..utils import (
42 from ..utils import (
43 stringutil,
43 stringutil,
44 )
44 )
45
45
46 from . import (
46 from . import (
47 webutil,
47 webutil,
48 )
48 )
49
49
50 __all__ = []
50 __all__ = []
51 commands = {}
51 commands = {}
52
52
53 class webcommand(object):
53 class webcommand(object):
54 """Decorator used to register a web command handler.
54 """Decorator used to register a web command handler.
55
55
56 The decorator takes as its positional arguments the name/path the
56 The decorator takes as its positional arguments the name/path the
57 command should be accessible under.
57 command should be accessible under.
58
58
59 When called, functions receive as arguments a ``requestcontext``,
59 When called, functions receive as arguments a ``requestcontext``,
60 ``wsgirequest``, and a templater instance for generatoring output.
60 ``wsgirequest``, and a templater instance for generatoring output.
61 The functions should populate the ``rctx.res`` object with details
61 The functions should populate the ``rctx.res`` object with details
62 about the HTTP response.
62 about the HTTP response.
63
63
64 The function returns a generator to be consumed by the WSGI application.
64 The function returns a generator to be consumed by the WSGI application.
65 For most commands, this should be the result from
65 For most commands, this should be the result from
66 ``web.res.sendresponse()``. Many commands will call ``web.sendtemplate()``
66 ``web.res.sendresponse()``. Many commands will call ``web.sendtemplate()``
67 to render a template.
67 to render a template.
68
68
69 Usage:
69 Usage:
70
70
71 @webcommand('mycommand')
71 @webcommand('mycommand')
72 def mycommand(web):
72 def mycommand(web):
73 pass
73 pass
74 """
74 """
75
75
76 def __init__(self, name):
76 def __init__(self, name):
77 self.name = name
77 self.name = name
78
78
79 def __call__(self, func):
79 def __call__(self, func):
80 __all__.append(self.name)
80 __all__.append(self.name)
81 commands[self.name] = func
81 commands[self.name] = func
82 return func
82 return func
83
83
84 @webcommand('log')
84 @webcommand('log')
85 def log(web):
85 def log(web):
86 """
86 """
87 /log[/{revision}[/{path}]]
87 /log[/{revision}[/{path}]]
88 --------------------------
88 --------------------------
89
89
90 Show repository or file history.
90 Show repository or file history.
91
91
92 For URLs of the form ``/log/{revision}``, a list of changesets starting at
92 For URLs of the form ``/log/{revision}``, a list of changesets starting at
93 the specified changeset identifier is shown. If ``{revision}`` is not
93 the specified changeset identifier is shown. If ``{revision}`` is not
94 defined, the default is ``tip``. This form is equivalent to the
94 defined, the default is ``tip``. This form is equivalent to the
95 ``changelog`` handler.
95 ``changelog`` handler.
96
96
97 For URLs of the form ``/log/{revision}/{file}``, the history for a specific
97 For URLs of the form ``/log/{revision}/{file}``, the history for a specific
98 file will be shown. This form is equivalent to the ``filelog`` handler.
98 file will be shown. This form is equivalent to the ``filelog`` handler.
99 """
99 """
100
100
101 if web.req.qsparams.get('file'):
101 if web.req.qsparams.get('file'):
102 return filelog(web)
102 return filelog(web)
103 else:
103 else:
104 return changelog(web)
104 return changelog(web)
105
105
106 @webcommand('rawfile')
106 @webcommand('rawfile')
107 def rawfile(web):
107 def rawfile(web):
108 guessmime = web.configbool('web', 'guessmime')
108 guessmime = web.configbool('web', 'guessmime')
109
109
110 path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
110 path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
111 if not path:
111 if not path:
112 return manifest(web)
112 return manifest(web)
113
113
114 try:
114 try:
115 fctx = webutil.filectx(web.repo, web.req)
115 fctx = webutil.filectx(web.repo, web.req)
116 except error.LookupError as inst:
116 except error.LookupError as inst:
117 try:
117 try:
118 return manifest(web)
118 return manifest(web)
119 except ErrorResponse:
119 except ErrorResponse:
120 raise inst
120 raise inst
121
121
122 path = fctx.path()
122 path = fctx.path()
123 text = fctx.data()
123 text = fctx.data()
124 mt = 'application/binary'
124 mt = 'application/binary'
125 if guessmime:
125 if guessmime:
126 mt = mimetypes.guess_type(path)[0]
126 mt = mimetypes.guess_type(path)[0]
127 if mt is None:
127 if mt is None:
128 if stringutil.binary(text):
128 if stringutil.binary(text):
129 mt = 'application/binary'
129 mt = 'application/binary'
130 else:
130 else:
131 mt = 'text/plain'
131 mt = 'text/plain'
132 if mt.startswith('text/'):
132 if mt.startswith('text/'):
133 mt += '; charset="%s"' % encoding.encoding
133 mt += '; charset="%s"' % encoding.encoding
134
134
135 web.res.headers['Content-Type'] = mt
135 web.res.headers['Content-Type'] = mt
136 filename = (path.rpartition('/')[-1]
136 filename = (path.rpartition('/')[-1]
137 .replace('\\', '\\\\').replace('"', '\\"'))
137 .replace('\\', '\\\\').replace('"', '\\"'))
138 web.res.headers['Content-Disposition'] = 'inline; filename="%s"' % filename
138 web.res.headers['Content-Disposition'] = 'inline; filename="%s"' % filename
139 web.res.setbodybytes(text)
139 web.res.setbodybytes(text)
140 return web.res.sendresponse()
140 return web.res.sendresponse()
141
141
142 def _filerevision(web, fctx):
142 def _filerevision(web, fctx):
143 f = fctx.path()
143 f = fctx.path()
144 text = fctx.data()
144 text = fctx.data()
145 parity = paritygen(web.stripecount)
145 parity = paritygen(web.stripecount)
146 ishead = fctx.filerev() in fctx.filelog().headrevs()
146 ishead = fctx.filerev() in fctx.filelog().headrevs()
147
147
148 if stringutil.binary(text):
148 if stringutil.binary(text):
149 mt = mimetypes.guess_type(f)[0] or 'application/octet-stream'
149 mt = mimetypes.guess_type(f)[0] or 'application/octet-stream'
150 text = '(binary:%s)' % mt
150 text = '(binary:%s)' % mt
151
151
152 def lines():
152 def lines():
153 for lineno, t in enumerate(text.splitlines(True)):
153 for lineno, t in enumerate(text.splitlines(True)):
154 yield {"line": t,
154 yield {"line": t,
155 "lineid": "l%d" % (lineno + 1),
155 "lineid": "l%d" % (lineno + 1),
156 "linenumber": "% 6d" % (lineno + 1),
156 "linenumber": "% 6d" % (lineno + 1),
157 "parity": next(parity)}
157 "parity": next(parity)}
158
158
159 return web.sendtemplate(
159 return web.sendtemplate(
160 'filerevision',
160 'filerevision',
161 file=f,
161 file=f,
162 path=webutil.up(f),
162 path=webutil.up(f),
163 text=lines(),
163 text=lines(),
164 symrev=webutil.symrevorshortnode(web.req, fctx),
164 symrev=webutil.symrevorshortnode(web.req, fctx),
165 rename=webutil.renamelink(fctx),
165 rename=webutil.renamelink(fctx),
166 permissions=fctx.manifest().flags(f),
166 permissions=fctx.manifest().flags(f),
167 ishead=int(ishead),
167 ishead=int(ishead),
168 **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))
168 **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))
169
169
170 @webcommand('file')
170 @webcommand('file')
171 def file(web):
171 def file(web):
172 """
172 """
173 /file/{revision}[/{path}]
173 /file/{revision}[/{path}]
174 -------------------------
174 -------------------------
175
175
176 Show information about a directory or file in the repository.
176 Show information about a directory or file in the repository.
177
177
178 Info about the ``path`` given as a URL parameter will be rendered.
178 Info about the ``path`` given as a URL parameter will be rendered.
179
179
180 If ``path`` is a directory, information about the entries in that
180 If ``path`` is a directory, information about the entries in that
181 directory will be rendered. This form is equivalent to the ``manifest``
181 directory will be rendered. This form is equivalent to the ``manifest``
182 handler.
182 handler.
183
183
184 If ``path`` is a file, information about that file will be shown via
184 If ``path`` is a file, information about that file will be shown via
185 the ``filerevision`` template.
185 the ``filerevision`` template.
186
186
187 If ``path`` is not defined, information about the root directory will
187 If ``path`` is not defined, information about the root directory will
188 be rendered.
188 be rendered.
189 """
189 """
190 if web.req.qsparams.get('style') == 'raw':
190 if web.req.qsparams.get('style') == 'raw':
191 return rawfile(web)
191 return rawfile(web)
192
192
193 path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
193 path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
194 if not path:
194 if not path:
195 return manifest(web)
195 return manifest(web)
196 try:
196 try:
197 return _filerevision(web, webutil.filectx(web.repo, web.req))
197 return _filerevision(web, webutil.filectx(web.repo, web.req))
198 except error.LookupError as inst:
198 except error.LookupError as inst:
199 try:
199 try:
200 return manifest(web)
200 return manifest(web)
201 except ErrorResponse:
201 except ErrorResponse:
202 raise inst
202 raise inst
203
203
204 def _search(web):
204 def _search(web):
205 MODE_REVISION = 'rev'
205 MODE_REVISION = 'rev'
206 MODE_KEYWORD = 'keyword'
206 MODE_KEYWORD = 'keyword'
207 MODE_REVSET = 'revset'
207 MODE_REVSET = 'revset'
208
208
209 def revsearch(ctx):
209 def revsearch(ctx):
210 yield ctx
210 yield ctx
211
211
212 def keywordsearch(query):
212 def keywordsearch(query):
213 lower = encoding.lower
213 lower = encoding.lower
214 qw = lower(query).split()
214 qw = lower(query).split()
215
215
216 def revgen():
216 def revgen():
217 cl = web.repo.changelog
217 cl = web.repo.changelog
218 for i in xrange(len(web.repo) - 1, 0, -100):
218 for i in xrange(len(web.repo) - 1, 0, -100):
219 l = []
219 l = []
220 for j in cl.revs(max(0, i - 99), i):
220 for j in cl.revs(max(0, i - 99), i):
221 ctx = web.repo[j]
221 ctx = web.repo[j]
222 l.append(ctx)
222 l.append(ctx)
223 l.reverse()
223 l.reverse()
224 for e in l:
224 for e in l:
225 yield e
225 yield e
226
226
227 for ctx in revgen():
227 for ctx in revgen():
228 miss = 0
228 miss = 0
229 for q in qw:
229 for q in qw:
230 if not (q in lower(ctx.user()) or
230 if not (q in lower(ctx.user()) or
231 q in lower(ctx.description()) or
231 q in lower(ctx.description()) or
232 q in lower(" ".join(ctx.files()))):
232 q in lower(" ".join(ctx.files()))):
233 miss = 1
233 miss = 1
234 break
234 break
235 if miss:
235 if miss:
236 continue
236 continue
237
237
238 yield ctx
238 yield ctx
239
239
240 def revsetsearch(revs):
240 def revsetsearch(revs):
241 for r in revs:
241 for r in revs:
242 yield web.repo[r]
242 yield web.repo[r]
243
243
244 searchfuncs = {
244 searchfuncs = {
245 MODE_REVISION: (revsearch, 'exact revision search'),
245 MODE_REVISION: (revsearch, 'exact revision search'),
246 MODE_KEYWORD: (keywordsearch, 'literal keyword search'),
246 MODE_KEYWORD: (keywordsearch, 'literal keyword search'),
247 MODE_REVSET: (revsetsearch, 'revset expression search'),
247 MODE_REVSET: (revsetsearch, 'revset expression search'),
248 }
248 }
249
249
250 def getsearchmode(query):
250 def getsearchmode(query):
251 try:
251 try:
252 ctx = scmutil.revsymbol(web.repo, query)
252 ctx = scmutil.revsymbol(web.repo, query)
253 except (error.RepoError, error.LookupError):
253 except (error.RepoError, error.LookupError):
254 # query is not an exact revision pointer, need to
254 # query is not an exact revision pointer, need to
255 # decide if it's a revset expression or keywords
255 # decide if it's a revset expression or keywords
256 pass
256 pass
257 else:
257 else:
258 return MODE_REVISION, ctx
258 return MODE_REVISION, ctx
259
259
260 revdef = 'reverse(%s)' % query
260 revdef = 'reverse(%s)' % query
261 try:
261 try:
262 tree = revsetlang.parse(revdef)
262 tree = revsetlang.parse(revdef)
263 except error.ParseError:
263 except error.ParseError:
264 # can't parse to a revset tree
264 # can't parse to a revset tree
265 return MODE_KEYWORD, query
265 return MODE_KEYWORD, query
266
266
267 if revsetlang.depth(tree) <= 2:
267 if revsetlang.depth(tree) <= 2:
268 # no revset syntax used
268 # no revset syntax used
269 return MODE_KEYWORD, query
269 return MODE_KEYWORD, query
270
270
271 if any((token, (value or '')[:3]) == ('string', 're:')
271 if any((token, (value or '')[:3]) == ('string', 're:')
272 for token, value, pos in revsetlang.tokenize(revdef)):
272 for token, value, pos in revsetlang.tokenize(revdef)):
273 return MODE_KEYWORD, query
273 return MODE_KEYWORD, query
274
274
275 funcsused = revsetlang.funcsused(tree)
275 funcsused = revsetlang.funcsused(tree)
276 if not funcsused.issubset(revset.safesymbols):
276 if not funcsused.issubset(revset.safesymbols):
277 return MODE_KEYWORD, query
277 return MODE_KEYWORD, query
278
278
279 mfunc = revset.match(web.repo.ui, revdef, repo=web.repo)
279 mfunc = revset.match(web.repo.ui, revdef, repo=web.repo)
280 try:
280 try:
281 revs = mfunc(web.repo)
281 revs = mfunc(web.repo)
282 return MODE_REVSET, revs
282 return MODE_REVSET, revs
283 # ParseError: wrongly placed tokens, wrongs arguments, etc
283 # ParseError: wrongly placed tokens, wrongs arguments, etc
284 # RepoLookupError: no such revision, e.g. in 'revision:'
284 # RepoLookupError: no such revision, e.g. in 'revision:'
285 # Abort: bookmark/tag not exists
285 # Abort: bookmark/tag not exists
286 # LookupError: ambiguous identifier, e.g. in '(bc)' on a large repo
286 # LookupError: ambiguous identifier, e.g. in '(bc)' on a large repo
287 except (error.ParseError, error.RepoLookupError, error.Abort,
287 except (error.ParseError, error.RepoLookupError, error.Abort,
288 LookupError):
288 LookupError):
289 return MODE_KEYWORD, query
289 return MODE_KEYWORD, query
290
290
291 def changelist(context):
291 def changelist(context):
292 count = 0
292 count = 0
293
293
294 for ctx in searchfunc[0](funcarg):
294 for ctx in searchfunc[0](funcarg):
295 count += 1
295 count += 1
296 n = ctx.node()
296 n = ctx.node()
297 showtags = webutil.showtag(web.repo, web.tmpl, 'changelogtag', n)
297 showtags = webutil.showtag(web.repo, web.tmpl, 'changelogtag', n)
298 files = webutil.listfilediffs(web.tmpl, ctx.files(), n,
298 files = webutil.listfilediffs(web.tmpl, ctx.files(), n,
299 web.maxfiles)
299 web.maxfiles)
300
300
301 lm = webutil.commonentry(web.repo, ctx)
301 lm = webutil.commonentry(web.repo, ctx)
302 lm.update({
302 lm.update({
303 'parity': next(parity),
303 'parity': next(parity),
304 'changelogtag': showtags,
304 'changelogtag': showtags,
305 'files': files,
305 'files': files,
306 })
306 })
307 yield lm
307 yield lm
308
308
309 if count >= revcount:
309 if count >= revcount:
310 break
310 break
311
311
312 query = web.req.qsparams['rev']
312 query = web.req.qsparams['rev']
313 revcount = web.maxchanges
313 revcount = web.maxchanges
314 if 'revcount' in web.req.qsparams:
314 if 'revcount' in web.req.qsparams:
315 try:
315 try:
316 revcount = int(web.req.qsparams.get('revcount', revcount))
316 revcount = int(web.req.qsparams.get('revcount', revcount))
317 revcount = max(revcount, 1)
317 revcount = max(revcount, 1)
318 web.tmpl.defaults['sessionvars']['revcount'] = revcount
318 web.tmpl.defaults['sessionvars']['revcount'] = revcount
319 except ValueError:
319 except ValueError:
320 pass
320 pass
321
321
322 lessvars = copy.copy(web.tmpl.defaults['sessionvars'])
322 lessvars = copy.copy(web.tmpl.defaults['sessionvars'])
323 lessvars['revcount'] = max(revcount // 2, 1)
323 lessvars['revcount'] = max(revcount // 2, 1)
324 lessvars['rev'] = query
324 lessvars['rev'] = query
325 morevars = copy.copy(web.tmpl.defaults['sessionvars'])
325 morevars = copy.copy(web.tmpl.defaults['sessionvars'])
326 morevars['revcount'] = revcount * 2
326 morevars['revcount'] = revcount * 2
327 morevars['rev'] = query
327 morevars['rev'] = query
328
328
329 mode, funcarg = getsearchmode(query)
329 mode, funcarg = getsearchmode(query)
330
330
331 if 'forcekw' in web.req.qsparams:
331 if 'forcekw' in web.req.qsparams:
332 showforcekw = ''
332 showforcekw = ''
333 showunforcekw = searchfuncs[mode][1]
333 showunforcekw = searchfuncs[mode][1]
334 mode = MODE_KEYWORD
334 mode = MODE_KEYWORD
335 funcarg = query
335 funcarg = query
336 else:
336 else:
337 if mode != MODE_KEYWORD:
337 if mode != MODE_KEYWORD:
338 showforcekw = searchfuncs[MODE_KEYWORD][1]
338 showforcekw = searchfuncs[MODE_KEYWORD][1]
339 else:
339 else:
340 showforcekw = ''
340 showforcekw = ''
341 showunforcekw = ''
341 showunforcekw = ''
342
342
343 searchfunc = searchfuncs[mode]
343 searchfunc = searchfuncs[mode]
344
344
345 tip = web.repo['tip']
345 tip = web.repo['tip']
346 parity = paritygen(web.stripecount)
346 parity = paritygen(web.stripecount)
347
347
348 return web.sendtemplate(
348 return web.sendtemplate(
349 'search',
349 'search',
350 query=query,
350 query=query,
351 node=tip.hex(),
351 node=tip.hex(),
352 symrev='tip',
352 symrev='tip',
353 entries=templateutil.mappinggenerator(changelist, name='searchentry'),
353 entries=templateutil.mappinggenerator(changelist, name='searchentry'),
354 archives=web.archivelist('tip'),
354 archives=web.archivelist('tip'),
355 morevars=morevars,
355 morevars=morevars,
356 lessvars=lessvars,
356 lessvars=lessvars,
357 modedesc=searchfunc[1],
357 modedesc=searchfunc[1],
358 showforcekw=showforcekw,
358 showforcekw=showforcekw,
359 showunforcekw=showunforcekw)
359 showunforcekw=showunforcekw)
360
360
361 @webcommand('changelog')
361 @webcommand('changelog')
362 def changelog(web, shortlog=False):
362 def changelog(web, shortlog=False):
363 """
363 """
364 /changelog[/{revision}]
364 /changelog[/{revision}]
365 -----------------------
365 -----------------------
366
366
367 Show information about multiple changesets.
367 Show information about multiple changesets.
368
368
369 If the optional ``revision`` URL argument is absent, information about
369 If the optional ``revision`` URL argument is absent, information about
370 all changesets starting at ``tip`` will be rendered. If the ``revision``
370 all changesets starting at ``tip`` will be rendered. If the ``revision``
371 argument is present, changesets will be shown starting from the specified
371 argument is present, changesets will be shown starting from the specified
372 revision.
372 revision.
373
373
374 If ``revision`` is absent, the ``rev`` query string argument may be
374 If ``revision`` is absent, the ``rev`` query string argument may be
375 defined. This will perform a search for changesets.
375 defined. This will perform a search for changesets.
376
376
377 The argument for ``rev`` can be a single revision, a revision set,
377 The argument for ``rev`` can be a single revision, a revision set,
378 or a literal keyword to search for in changeset data (equivalent to
378 or a literal keyword to search for in changeset data (equivalent to
379 :hg:`log -k`).
379 :hg:`log -k`).
380
380
381 The ``revcount`` query string argument defines the maximum numbers of
381 The ``revcount`` query string argument defines the maximum numbers of
382 changesets to render.
382 changesets to render.
383
383
384 For non-searches, the ``changelog`` template will be rendered.
384 For non-searches, the ``changelog`` template will be rendered.
385 """
385 """
386
386
387 query = ''
387 query = ''
388 if 'node' in web.req.qsparams:
388 if 'node' in web.req.qsparams:
389 ctx = webutil.changectx(web.repo, web.req)
389 ctx = webutil.changectx(web.repo, web.req)
390 symrev = webutil.symrevorshortnode(web.req, ctx)
390 symrev = webutil.symrevorshortnode(web.req, ctx)
391 elif 'rev' in web.req.qsparams:
391 elif 'rev' in web.req.qsparams:
392 return _search(web)
392 return _search(web)
393 else:
393 else:
394 ctx = web.repo['tip']
394 ctx = web.repo['tip']
395 symrev = 'tip'
395 symrev = 'tip'
396
396
397 def changelist():
397 def changelist():
398 revs = []
398 revs = []
399 if pos != -1:
399 if pos != -1:
400 revs = web.repo.changelog.revs(pos, 0)
400 revs = web.repo.changelog.revs(pos, 0)
401 curcount = 0
401 curcount = 0
402 for rev in revs:
402 for rev in revs:
403 curcount += 1
403 curcount += 1
404 if curcount > revcount + 1:
404 if curcount > revcount + 1:
405 break
405 break
406
406
407 entry = webutil.changelistentry(web, web.repo[rev])
407 entry = webutil.changelistentry(web, web.repo[rev])
408 entry['parity'] = next(parity)
408 entry['parity'] = next(parity)
409 yield entry
409 yield entry
410
410
411 if shortlog:
411 if shortlog:
412 revcount = web.maxshortchanges
412 revcount = web.maxshortchanges
413 else:
413 else:
414 revcount = web.maxchanges
414 revcount = web.maxchanges
415
415
416 if 'revcount' in web.req.qsparams:
416 if 'revcount' in web.req.qsparams:
417 try:
417 try:
418 revcount = int(web.req.qsparams.get('revcount', revcount))
418 revcount = int(web.req.qsparams.get('revcount', revcount))
419 revcount = max(revcount, 1)
419 revcount = max(revcount, 1)
420 web.tmpl.defaults['sessionvars']['revcount'] = revcount
420 web.tmpl.defaults['sessionvars']['revcount'] = revcount
421 except ValueError:
421 except ValueError:
422 pass
422 pass
423
423
424 lessvars = copy.copy(web.tmpl.defaults['sessionvars'])
424 lessvars = copy.copy(web.tmpl.defaults['sessionvars'])
425 lessvars['revcount'] = max(revcount // 2, 1)
425 lessvars['revcount'] = max(revcount // 2, 1)
426 morevars = copy.copy(web.tmpl.defaults['sessionvars'])
426 morevars = copy.copy(web.tmpl.defaults['sessionvars'])
427 morevars['revcount'] = revcount * 2
427 morevars['revcount'] = revcount * 2
428
428
429 count = len(web.repo)
429 count = len(web.repo)
430 pos = ctx.rev()
430 pos = ctx.rev()
431 parity = paritygen(web.stripecount)
431 parity = paritygen(web.stripecount)
432
432
433 changenav = webutil.revnav(web.repo).gen(pos, revcount, count)
433 changenav = webutil.revnav(web.repo).gen(pos, revcount, count)
434
434
435 entries = list(changelist())
435 entries = list(changelist())
436 latestentry = entries[:1]
436 latestentry = entries[:1]
437 if len(entries) > revcount:
437 if len(entries) > revcount:
438 nextentry = entries[-1:]
438 nextentry = entries[-1:]
439 entries = entries[:-1]
439 entries = entries[:-1]
440 else:
440 else:
441 nextentry = []
441 nextentry = []
442
442
443 return web.sendtemplate(
443 return web.sendtemplate(
444 'shortlog' if shortlog else 'changelog',
444 'shortlog' if shortlog else 'changelog',
445 changenav=changenav,
445 changenav=changenav,
446 node=ctx.hex(),
446 node=ctx.hex(),
447 rev=pos,
447 rev=pos,
448 symrev=symrev,
448 symrev=symrev,
449 changesets=count,
449 changesets=count,
450 entries=entries,
450 entries=entries,
451 latestentry=latestentry,
451 latestentry=latestentry,
452 nextentry=nextentry,
452 nextentry=nextentry,
453 archives=web.archivelist('tip'),
453 archives=web.archivelist('tip'),
454 revcount=revcount,
454 revcount=revcount,
455 morevars=morevars,
455 morevars=morevars,
456 lessvars=lessvars,
456 lessvars=lessvars,
457 query=query)
457 query=query)
458
458
459 @webcommand('shortlog')
459 @webcommand('shortlog')
460 def shortlog(web):
460 def shortlog(web):
461 """
461 """
462 /shortlog
462 /shortlog
463 ---------
463 ---------
464
464
465 Show basic information about a set of changesets.
465 Show basic information about a set of changesets.
466
466
467 This accepts the same parameters as the ``changelog`` handler. The only
467 This accepts the same parameters as the ``changelog`` handler. The only
468 difference is the ``shortlog`` template will be rendered instead of the
468 difference is the ``shortlog`` template will be rendered instead of the
469 ``changelog`` template.
469 ``changelog`` template.
470 """
470 """
471 return changelog(web, shortlog=True)
471 return changelog(web, shortlog=True)
472
472
473 @webcommand('changeset')
473 @webcommand('changeset')
474 def changeset(web):
474 def changeset(web):
475 """
475 """
476 /changeset[/{revision}]
476 /changeset[/{revision}]
477 -----------------------
477 -----------------------
478
478
479 Show information about a single changeset.
479 Show information about a single changeset.
480
480
481 A URL path argument is the changeset identifier to show. See ``hg help
481 A URL path argument is the changeset identifier to show. See ``hg help
482 revisions`` for possible values. If not defined, the ``tip`` changeset
482 revisions`` for possible values. If not defined, the ``tip`` changeset
483 will be shown.
483 will be shown.
484
484
485 The ``changeset`` template is rendered. Contents of the ``changesettag``,
485 The ``changeset`` template is rendered. Contents of the ``changesettag``,
486 ``changesetbookmark``, ``filenodelink``, ``filenolink``, and the many
486 ``changesetbookmark``, ``filenodelink``, ``filenolink``, and the many
487 templates related to diffs may all be used to produce the output.
487 templates related to diffs may all be used to produce the output.
488 """
488 """
489 ctx = webutil.changectx(web.repo, web.req)
489 ctx = webutil.changectx(web.repo, web.req)
490
490
491 return web.sendtemplate(
491 return web.sendtemplate(
492 'changeset',
492 'changeset',
493 **webutil.changesetentry(web, ctx))
493 **webutil.changesetentry(web, ctx))
494
494
495 rev = webcommand('rev')(changeset)
495 rev = webcommand('rev')(changeset)
496
496
497 def decodepath(path):
497 def decodepath(path):
498 """Hook for mapping a path in the repository to a path in the
498 """Hook for mapping a path in the repository to a path in the
499 working copy.
499 working copy.
500
500
501 Extensions (e.g., largefiles) can override this to remap files in
501 Extensions (e.g., largefiles) can override this to remap files in
502 the virtual file system presented by the manifest command below."""
502 the virtual file system presented by the manifest command below."""
503 return path
503 return path
504
504
505 @webcommand('manifest')
505 @webcommand('manifest')
506 def manifest(web):
506 def manifest(web):
507 """
507 """
508 /manifest[/{revision}[/{path}]]
508 /manifest[/{revision}[/{path}]]
509 -------------------------------
509 -------------------------------
510
510
511 Show information about a directory.
511 Show information about a directory.
512
512
513 If the URL path arguments are omitted, information about the root
513 If the URL path arguments are omitted, information about the root
514 directory for the ``tip`` changeset will be shown.
514 directory for the ``tip`` changeset will be shown.
515
515
516 Because this handler can only show information for directories, it
516 Because this handler can only show information for directories, it
517 is recommended to use the ``file`` handler instead, as it can handle both
517 is recommended to use the ``file`` handler instead, as it can handle both
518 directories and files.
518 directories and files.
519
519
520 The ``manifest`` template will be rendered for this handler.
520 The ``manifest`` template will be rendered for this handler.
521 """
521 """
522 if 'node' in web.req.qsparams:
522 if 'node' in web.req.qsparams:
523 ctx = webutil.changectx(web.repo, web.req)
523 ctx = webutil.changectx(web.repo, web.req)
524 symrev = webutil.symrevorshortnode(web.req, ctx)
524 symrev = webutil.symrevorshortnode(web.req, ctx)
525 else:
525 else:
526 ctx = web.repo['tip']
526 ctx = web.repo['tip']
527 symrev = 'tip'
527 symrev = 'tip'
528 path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
528 path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', ''))
529 mf = ctx.manifest()
529 mf = ctx.manifest()
530 node = ctx.node()
530 node = ctx.node()
531
531
532 files = {}
532 files = {}
533 dirs = {}
533 dirs = {}
534 parity = paritygen(web.stripecount)
534 parity = paritygen(web.stripecount)
535
535
536 if path and path[-1:] != "/":
536 if path and path[-1:] != "/":
537 path += "/"
537 path += "/"
538 l = len(path)
538 l = len(path)
539 abspath = "/" + path
539 abspath = "/" + path
540
540
541 for full, n in mf.iteritems():
541 for full, n in mf.iteritems():
542 # the virtual path (working copy path) used for the full
542 # the virtual path (working copy path) used for the full
543 # (repository) path
543 # (repository) path
544 f = decodepath(full)
544 f = decodepath(full)
545
545
546 if f[:l] != path:
546 if f[:l] != path:
547 continue
547 continue
548 remain = f[l:]
548 remain = f[l:]
549 elements = remain.split('/')
549 elements = remain.split('/')
550 if len(elements) == 1:
550 if len(elements) == 1:
551 files[remain] = full
551 files[remain] = full
552 else:
552 else:
553 h = dirs # need to retain ref to dirs (root)
553 h = dirs # need to retain ref to dirs (root)
554 for elem in elements[0:-1]:
554 for elem in elements[0:-1]:
555 if elem not in h:
555 if elem not in h:
556 h[elem] = {}
556 h[elem] = {}
557 h = h[elem]
557 h = h[elem]
558 if len(h) > 1:
558 if len(h) > 1:
559 break
559 break
560 h[None] = None # denotes files present
560 h[None] = None # denotes files present
561
561
562 if mf and not files and not dirs:
562 if mf and not files and not dirs:
563 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
563 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
564
564
565 def filelist(**map):
565 def filelist(**map):
566 for f in sorted(files):
566 for f in sorted(files):
567 full = files[f]
567 full = files[f]
568
568
569 fctx = ctx.filectx(full)
569 fctx = ctx.filectx(full)
570 yield {"file": full,
570 yield {"file": full,
571 "parity": next(parity),
571 "parity": next(parity),
572 "basename": f,
572 "basename": f,
573 "date": fctx.date(),
573 "date": fctx.date(),
574 "size": fctx.size(),
574 "size": fctx.size(),
575 "permissions": mf.flags(full)}
575 "permissions": mf.flags(full)}
576
576
577 def dirlist(**map):
577 def dirlist(**map):
578 for d in sorted(dirs):
578 for d in sorted(dirs):
579
579
580 emptydirs = []
580 emptydirs = []
581 h = dirs[d]
581 h = dirs[d]
582 while isinstance(h, dict) and len(h) == 1:
582 while isinstance(h, dict) and len(h) == 1:
583 k, v = next(iter(h.items()))
583 k, v = next(iter(h.items()))
584 if v:
584 if v:
585 emptydirs.append(k)
585 emptydirs.append(k)
586 h = v
586 h = v
587
587
588 path = "%s%s" % (abspath, d)
588 path = "%s%s" % (abspath, d)
589 yield {"parity": next(parity),
589 yield {"parity": next(parity),
590 "path": path,
590 "path": path,
591 "emptydirs": "/".join(emptydirs),
591 "emptydirs": "/".join(emptydirs),
592 "basename": d}
592 "basename": d}
593
593
594 return web.sendtemplate(
594 return web.sendtemplate(
595 'manifest',
595 'manifest',
596 symrev=symrev,
596 symrev=symrev,
597 path=abspath,
597 path=abspath,
598 up=webutil.up(abspath),
598 up=webutil.up(abspath),
599 upparity=next(parity),
599 upparity=next(parity),
600 fentries=filelist,
600 fentries=filelist,
601 dentries=dirlist,
601 dentries=dirlist,
602 archives=web.archivelist(hex(node)),
602 archives=web.archivelist(hex(node)),
603 **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))
603 **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))
604
604
605 @webcommand('tags')
605 @webcommand('tags')
606 def tags(web):
606 def tags(web):
607 """
607 """
608 /tags
608 /tags
609 -----
609 -----
610
610
611 Show information about tags.
611 Show information about tags.
612
612
613 No arguments are accepted.
613 No arguments are accepted.
614
614
615 The ``tags`` template is rendered.
615 The ``tags`` template is rendered.
616 """
616 """
617 i = list(reversed(web.repo.tagslist()))
617 i = list(reversed(web.repo.tagslist()))
618 parity = paritygen(web.stripecount)
618 parity = paritygen(web.stripecount)
619
619
620 def entries(notip, latestonly, **map):
620 def entries(notip, latestonly, **map):
621 t = i
621 t = i
622 if notip:
622 if notip:
623 t = [(k, n) for k, n in i if k != "tip"]
623 t = [(k, n) for k, n in i if k != "tip"]
624 if latestonly:
624 if latestonly:
625 t = t[:1]
625 t = t[:1]
626 for k, n in t:
626 for k, n in t:
627 yield {"parity": next(parity),
627 yield {"parity": next(parity),
628 "tag": k,
628 "tag": k,
629 "date": web.repo[n].date(),
629 "date": web.repo[n].date(),
630 "node": hex(n)}
630 "node": hex(n)}
631
631
632 return web.sendtemplate(
632 return web.sendtemplate(
633 'tags',
633 'tags',
634 node=hex(web.repo.changelog.tip()),
634 node=hex(web.repo.changelog.tip()),
635 entries=lambda **x: entries(False, False, **x),
635 entries=lambda **x: entries(False, False, **x),
636 entriesnotip=lambda **x: entries(True, False, **x),
636 entriesnotip=lambda **x: entries(True, False, **x),
637 latestentry=lambda **x: entries(True, True, **x))
637 latestentry=lambda **x: entries(True, True, **x))
638
638
639 @webcommand('bookmarks')
639 @webcommand('bookmarks')
640 def bookmarks(web):
640 def bookmarks(web):
641 """
641 """
642 /bookmarks
642 /bookmarks
643 ----------
643 ----------
644
644
645 Show information about bookmarks.
645 Show information about bookmarks.
646
646
647 No arguments are accepted.
647 No arguments are accepted.
648
648
649 The ``bookmarks`` template is rendered.
649 The ``bookmarks`` template is rendered.
650 """
650 """
651 i = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
651 i = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
652 sortkey = lambda b: (web.repo[b[1]].rev(), b[0])
652 sortkey = lambda b: (web.repo[b[1]].rev(), b[0])
653 i = sorted(i, key=sortkey, reverse=True)
653 i = sorted(i, key=sortkey, reverse=True)
654 parity = paritygen(web.stripecount)
654 parity = paritygen(web.stripecount)
655
655
656 def entries(latestonly, **map):
656 def entries(latestonly, **map):
657 t = i
657 t = i
658 if latestonly:
658 if latestonly:
659 t = i[:1]
659 t = i[:1]
660 for k, n in t:
660 for k, n in t:
661 yield {"parity": next(parity),
661 yield {"parity": next(parity),
662 "bookmark": k,
662 "bookmark": k,
663 "date": web.repo[n].date(),
663 "date": web.repo[n].date(),
664 "node": hex(n)}
664 "node": hex(n)}
665
665
666 if i:
666 if i:
667 latestrev = i[0][1]
667 latestrev = i[0][1]
668 else:
668 else:
669 latestrev = -1
669 latestrev = -1
670
670
671 return web.sendtemplate(
671 return web.sendtemplate(
672 'bookmarks',
672 'bookmarks',
673 node=hex(web.repo.changelog.tip()),
673 node=hex(web.repo.changelog.tip()),
674 lastchange=[{'date': web.repo[latestrev].date()}],
674 lastchange=[{'date': web.repo[latestrev].date()}],
675 entries=lambda **x: entries(latestonly=False, **x),
675 entries=lambda **x: entries(latestonly=False, **x),
676 latestentry=lambda **x: entries(latestonly=True, **x))
676 latestentry=lambda **x: entries(latestonly=True, **x))
677
677
678 @webcommand('branches')
678 @webcommand('branches')
679 def branches(web):
679 def branches(web):
680 """
680 """
681 /branches
681 /branches
682 ---------
682 ---------
683
683
684 Show information about branches.
684 Show information about branches.
685
685
686 All known branches are contained in the output, even closed branches.
686 All known branches are contained in the output, even closed branches.
687
687
688 No arguments are accepted.
688 No arguments are accepted.
689
689
690 The ``branches`` template is rendered.
690 The ``branches`` template is rendered.
691 """
691 """
692 entries = webutil.branchentries(web.repo, web.stripecount)
692 entries = webutil.branchentries(web.repo, web.stripecount)
693 latestentry = webutil.branchentries(web.repo, web.stripecount, 1)
693 latestentry = webutil.branchentries(web.repo, web.stripecount, 1)
694
694
695 return web.sendtemplate(
695 return web.sendtemplate(
696 'branches',
696 'branches',
697 node=hex(web.repo.changelog.tip()),
697 node=hex(web.repo.changelog.tip()),
698 entries=entries,
698 entries=entries,
699 latestentry=latestentry)
699 latestentry=latestentry)
700
700
701 @webcommand('summary')
701 @webcommand('summary')
702 def summary(web):
702 def summary(web):
703 """
703 """
704 /summary
704 /summary
705 --------
705 --------
706
706
707 Show a summary of repository state.
707 Show a summary of repository state.
708
708
709 Information about the latest changesets, bookmarks, tags, and branches
709 Information about the latest changesets, bookmarks, tags, and branches
710 is captured by this handler.
710 is captured by this handler.
711
711
712 The ``summary`` template is rendered.
712 The ``summary`` template is rendered.
713 """
713 """
714 i = reversed(web.repo.tagslist())
714 i = reversed(web.repo.tagslist())
715
715
716 def tagentries(**map):
716 def tagentries(context):
717 parity = paritygen(web.stripecount)
717 parity = paritygen(web.stripecount)
718 count = 0
718 count = 0
719 for k, n in i:
719 for k, n in i:
720 if k == "tip": # skip tip
720 if k == "tip": # skip tip
721 continue
721 continue
722
722
723 count += 1
723 count += 1
724 if count > 10: # limit to 10 tags
724 if count > 10: # limit to 10 tags
725 break
725 break
726
726
727 yield web.tmpl.generate('tagentry', {
727 yield {
728 'parity': next(parity),
728 'parity': next(parity),
729 'tag': k,
729 'tag': k,
730 'node': hex(n),
730 'node': hex(n),
731 'date': web.repo[n].date(),
731 'date': web.repo[n].date(),
732 })
732 }
733
733
734 def bookmarks(**map):
734 def bookmarks(**map):
735 parity = paritygen(web.stripecount)
735 parity = paritygen(web.stripecount)
736 marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
736 marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
737 sortkey = lambda b: (web.repo[b[1]].rev(), b[0])
737 sortkey = lambda b: (web.repo[b[1]].rev(), b[0])
738 marks = sorted(marks, key=sortkey, reverse=True)
738 marks = sorted(marks, key=sortkey, reverse=True)
739 for k, n in marks[:10]: # limit to 10 bookmarks
739 for k, n in marks[:10]: # limit to 10 bookmarks
740 yield {'parity': next(parity),
740 yield {'parity': next(parity),
741 'bookmark': k,
741 'bookmark': k,
742 'date': web.repo[n].date(),
742 'date': web.repo[n].date(),
743 'node': hex(n)}
743 'node': hex(n)}
744
744
745 def changelist(**map):
745 def changelist(context):
746 parity = paritygen(web.stripecount, offset=start - end)
746 parity = paritygen(web.stripecount, offset=start - end)
747 l = [] # build a list in forward order for efficiency
747 l = [] # build a list in forward order for efficiency
748 revs = []
748 revs = []
749 if start < end:
749 if start < end:
750 revs = web.repo.changelog.revs(start, end - 1)
750 revs = web.repo.changelog.revs(start, end - 1)
751 for i in revs:
751 for i in revs:
752 ctx = web.repo[i]
752 ctx = web.repo[i]
753 lm = webutil.commonentry(web.repo, ctx)
753 lm = webutil.commonentry(web.repo, ctx)
754 lm['parity'] = next(parity)
754 lm['parity'] = next(parity)
755 l.append(web.tmpl.generate('shortlogentry', lm))
755 l.append(lm)
756
756
757 for entry in reversed(l):
757 for entry in reversed(l):
758 yield entry
758 yield entry
759
759
760 tip = web.repo['tip']
760 tip = web.repo['tip']
761 count = len(web.repo)
761 count = len(web.repo)
762 start = max(0, count - web.maxchanges)
762 start = max(0, count - web.maxchanges)
763 end = min(count, start + web.maxchanges)
763 end = min(count, start + web.maxchanges)
764
764
765 desc = web.config("web", "description")
765 desc = web.config("web", "description")
766 if not desc:
766 if not desc:
767 desc = 'unknown'
767 desc = 'unknown'
768
768
769 return web.sendtemplate(
769 return web.sendtemplate(
770 'summary',
770 'summary',
771 desc=desc,
771 desc=desc,
772 owner=get_contact(web.config) or 'unknown',
772 owner=get_contact(web.config) or 'unknown',
773 lastchange=tip.date(),
773 lastchange=tip.date(),
774 tags=tagentries,
774 tags=templateutil.mappinggenerator(tagentries, name='tagentry'),
775 bookmarks=bookmarks,
775 bookmarks=bookmarks,
776 branches=webutil.branchentries(web.repo, web.stripecount, 10),
776 branches=webutil.branchentries(web.repo, web.stripecount, 10),
777 shortlog=changelist,
777 shortlog=templateutil.mappinggenerator(changelist,
778 name='shortlogentry'),
778 node=tip.hex(),
779 node=tip.hex(),
779 symrev='tip',
780 symrev='tip',
780 archives=web.archivelist('tip'),
781 archives=web.archivelist('tip'),
781 labels=web.configlist('web', 'labels'))
782 labels=web.configlist('web', 'labels'))
782
783
783 @webcommand('filediff')
784 @webcommand('filediff')
784 def filediff(web):
785 def filediff(web):
785 """
786 """
786 /diff/{revision}/{path}
787 /diff/{revision}/{path}
787 -----------------------
788 -----------------------
788
789
789 Show how a file changed in a particular commit.
790 Show how a file changed in a particular commit.
790
791
791 The ``filediff`` template is rendered.
792 The ``filediff`` template is rendered.
792
793
793 This handler is registered under both the ``/diff`` and ``/filediff``
794 This handler is registered under both the ``/diff`` and ``/filediff``
794 paths. ``/diff`` is used in modern code.
795 paths. ``/diff`` is used in modern code.
795 """
796 """
796 fctx, ctx = None, None
797 fctx, ctx = None, None
797 try:
798 try:
798 fctx = webutil.filectx(web.repo, web.req)
799 fctx = webutil.filectx(web.repo, web.req)
799 except LookupError:
800 except LookupError:
800 ctx = webutil.changectx(web.repo, web.req)
801 ctx = webutil.changectx(web.repo, web.req)
801 path = webutil.cleanpath(web.repo, web.req.qsparams['file'])
802 path = webutil.cleanpath(web.repo, web.req.qsparams['file'])
802 if path not in ctx.files():
803 if path not in ctx.files():
803 raise
804 raise
804
805
805 if fctx is not None:
806 if fctx is not None:
806 path = fctx.path()
807 path = fctx.path()
807 ctx = fctx.changectx()
808 ctx = fctx.changectx()
808 basectx = ctx.p1()
809 basectx = ctx.p1()
809
810
810 style = web.config('web', 'style')
811 style = web.config('web', 'style')
811 if 'style' in web.req.qsparams:
812 if 'style' in web.req.qsparams:
812 style = web.req.qsparams['style']
813 style = web.req.qsparams['style']
813
814
814 diffs = webutil.diffs(web, ctx, basectx, [path], style)
815 diffs = webutil.diffs(web, ctx, basectx, [path], style)
815 if fctx is not None:
816 if fctx is not None:
816 rename = webutil.renamelink(fctx)
817 rename = webutil.renamelink(fctx)
817 ctx = fctx
818 ctx = fctx
818 else:
819 else:
819 rename = []
820 rename = []
820 ctx = ctx
821 ctx = ctx
821
822
822 return web.sendtemplate(
823 return web.sendtemplate(
823 'filediff',
824 'filediff',
824 file=path,
825 file=path,
825 symrev=webutil.symrevorshortnode(web.req, ctx),
826 symrev=webutil.symrevorshortnode(web.req, ctx),
826 rename=rename,
827 rename=rename,
827 diff=diffs,
828 diff=diffs,
828 **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))
829 **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))
829
830
830 diff = webcommand('diff')(filediff)
831 diff = webcommand('diff')(filediff)
831
832
832 @webcommand('comparison')
833 @webcommand('comparison')
833 def comparison(web):
834 def comparison(web):
834 """
835 """
835 /comparison/{revision}/{path}
836 /comparison/{revision}/{path}
836 -----------------------------
837 -----------------------------
837
838
838 Show a comparison between the old and new versions of a file from changes
839 Show a comparison between the old and new versions of a file from changes
839 made on a particular revision.
840 made on a particular revision.
840
841
841 This is similar to the ``diff`` handler. However, this form features
842 This is similar to the ``diff`` handler. However, this form features
842 a split or side-by-side diff rather than a unified diff.
843 a split or side-by-side diff rather than a unified diff.
843
844
844 The ``context`` query string argument can be used to control the lines of
845 The ``context`` query string argument can be used to control the lines of
845 context in the diff.
846 context in the diff.
846
847
847 The ``filecomparison`` template is rendered.
848 The ``filecomparison`` template is rendered.
848 """
849 """
849 ctx = webutil.changectx(web.repo, web.req)
850 ctx = webutil.changectx(web.repo, web.req)
850 if 'file' not in web.req.qsparams:
851 if 'file' not in web.req.qsparams:
851 raise ErrorResponse(HTTP_NOT_FOUND, 'file not given')
852 raise ErrorResponse(HTTP_NOT_FOUND, 'file not given')
852 path = webutil.cleanpath(web.repo, web.req.qsparams['file'])
853 path = webutil.cleanpath(web.repo, web.req.qsparams['file'])
853
854
854 parsecontext = lambda v: v == 'full' and -1 or int(v)
855 parsecontext = lambda v: v == 'full' and -1 or int(v)
855 if 'context' in web.req.qsparams:
856 if 'context' in web.req.qsparams:
856 context = parsecontext(web.req.qsparams['context'])
857 context = parsecontext(web.req.qsparams['context'])
857 else:
858 else:
858 context = parsecontext(web.config('web', 'comparisoncontext', '5'))
859 context = parsecontext(web.config('web', 'comparisoncontext', '5'))
859
860
860 def filelines(f):
861 def filelines(f):
861 if f.isbinary():
862 if f.isbinary():
862 mt = mimetypes.guess_type(f.path())[0]
863 mt = mimetypes.guess_type(f.path())[0]
863 if not mt:
864 if not mt:
864 mt = 'application/octet-stream'
865 mt = 'application/octet-stream'
865 return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))]
866 return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))]
866 return f.data().splitlines()
867 return f.data().splitlines()
867
868
868 fctx = None
869 fctx = None
869 parent = ctx.p1()
870 parent = ctx.p1()
870 leftrev = parent.rev()
871 leftrev = parent.rev()
871 leftnode = parent.node()
872 leftnode = parent.node()
872 rightrev = ctx.rev()
873 rightrev = ctx.rev()
873 rightnode = ctx.node()
874 rightnode = ctx.node()
874 if path in ctx:
875 if path in ctx:
875 fctx = ctx[path]
876 fctx = ctx[path]
876 rightlines = filelines(fctx)
877 rightlines = filelines(fctx)
877 if path not in parent:
878 if path not in parent:
878 leftlines = ()
879 leftlines = ()
879 else:
880 else:
880 pfctx = parent[path]
881 pfctx = parent[path]
881 leftlines = filelines(pfctx)
882 leftlines = filelines(pfctx)
882 else:
883 else:
883 rightlines = ()
884 rightlines = ()
884 pfctx = ctx.parents()[0][path]
885 pfctx = ctx.parents()[0][path]
885 leftlines = filelines(pfctx)
886 leftlines = filelines(pfctx)
886
887
887 comparison = webutil.compare(web.tmpl, context, leftlines, rightlines)
888 comparison = webutil.compare(web.tmpl, context, leftlines, rightlines)
888 if fctx is not None:
889 if fctx is not None:
889 rename = webutil.renamelink(fctx)
890 rename = webutil.renamelink(fctx)
890 ctx = fctx
891 ctx = fctx
891 else:
892 else:
892 rename = []
893 rename = []
893 ctx = ctx
894 ctx = ctx
894
895
895 return web.sendtemplate(
896 return web.sendtemplate(
896 'filecomparison',
897 'filecomparison',
897 file=path,
898 file=path,
898 symrev=webutil.symrevorshortnode(web.req, ctx),
899 symrev=webutil.symrevorshortnode(web.req, ctx),
899 rename=rename,
900 rename=rename,
900 leftrev=leftrev,
901 leftrev=leftrev,
901 leftnode=hex(leftnode),
902 leftnode=hex(leftnode),
902 rightrev=rightrev,
903 rightrev=rightrev,
903 rightnode=hex(rightnode),
904 rightnode=hex(rightnode),
904 comparison=comparison,
905 comparison=comparison,
905 **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))
906 **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))
906
907
907 @webcommand('annotate')
908 @webcommand('annotate')
908 def annotate(web):
909 def annotate(web):
909 """
910 """
910 /annotate/{revision}/{path}
911 /annotate/{revision}/{path}
911 ---------------------------
912 ---------------------------
912
913
913 Show changeset information for each line in a file.
914 Show changeset information for each line in a file.
914
915
915 The ``ignorews``, ``ignorewsamount``, ``ignorewseol``, and
916 The ``ignorews``, ``ignorewsamount``, ``ignorewseol``, and
916 ``ignoreblanklines`` query string arguments have the same meaning as
917 ``ignoreblanklines`` query string arguments have the same meaning as
917 their ``[annotate]`` config equivalents. It uses the hgrc boolean
918 their ``[annotate]`` config equivalents. It uses the hgrc boolean
918 parsing logic to interpret the value. e.g. ``0`` and ``false`` are
919 parsing logic to interpret the value. e.g. ``0`` and ``false`` are
919 false and ``1`` and ``true`` are true. If not defined, the server
920 false and ``1`` and ``true`` are true. If not defined, the server
920 default settings are used.
921 default settings are used.
921
922
922 The ``fileannotate`` template is rendered.
923 The ``fileannotate`` template is rendered.
923 """
924 """
924 fctx = webutil.filectx(web.repo, web.req)
925 fctx = webutil.filectx(web.repo, web.req)
925 f = fctx.path()
926 f = fctx.path()
926 parity = paritygen(web.stripecount)
927 parity = paritygen(web.stripecount)
927 ishead = fctx.filerev() in fctx.filelog().headrevs()
928 ishead = fctx.filerev() in fctx.filelog().headrevs()
928
929
929 # parents() is called once per line and several lines likely belong to
930 # parents() is called once per line and several lines likely belong to
930 # same revision. So it is worth caching.
931 # same revision. So it is worth caching.
931 # TODO there are still redundant operations within basefilectx.parents()
932 # TODO there are still redundant operations within basefilectx.parents()
932 # and from the fctx.annotate() call itself that could be cached.
933 # and from the fctx.annotate() call itself that could be cached.
933 parentscache = {}
934 parentscache = {}
934 def parents(f):
935 def parents(f):
935 rev = f.rev()
936 rev = f.rev()
936 if rev not in parentscache:
937 if rev not in parentscache:
937 parentscache[rev] = []
938 parentscache[rev] = []
938 for p in f.parents():
939 for p in f.parents():
939 entry = {
940 entry = {
940 'node': p.hex(),
941 'node': p.hex(),
941 'rev': p.rev(),
942 'rev': p.rev(),
942 }
943 }
943 parentscache[rev].append(entry)
944 parentscache[rev].append(entry)
944
945
945 for p in parentscache[rev]:
946 for p in parentscache[rev]:
946 yield p
947 yield p
947
948
948 def annotate(**map):
949 def annotate(**map):
949 if fctx.isbinary():
950 if fctx.isbinary():
950 mt = (mimetypes.guess_type(fctx.path())[0]
951 mt = (mimetypes.guess_type(fctx.path())[0]
951 or 'application/octet-stream')
952 or 'application/octet-stream')
952 lines = [dagop.annotateline(fctx=fctx.filectx(fctx.filerev()),
953 lines = [dagop.annotateline(fctx=fctx.filectx(fctx.filerev()),
953 lineno=1, text='(binary:%s)' % mt)]
954 lineno=1, text='(binary:%s)' % mt)]
954 else:
955 else:
955 lines = webutil.annotate(web.req, fctx, web.repo.ui)
956 lines = webutil.annotate(web.req, fctx, web.repo.ui)
956
957
957 previousrev = None
958 previousrev = None
958 blockparitygen = paritygen(1)
959 blockparitygen = paritygen(1)
959 for lineno, aline in enumerate(lines):
960 for lineno, aline in enumerate(lines):
960 f = aline.fctx
961 f = aline.fctx
961 rev = f.rev()
962 rev = f.rev()
962 if rev != previousrev:
963 if rev != previousrev:
963 blockhead = True
964 blockhead = True
964 blockparity = next(blockparitygen)
965 blockparity = next(blockparitygen)
965 else:
966 else:
966 blockhead = None
967 blockhead = None
967 previousrev = rev
968 previousrev = rev
968 yield {"parity": next(parity),
969 yield {"parity": next(parity),
969 "node": f.hex(),
970 "node": f.hex(),
970 "rev": rev,
971 "rev": rev,
971 "author": f.user(),
972 "author": f.user(),
972 "parents": parents(f),
973 "parents": parents(f),
973 "desc": f.description(),
974 "desc": f.description(),
974 "extra": f.extra(),
975 "extra": f.extra(),
975 "file": f.path(),
976 "file": f.path(),
976 "blockhead": blockhead,
977 "blockhead": blockhead,
977 "blockparity": blockparity,
978 "blockparity": blockparity,
978 "targetline": aline.lineno,
979 "targetline": aline.lineno,
979 "line": aline.text,
980 "line": aline.text,
980 "lineno": lineno + 1,
981 "lineno": lineno + 1,
981 "lineid": "l%d" % (lineno + 1),
982 "lineid": "l%d" % (lineno + 1),
982 "linenumber": "% 6d" % (lineno + 1),
983 "linenumber": "% 6d" % (lineno + 1),
983 "revdate": f.date()}
984 "revdate": f.date()}
984
985
985 diffopts = webutil.difffeatureopts(web.req, web.repo.ui, 'annotate')
986 diffopts = webutil.difffeatureopts(web.req, web.repo.ui, 'annotate')
986 diffopts = {k: getattr(diffopts, k) for k in diffopts.defaults}
987 diffopts = {k: getattr(diffopts, k) for k in diffopts.defaults}
987
988
988 return web.sendtemplate(
989 return web.sendtemplate(
989 'fileannotate',
990 'fileannotate',
990 file=f,
991 file=f,
991 annotate=annotate,
992 annotate=annotate,
992 path=webutil.up(f),
993 path=webutil.up(f),
993 symrev=webutil.symrevorshortnode(web.req, fctx),
994 symrev=webutil.symrevorshortnode(web.req, fctx),
994 rename=webutil.renamelink(fctx),
995 rename=webutil.renamelink(fctx),
995 permissions=fctx.manifest().flags(f),
996 permissions=fctx.manifest().flags(f),
996 ishead=int(ishead),
997 ishead=int(ishead),
997 diffopts=diffopts,
998 diffopts=diffopts,
998 **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))
999 **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))
999
1000
1000 @webcommand('filelog')
1001 @webcommand('filelog')
1001 def filelog(web):
1002 def filelog(web):
1002 """
1003 """
1003 /filelog/{revision}/{path}
1004 /filelog/{revision}/{path}
1004 --------------------------
1005 --------------------------
1005
1006
1006 Show information about the history of a file in the repository.
1007 Show information about the history of a file in the repository.
1007
1008
1008 The ``revcount`` query string argument can be defined to control the
1009 The ``revcount`` query string argument can be defined to control the
1009 maximum number of entries to show.
1010 maximum number of entries to show.
1010
1011
1011 The ``filelog`` template will be rendered.
1012 The ``filelog`` template will be rendered.
1012 """
1013 """
1013
1014
1014 try:
1015 try:
1015 fctx = webutil.filectx(web.repo, web.req)
1016 fctx = webutil.filectx(web.repo, web.req)
1016 f = fctx.path()
1017 f = fctx.path()
1017 fl = fctx.filelog()
1018 fl = fctx.filelog()
1018 except error.LookupError:
1019 except error.LookupError:
1019 f = webutil.cleanpath(web.repo, web.req.qsparams['file'])
1020 f = webutil.cleanpath(web.repo, web.req.qsparams['file'])
1020 fl = web.repo.file(f)
1021 fl = web.repo.file(f)
1021 numrevs = len(fl)
1022 numrevs = len(fl)
1022 if not numrevs: # file doesn't exist at all
1023 if not numrevs: # file doesn't exist at all
1023 raise
1024 raise
1024 rev = webutil.changectx(web.repo, web.req).rev()
1025 rev = webutil.changectx(web.repo, web.req).rev()
1025 first = fl.linkrev(0)
1026 first = fl.linkrev(0)
1026 if rev < first: # current rev is from before file existed
1027 if rev < first: # current rev is from before file existed
1027 raise
1028 raise
1028 frev = numrevs - 1
1029 frev = numrevs - 1
1029 while fl.linkrev(frev) > rev:
1030 while fl.linkrev(frev) > rev:
1030 frev -= 1
1031 frev -= 1
1031 fctx = web.repo.filectx(f, fl.linkrev(frev))
1032 fctx = web.repo.filectx(f, fl.linkrev(frev))
1032
1033
1033 revcount = web.maxshortchanges
1034 revcount = web.maxshortchanges
1034 if 'revcount' in web.req.qsparams:
1035 if 'revcount' in web.req.qsparams:
1035 try:
1036 try:
1036 revcount = int(web.req.qsparams.get('revcount', revcount))
1037 revcount = int(web.req.qsparams.get('revcount', revcount))
1037 revcount = max(revcount, 1)
1038 revcount = max(revcount, 1)
1038 web.tmpl.defaults['sessionvars']['revcount'] = revcount
1039 web.tmpl.defaults['sessionvars']['revcount'] = revcount
1039 except ValueError:
1040 except ValueError:
1040 pass
1041 pass
1041
1042
1042 lrange = webutil.linerange(web.req)
1043 lrange = webutil.linerange(web.req)
1043
1044
1044 lessvars = copy.copy(web.tmpl.defaults['sessionvars'])
1045 lessvars = copy.copy(web.tmpl.defaults['sessionvars'])
1045 lessvars['revcount'] = max(revcount // 2, 1)
1046 lessvars['revcount'] = max(revcount // 2, 1)
1046 morevars = copy.copy(web.tmpl.defaults['sessionvars'])
1047 morevars = copy.copy(web.tmpl.defaults['sessionvars'])
1047 morevars['revcount'] = revcount * 2
1048 morevars['revcount'] = revcount * 2
1048
1049
1049 patch = 'patch' in web.req.qsparams
1050 patch = 'patch' in web.req.qsparams
1050 if patch:
1051 if patch:
1051 lessvars['patch'] = morevars['patch'] = web.req.qsparams['patch']
1052 lessvars['patch'] = morevars['patch'] = web.req.qsparams['patch']
1052 descend = 'descend' in web.req.qsparams
1053 descend = 'descend' in web.req.qsparams
1053 if descend:
1054 if descend:
1054 lessvars['descend'] = morevars['descend'] = web.req.qsparams['descend']
1055 lessvars['descend'] = morevars['descend'] = web.req.qsparams['descend']
1055
1056
1056 count = fctx.filerev() + 1
1057 count = fctx.filerev() + 1
1057 start = max(0, count - revcount) # first rev on this page
1058 start = max(0, count - revcount) # first rev on this page
1058 end = min(count, start + revcount) # last rev on this page
1059 end = min(count, start + revcount) # last rev on this page
1059 parity = paritygen(web.stripecount, offset=start - end)
1060 parity = paritygen(web.stripecount, offset=start - end)
1060
1061
1061 repo = web.repo
1062 repo = web.repo
1062 filelog = fctx.filelog()
1063 filelog = fctx.filelog()
1063 revs = [filerev for filerev in filelog.revs(start, end - 1)
1064 revs = [filerev for filerev in filelog.revs(start, end - 1)
1064 if filelog.linkrev(filerev) in repo]
1065 if filelog.linkrev(filerev) in repo]
1065 entries = []
1066 entries = []
1066
1067
1067 diffstyle = web.config('web', 'style')
1068 diffstyle = web.config('web', 'style')
1068 if 'style' in web.req.qsparams:
1069 if 'style' in web.req.qsparams:
1069 diffstyle = web.req.qsparams['style']
1070 diffstyle = web.req.qsparams['style']
1070
1071
1071 def diff(fctx, linerange=None):
1072 def diff(fctx, linerange=None):
1072 ctx = fctx.changectx()
1073 ctx = fctx.changectx()
1073 basectx = ctx.p1()
1074 basectx = ctx.p1()
1074 path = fctx.path()
1075 path = fctx.path()
1075 return webutil.diffs(web, ctx, basectx, [path], diffstyle,
1076 return webutil.diffs(web, ctx, basectx, [path], diffstyle,
1076 linerange=linerange,
1077 linerange=linerange,
1077 lineidprefix='%s-' % ctx.hex()[:12])
1078 lineidprefix='%s-' % ctx.hex()[:12])
1078
1079
1079 linerange = None
1080 linerange = None
1080 if lrange is not None:
1081 if lrange is not None:
1081 linerange = webutil.formatlinerange(*lrange)
1082 linerange = webutil.formatlinerange(*lrange)
1082 # deactivate numeric nav links when linerange is specified as this
1083 # deactivate numeric nav links when linerange is specified as this
1083 # would required a dedicated "revnav" class
1084 # would required a dedicated "revnav" class
1084 nav = None
1085 nav = None
1085 if descend:
1086 if descend:
1086 it = dagop.blockdescendants(fctx, *lrange)
1087 it = dagop.blockdescendants(fctx, *lrange)
1087 else:
1088 else:
1088 it = dagop.blockancestors(fctx, *lrange)
1089 it = dagop.blockancestors(fctx, *lrange)
1089 for i, (c, lr) in enumerate(it, 1):
1090 for i, (c, lr) in enumerate(it, 1):
1090 diffs = None
1091 diffs = None
1091 if patch:
1092 if patch:
1092 diffs = diff(c, linerange=lr)
1093 diffs = diff(c, linerange=lr)
1093 # follow renames accross filtered (not in range) revisions
1094 # follow renames accross filtered (not in range) revisions
1094 path = c.path()
1095 path = c.path()
1095 entries.append(dict(
1096 entries.append(dict(
1096 parity=next(parity),
1097 parity=next(parity),
1097 filerev=c.rev(),
1098 filerev=c.rev(),
1098 file=path,
1099 file=path,
1099 diff=diffs,
1100 diff=diffs,
1100 linerange=webutil.formatlinerange(*lr),
1101 linerange=webutil.formatlinerange(*lr),
1101 **pycompat.strkwargs(webutil.commonentry(repo, c))))
1102 **pycompat.strkwargs(webutil.commonentry(repo, c))))
1102 if i == revcount:
1103 if i == revcount:
1103 break
1104 break
1104 lessvars['linerange'] = webutil.formatlinerange(*lrange)
1105 lessvars['linerange'] = webutil.formatlinerange(*lrange)
1105 morevars['linerange'] = lessvars['linerange']
1106 morevars['linerange'] = lessvars['linerange']
1106 else:
1107 else:
1107 for i in revs:
1108 for i in revs:
1108 iterfctx = fctx.filectx(i)
1109 iterfctx = fctx.filectx(i)
1109 diffs = None
1110 diffs = None
1110 if patch:
1111 if patch:
1111 diffs = diff(iterfctx)
1112 diffs = diff(iterfctx)
1112 entries.append(dict(
1113 entries.append(dict(
1113 parity=next(parity),
1114 parity=next(parity),
1114 filerev=i,
1115 filerev=i,
1115 file=f,
1116 file=f,
1116 diff=diffs,
1117 diff=diffs,
1117 rename=webutil.renamelink(iterfctx),
1118 rename=webutil.renamelink(iterfctx),
1118 **pycompat.strkwargs(webutil.commonentry(repo, iterfctx))))
1119 **pycompat.strkwargs(webutil.commonentry(repo, iterfctx))))
1119 entries.reverse()
1120 entries.reverse()
1120 revnav = webutil.filerevnav(web.repo, fctx.path())
1121 revnav = webutil.filerevnav(web.repo, fctx.path())
1121 nav = revnav.gen(end - 1, revcount, count)
1122 nav = revnav.gen(end - 1, revcount, count)
1122
1123
1123 latestentry = entries[:1]
1124 latestentry = entries[:1]
1124
1125
1125 return web.sendtemplate(
1126 return web.sendtemplate(
1126 'filelog',
1127 'filelog',
1127 file=f,
1128 file=f,
1128 nav=nav,
1129 nav=nav,
1129 symrev=webutil.symrevorshortnode(web.req, fctx),
1130 symrev=webutil.symrevorshortnode(web.req, fctx),
1130 entries=entries,
1131 entries=entries,
1131 descend=descend,
1132 descend=descend,
1132 patch=patch,
1133 patch=patch,
1133 latestentry=latestentry,
1134 latestentry=latestentry,
1134 linerange=linerange,
1135 linerange=linerange,
1135 revcount=revcount,
1136 revcount=revcount,
1136 morevars=morevars,
1137 morevars=morevars,
1137 lessvars=lessvars,
1138 lessvars=lessvars,
1138 **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))
1139 **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))
1139
1140
1140 @webcommand('archive')
1141 @webcommand('archive')
1141 def archive(web):
1142 def archive(web):
1142 """
1143 """
1143 /archive/{revision}.{format}[/{path}]
1144 /archive/{revision}.{format}[/{path}]
1144 -------------------------------------
1145 -------------------------------------
1145
1146
1146 Obtain an archive of repository content.
1147 Obtain an archive of repository content.
1147
1148
1148 The content and type of the archive is defined by a URL path parameter.
1149 The content and type of the archive is defined by a URL path parameter.
1149 ``format`` is the file extension of the archive type to be generated. e.g.
1150 ``format`` is the file extension of the archive type to be generated. e.g.
1150 ``zip`` or ``tar.bz2``. Not all archive types may be allowed by your
1151 ``zip`` or ``tar.bz2``. Not all archive types may be allowed by your
1151 server configuration.
1152 server configuration.
1152
1153
1153 The optional ``path`` URL parameter controls content to include in the
1154 The optional ``path`` URL parameter controls content to include in the
1154 archive. If omitted, every file in the specified revision is present in the
1155 archive. If omitted, every file in the specified revision is present in the
1155 archive. If included, only the specified file or contents of the specified
1156 archive. If included, only the specified file or contents of the specified
1156 directory will be included in the archive.
1157 directory will be included in the archive.
1157
1158
1158 No template is used for this handler. Raw, binary content is generated.
1159 No template is used for this handler. Raw, binary content is generated.
1159 """
1160 """
1160
1161
1161 type_ = web.req.qsparams.get('type')
1162 type_ = web.req.qsparams.get('type')
1162 allowed = web.configlist("web", "allow_archive")
1163 allowed = web.configlist("web", "allow_archive")
1163 key = web.req.qsparams['node']
1164 key = web.req.qsparams['node']
1164
1165
1165 if type_ not in web.archivespecs:
1166 if type_ not in web.archivespecs:
1166 msg = 'Unsupported archive type: %s' % type_
1167 msg = 'Unsupported archive type: %s' % type_
1167 raise ErrorResponse(HTTP_NOT_FOUND, msg)
1168 raise ErrorResponse(HTTP_NOT_FOUND, msg)
1168
1169
1169 if not ((type_ in allowed or
1170 if not ((type_ in allowed or
1170 web.configbool("web", "allow" + type_))):
1171 web.configbool("web", "allow" + type_))):
1171 msg = 'Archive type not allowed: %s' % type_
1172 msg = 'Archive type not allowed: %s' % type_
1172 raise ErrorResponse(HTTP_FORBIDDEN, msg)
1173 raise ErrorResponse(HTTP_FORBIDDEN, msg)
1173
1174
1174 reponame = re.sub(br"\W+", "-", os.path.basename(web.reponame))
1175 reponame = re.sub(br"\W+", "-", os.path.basename(web.reponame))
1175 cnode = web.repo.lookup(key)
1176 cnode = web.repo.lookup(key)
1176 arch_version = key
1177 arch_version = key
1177 if cnode == key or key == 'tip':
1178 if cnode == key or key == 'tip':
1178 arch_version = short(cnode)
1179 arch_version = short(cnode)
1179 name = "%s-%s" % (reponame, arch_version)
1180 name = "%s-%s" % (reponame, arch_version)
1180
1181
1181 ctx = webutil.changectx(web.repo, web.req)
1182 ctx = webutil.changectx(web.repo, web.req)
1182 pats = []
1183 pats = []
1183 match = scmutil.match(ctx, [])
1184 match = scmutil.match(ctx, [])
1184 file = web.req.qsparams.get('file')
1185 file = web.req.qsparams.get('file')
1185 if file:
1186 if file:
1186 pats = ['path:' + file]
1187 pats = ['path:' + file]
1187 match = scmutil.match(ctx, pats, default='path')
1188 match = scmutil.match(ctx, pats, default='path')
1188 if pats:
1189 if pats:
1189 files = [f for f in ctx.manifest().keys() if match(f)]
1190 files = [f for f in ctx.manifest().keys() if match(f)]
1190 if not files:
1191 if not files:
1191 raise ErrorResponse(HTTP_NOT_FOUND,
1192 raise ErrorResponse(HTTP_NOT_FOUND,
1192 'file(s) not found: %s' % file)
1193 'file(s) not found: %s' % file)
1193
1194
1194 mimetype, artype, extension, encoding = web.archivespecs[type_]
1195 mimetype, artype, extension, encoding = web.archivespecs[type_]
1195
1196
1196 web.res.headers['Content-Type'] = mimetype
1197 web.res.headers['Content-Type'] = mimetype
1197 web.res.headers['Content-Disposition'] = 'attachment; filename=%s%s' % (
1198 web.res.headers['Content-Disposition'] = 'attachment; filename=%s%s' % (
1198 name, extension)
1199 name, extension)
1199
1200
1200 if encoding:
1201 if encoding:
1201 web.res.headers['Content-Encoding'] = encoding
1202 web.res.headers['Content-Encoding'] = encoding
1202
1203
1203 web.res.setbodywillwrite()
1204 web.res.setbodywillwrite()
1204 if list(web.res.sendresponse()):
1205 if list(web.res.sendresponse()):
1205 raise error.ProgrammingError('sendresponse() should not emit data '
1206 raise error.ProgrammingError('sendresponse() should not emit data '
1206 'if writing later')
1207 'if writing later')
1207
1208
1208 bodyfh = web.res.getbodyfile()
1209 bodyfh = web.res.getbodyfile()
1209
1210
1210 archival.archive(web.repo, bodyfh, cnode, artype, prefix=name,
1211 archival.archive(web.repo, bodyfh, cnode, artype, prefix=name,
1211 matchfn=match,
1212 matchfn=match,
1212 subrepos=web.configbool("web", "archivesubrepos"))
1213 subrepos=web.configbool("web", "archivesubrepos"))
1213
1214
1214 return []
1215 return []
1215
1216
1216 @webcommand('static')
1217 @webcommand('static')
1217 def static(web):
1218 def static(web):
1218 fname = web.req.qsparams['file']
1219 fname = web.req.qsparams['file']
1219 # a repo owner may set web.static in .hg/hgrc to get any file
1220 # a repo owner may set web.static in .hg/hgrc to get any file
1220 # readable by the user running the CGI script
1221 # readable by the user running the CGI script
1221 static = web.config("web", "static", None, untrusted=False)
1222 static = web.config("web", "static", None, untrusted=False)
1222 if not static:
1223 if not static:
1223 tp = web.templatepath or templater.templatepaths()
1224 tp = web.templatepath or templater.templatepaths()
1224 if isinstance(tp, str):
1225 if isinstance(tp, str):
1225 tp = [tp]
1226 tp = [tp]
1226 static = [os.path.join(p, 'static') for p in tp]
1227 static = [os.path.join(p, 'static') for p in tp]
1227
1228
1228 staticfile(static, fname, web.res)
1229 staticfile(static, fname, web.res)
1229 return web.res.sendresponse()
1230 return web.res.sendresponse()
1230
1231
1231 @webcommand('graph')
1232 @webcommand('graph')
1232 def graph(web):
1233 def graph(web):
1233 """
1234 """
1234 /graph[/{revision}]
1235 /graph[/{revision}]
1235 -------------------
1236 -------------------
1236
1237
1237 Show information about the graphical topology of the repository.
1238 Show information about the graphical topology of the repository.
1238
1239
1239 Information rendered by this handler can be used to create visual
1240 Information rendered by this handler can be used to create visual
1240 representations of repository topology.
1241 representations of repository topology.
1241
1242
1242 The ``revision`` URL parameter controls the starting changeset. If it's
1243 The ``revision`` URL parameter controls the starting changeset. If it's
1243 absent, the default is ``tip``.
1244 absent, the default is ``tip``.
1244
1245
1245 The ``revcount`` query string argument can define the number of changesets
1246 The ``revcount`` query string argument can define the number of changesets
1246 to show information for.
1247 to show information for.
1247
1248
1248 The ``graphtop`` query string argument can specify the starting changeset
1249 The ``graphtop`` query string argument can specify the starting changeset
1249 for producing ``jsdata`` variable that is used for rendering graph in
1250 for producing ``jsdata`` variable that is used for rendering graph in
1250 JavaScript. By default it has the same value as ``revision``.
1251 JavaScript. By default it has the same value as ``revision``.
1251
1252
1252 This handler will render the ``graph`` template.
1253 This handler will render the ``graph`` template.
1253 """
1254 """
1254
1255
1255 if 'node' in web.req.qsparams:
1256 if 'node' in web.req.qsparams:
1256 ctx = webutil.changectx(web.repo, web.req)
1257 ctx = webutil.changectx(web.repo, web.req)
1257 symrev = webutil.symrevorshortnode(web.req, ctx)
1258 symrev = webutil.symrevorshortnode(web.req, ctx)
1258 else:
1259 else:
1259 ctx = web.repo['tip']
1260 ctx = web.repo['tip']
1260 symrev = 'tip'
1261 symrev = 'tip'
1261 rev = ctx.rev()
1262 rev = ctx.rev()
1262
1263
1263 bg_height = 39
1264 bg_height = 39
1264 revcount = web.maxshortchanges
1265 revcount = web.maxshortchanges
1265 if 'revcount' in web.req.qsparams:
1266 if 'revcount' in web.req.qsparams:
1266 try:
1267 try:
1267 revcount = int(web.req.qsparams.get('revcount', revcount))
1268 revcount = int(web.req.qsparams.get('revcount', revcount))
1268 revcount = max(revcount, 1)
1269 revcount = max(revcount, 1)
1269 web.tmpl.defaults['sessionvars']['revcount'] = revcount
1270 web.tmpl.defaults['sessionvars']['revcount'] = revcount
1270 except ValueError:
1271 except ValueError:
1271 pass
1272 pass
1272
1273
1273 lessvars = copy.copy(web.tmpl.defaults['sessionvars'])
1274 lessvars = copy.copy(web.tmpl.defaults['sessionvars'])
1274 lessvars['revcount'] = max(revcount // 2, 1)
1275 lessvars['revcount'] = max(revcount // 2, 1)
1275 morevars = copy.copy(web.tmpl.defaults['sessionvars'])
1276 morevars = copy.copy(web.tmpl.defaults['sessionvars'])
1276 morevars['revcount'] = revcount * 2
1277 morevars['revcount'] = revcount * 2
1277
1278
1278 graphtop = web.req.qsparams.get('graphtop', ctx.hex())
1279 graphtop = web.req.qsparams.get('graphtop', ctx.hex())
1279 graphvars = copy.copy(web.tmpl.defaults['sessionvars'])
1280 graphvars = copy.copy(web.tmpl.defaults['sessionvars'])
1280 graphvars['graphtop'] = graphtop
1281 graphvars['graphtop'] = graphtop
1281
1282
1282 count = len(web.repo)
1283 count = len(web.repo)
1283 pos = rev
1284 pos = rev
1284
1285
1285 uprev = min(max(0, count - 1), rev + revcount)
1286 uprev = min(max(0, count - 1), rev + revcount)
1286 downrev = max(0, rev - revcount)
1287 downrev = max(0, rev - revcount)
1287 changenav = webutil.revnav(web.repo).gen(pos, revcount, count)
1288 changenav = webutil.revnav(web.repo).gen(pos, revcount, count)
1288
1289
1289 tree = []
1290 tree = []
1290 nextentry = []
1291 nextentry = []
1291 lastrev = 0
1292 lastrev = 0
1292 if pos != -1:
1293 if pos != -1:
1293 allrevs = web.repo.changelog.revs(pos, 0)
1294 allrevs = web.repo.changelog.revs(pos, 0)
1294 revs = []
1295 revs = []
1295 for i in allrevs:
1296 for i in allrevs:
1296 revs.append(i)
1297 revs.append(i)
1297 if len(revs) >= revcount + 1:
1298 if len(revs) >= revcount + 1:
1298 break
1299 break
1299
1300
1300 if len(revs) > revcount:
1301 if len(revs) > revcount:
1301 nextentry = [webutil.commonentry(web.repo, web.repo[revs[-1]])]
1302 nextentry = [webutil.commonentry(web.repo, web.repo[revs[-1]])]
1302 revs = revs[:-1]
1303 revs = revs[:-1]
1303
1304
1304 lastrev = revs[-1]
1305 lastrev = revs[-1]
1305
1306
1306 # We have to feed a baseset to dagwalker as it is expecting smartset
1307 # We have to feed a baseset to dagwalker as it is expecting smartset
1307 # object. This does not have a big impact on hgweb performance itself
1308 # object. This does not have a big impact on hgweb performance itself
1308 # since hgweb graphing code is not itself lazy yet.
1309 # since hgweb graphing code is not itself lazy yet.
1309 dag = graphmod.dagwalker(web.repo, smartset.baseset(revs))
1310 dag = graphmod.dagwalker(web.repo, smartset.baseset(revs))
1310 # As we said one line above... not lazy.
1311 # As we said one line above... not lazy.
1311 tree = list(item for item in graphmod.colored(dag, web.repo)
1312 tree = list(item for item in graphmod.colored(dag, web.repo)
1312 if item[1] == graphmod.CHANGESET)
1313 if item[1] == graphmod.CHANGESET)
1313
1314
1314 def nodecurrent(ctx):
1315 def nodecurrent(ctx):
1315 wpnodes = web.repo.dirstate.parents()
1316 wpnodes = web.repo.dirstate.parents()
1316 if wpnodes[1] == nullid:
1317 if wpnodes[1] == nullid:
1317 wpnodes = wpnodes[:1]
1318 wpnodes = wpnodes[:1]
1318 if ctx.node() in wpnodes:
1319 if ctx.node() in wpnodes:
1319 return '@'
1320 return '@'
1320 return ''
1321 return ''
1321
1322
1322 def nodesymbol(ctx):
1323 def nodesymbol(ctx):
1323 if ctx.obsolete():
1324 if ctx.obsolete():
1324 return 'x'
1325 return 'x'
1325 elif ctx.isunstable():
1326 elif ctx.isunstable():
1326 return '*'
1327 return '*'
1327 elif ctx.closesbranch():
1328 elif ctx.closesbranch():
1328 return '_'
1329 return '_'
1329 else:
1330 else:
1330 return 'o'
1331 return 'o'
1331
1332
1332 def fulltree():
1333 def fulltree():
1333 pos = web.repo[graphtop].rev()
1334 pos = web.repo[graphtop].rev()
1334 tree = []
1335 tree = []
1335 if pos != -1:
1336 if pos != -1:
1336 revs = web.repo.changelog.revs(pos, lastrev)
1337 revs = web.repo.changelog.revs(pos, lastrev)
1337 dag = graphmod.dagwalker(web.repo, smartset.baseset(revs))
1338 dag = graphmod.dagwalker(web.repo, smartset.baseset(revs))
1338 tree = list(item for item in graphmod.colored(dag, web.repo)
1339 tree = list(item for item in graphmod.colored(dag, web.repo)
1339 if item[1] == graphmod.CHANGESET)
1340 if item[1] == graphmod.CHANGESET)
1340 return tree
1341 return tree
1341
1342
1342 def jsdata():
1343 def jsdata():
1343 return [{'node': pycompat.bytestr(ctx),
1344 return [{'node': pycompat.bytestr(ctx),
1344 'graphnode': nodecurrent(ctx) + nodesymbol(ctx),
1345 'graphnode': nodecurrent(ctx) + nodesymbol(ctx),
1345 'vertex': vtx,
1346 'vertex': vtx,
1346 'edges': edges}
1347 'edges': edges}
1347 for (id, type, ctx, vtx, edges) in fulltree()]
1348 for (id, type, ctx, vtx, edges) in fulltree()]
1348
1349
1349 def nodes():
1350 def nodes():
1350 parity = paritygen(web.stripecount)
1351 parity = paritygen(web.stripecount)
1351 for row, (id, type, ctx, vtx, edges) in enumerate(tree):
1352 for row, (id, type, ctx, vtx, edges) in enumerate(tree):
1352 entry = webutil.commonentry(web.repo, ctx)
1353 entry = webutil.commonentry(web.repo, ctx)
1353 edgedata = [{'col': edge[0],
1354 edgedata = [{'col': edge[0],
1354 'nextcol': edge[1],
1355 'nextcol': edge[1],
1355 'color': (edge[2] - 1) % 6 + 1,
1356 'color': (edge[2] - 1) % 6 + 1,
1356 'width': edge[3],
1357 'width': edge[3],
1357 'bcolor': edge[4]}
1358 'bcolor': edge[4]}
1358 for edge in edges]
1359 for edge in edges]
1359
1360
1360 entry.update({'col': vtx[0],
1361 entry.update({'col': vtx[0],
1361 'color': (vtx[1] - 1) % 6 + 1,
1362 'color': (vtx[1] - 1) % 6 + 1,
1362 'parity': next(parity),
1363 'parity': next(parity),
1363 'edges': edgedata,
1364 'edges': edgedata,
1364 'row': row,
1365 'row': row,
1365 'nextrow': row + 1})
1366 'nextrow': row + 1})
1366
1367
1367 yield entry
1368 yield entry
1368
1369
1369 rows = len(tree)
1370 rows = len(tree)
1370
1371
1371 return web.sendtemplate(
1372 return web.sendtemplate(
1372 'graph',
1373 'graph',
1373 rev=rev,
1374 rev=rev,
1374 symrev=symrev,
1375 symrev=symrev,
1375 revcount=revcount,
1376 revcount=revcount,
1376 uprev=uprev,
1377 uprev=uprev,
1377 lessvars=lessvars,
1378 lessvars=lessvars,
1378 morevars=morevars,
1379 morevars=morevars,
1379 downrev=downrev,
1380 downrev=downrev,
1380 graphvars=graphvars,
1381 graphvars=graphvars,
1381 rows=rows,
1382 rows=rows,
1382 bg_height=bg_height,
1383 bg_height=bg_height,
1383 changesets=count,
1384 changesets=count,
1384 nextentry=nextentry,
1385 nextentry=nextentry,
1385 jsdata=lambda **x: jsdata(),
1386 jsdata=lambda **x: jsdata(),
1386 nodes=lambda **x: nodes(),
1387 nodes=lambda **x: nodes(),
1387 node=ctx.hex(),
1388 node=ctx.hex(),
1388 changenav=changenav)
1389 changenav=changenav)
1389
1390
1390 def _getdoc(e):
1391 def _getdoc(e):
1391 doc = e[0].__doc__
1392 doc = e[0].__doc__
1392 if doc:
1393 if doc:
1393 doc = _(doc).partition('\n')[0]
1394 doc = _(doc).partition('\n')[0]
1394 else:
1395 else:
1395 doc = _('(no help text available)')
1396 doc = _('(no help text available)')
1396 return doc
1397 return doc
1397
1398
1398 @webcommand('help')
1399 @webcommand('help')
1399 def help(web):
1400 def help(web):
1400 """
1401 """
1401 /help[/{topic}]
1402 /help[/{topic}]
1402 ---------------
1403 ---------------
1403
1404
1404 Render help documentation.
1405 Render help documentation.
1405
1406
1406 This web command is roughly equivalent to :hg:`help`. If a ``topic``
1407 This web command is roughly equivalent to :hg:`help`. If a ``topic``
1407 is defined, that help topic will be rendered. If not, an index of
1408 is defined, that help topic will be rendered. If not, an index of
1408 available help topics will be rendered.
1409 available help topics will be rendered.
1409
1410
1410 The ``help`` template will be rendered when requesting help for a topic.
1411 The ``help`` template will be rendered when requesting help for a topic.
1411 ``helptopics`` will be rendered for the index of help topics.
1412 ``helptopics`` will be rendered for the index of help topics.
1412 """
1413 """
1413 from .. import commands, help as helpmod # avoid cycle
1414 from .. import commands, help as helpmod # avoid cycle
1414
1415
1415 topicname = web.req.qsparams.get('node')
1416 topicname = web.req.qsparams.get('node')
1416 if not topicname:
1417 if not topicname:
1417 def topics(**map):
1418 def topics(**map):
1418 for entries, summary, _doc in helpmod.helptable:
1419 for entries, summary, _doc in helpmod.helptable:
1419 yield {'topic': entries[0], 'summary': summary}
1420 yield {'topic': entries[0], 'summary': summary}
1420
1421
1421 early, other = [], []
1422 early, other = [], []
1422 primary = lambda s: s.partition('|')[0]
1423 primary = lambda s: s.partition('|')[0]
1423 for c, e in commands.table.iteritems():
1424 for c, e in commands.table.iteritems():
1424 doc = _getdoc(e)
1425 doc = _getdoc(e)
1425 if 'DEPRECATED' in doc or c.startswith('debug'):
1426 if 'DEPRECATED' in doc or c.startswith('debug'):
1426 continue
1427 continue
1427 cmd = primary(c)
1428 cmd = primary(c)
1428 if cmd.startswith('^'):
1429 if cmd.startswith('^'):
1429 early.append((cmd[1:], doc))
1430 early.append((cmd[1:], doc))
1430 else:
1431 else:
1431 other.append((cmd, doc))
1432 other.append((cmd, doc))
1432
1433
1433 early.sort()
1434 early.sort()
1434 other.sort()
1435 other.sort()
1435
1436
1436 def earlycommands(**map):
1437 def earlycommands(**map):
1437 for c, doc in early:
1438 for c, doc in early:
1438 yield {'topic': c, 'summary': doc}
1439 yield {'topic': c, 'summary': doc}
1439
1440
1440 def othercommands(**map):
1441 def othercommands(**map):
1441 for c, doc in other:
1442 for c, doc in other:
1442 yield {'topic': c, 'summary': doc}
1443 yield {'topic': c, 'summary': doc}
1443
1444
1444 return web.sendtemplate(
1445 return web.sendtemplate(
1445 'helptopics',
1446 'helptopics',
1446 topics=topics,
1447 topics=topics,
1447 earlycommands=earlycommands,
1448 earlycommands=earlycommands,
1448 othercommands=othercommands,
1449 othercommands=othercommands,
1449 title='Index')
1450 title='Index')
1450
1451
1451 # Render an index of sub-topics.
1452 # Render an index of sub-topics.
1452 if topicname in helpmod.subtopics:
1453 if topicname in helpmod.subtopics:
1453 topics = []
1454 topics = []
1454 for entries, summary, _doc in helpmod.subtopics[topicname]:
1455 for entries, summary, _doc in helpmod.subtopics[topicname]:
1455 topics.append({
1456 topics.append({
1456 'topic': '%s.%s' % (topicname, entries[0]),
1457 'topic': '%s.%s' % (topicname, entries[0]),
1457 'basename': entries[0],
1458 'basename': entries[0],
1458 'summary': summary,
1459 'summary': summary,
1459 })
1460 })
1460
1461
1461 return web.sendtemplate(
1462 return web.sendtemplate(
1462 'helptopics',
1463 'helptopics',
1463 topics=topics,
1464 topics=topics,
1464 title=topicname,
1465 title=topicname,
1465 subindex=True)
1466 subindex=True)
1466
1467
1467 u = webutil.wsgiui.load()
1468 u = webutil.wsgiui.load()
1468 u.verbose = True
1469 u.verbose = True
1469
1470
1470 # Render a page from a sub-topic.
1471 # Render a page from a sub-topic.
1471 if '.' in topicname:
1472 if '.' in topicname:
1472 # TODO implement support for rendering sections, like
1473 # TODO implement support for rendering sections, like
1473 # `hg help` works.
1474 # `hg help` works.
1474 topic, subtopic = topicname.split('.', 1)
1475 topic, subtopic = topicname.split('.', 1)
1475 if topic not in helpmod.subtopics:
1476 if topic not in helpmod.subtopics:
1476 raise ErrorResponse(HTTP_NOT_FOUND)
1477 raise ErrorResponse(HTTP_NOT_FOUND)
1477 else:
1478 else:
1478 topic = topicname
1479 topic = topicname
1479 subtopic = None
1480 subtopic = None
1480
1481
1481 try:
1482 try:
1482 doc = helpmod.help_(u, commands, topic, subtopic=subtopic)
1483 doc = helpmod.help_(u, commands, topic, subtopic=subtopic)
1483 except error.Abort:
1484 except error.Abort:
1484 raise ErrorResponse(HTTP_NOT_FOUND)
1485 raise ErrorResponse(HTTP_NOT_FOUND)
1485
1486
1486 return web.sendtemplate(
1487 return web.sendtemplate(
1487 'help',
1488 'help',
1488 topic=topicname,
1489 topic=topicname,
1489 doc=doc)
1490 doc=doc)
1490
1491
1491 # tell hggettext to extract docstrings from these functions:
1492 # tell hggettext to extract docstrings from these functions:
1492 i18nfunctions = commands.values()
1493 i18nfunctions = commands.values()
@@ -1,62 +1,62 b''
1 {header}
1 {header}
2 <title>{repo|escape}: Summary</title>
2 <title>{repo|escape}: Summary</title>
3 <link rel="alternate" type="application/atom+xml"
3 <link rel="alternate" type="application/atom+xml"
4 href="{url|urlescape}atom-log" title="Atom feed for {repo|escape}"/>
4 href="{url|urlescape}atom-log" title="Atom feed for {repo|escape}"/>
5 <link rel="alternate" type="application/rss+xml"
5 <link rel="alternate" type="application/rss+xml"
6 href="{url|urlescape}rss-log" title="RSS feed for {repo|escape}"/>
6 href="{url|urlescape}rss-log" title="RSS feed for {repo|escape}"/>
7 </head>
7 </head>
8 <body>
8 <body>
9
9
10 <div class="page_header">
10 <div class="page_header">
11 <a href="{logourl}" title="Mercurial" style="float: right;">Mercurial</a>
11 <a href="{logourl}" title="Mercurial" style="float: right;">Mercurial</a>
12 <a href="/">Mercurial</a> {pathdef%breadcrumb} / summary
12 <a href="/">Mercurial</a> {pathdef%breadcrumb} / summary
13 </div>
13 </div>
14
14
15 <div class="page_nav">
15 <div class="page_nav">
16 <div>
16 <div>
17 summary |
17 summary |
18 <a href="{url|urlescape}shortlog{sessionvars%urlparameter}">shortlog</a> |
18 <a href="{url|urlescape}shortlog{sessionvars%urlparameter}">shortlog</a> |
19 <a href="{url|urlescape}log{sessionvars%urlparameter}">changelog</a> |
19 <a href="{url|urlescape}log{sessionvars%urlparameter}">changelog</a> |
20 <a href="{url|urlescape}graph{sessionvars%urlparameter}">graph</a> |
20 <a href="{url|urlescape}graph{sessionvars%urlparameter}">graph</a> |
21 <a href="{url|urlescape}tags{sessionvars%urlparameter}">tags</a> |
21 <a href="{url|urlescape}tags{sessionvars%urlparameter}">tags</a> |
22 <a href="{url|urlescape}bookmarks{sessionvars%urlparameter}">bookmarks</a> |
22 <a href="{url|urlescape}bookmarks{sessionvars%urlparameter}">bookmarks</a> |
23 <a href="{url|urlescape}branches{sessionvars%urlparameter}">branches</a> |
23 <a href="{url|urlescape}branches{sessionvars%urlparameter}">branches</a> |
24 <a href="{url|urlescape}file{sessionvars%urlparameter}">files</a>{archives%archiveentry} |
24 <a href="{url|urlescape}file{sessionvars%urlparameter}">files</a>{archives%archiveentry} |
25 <a href="{url|urlescape}help{sessionvars%urlparameter}">help</a>
25 <a href="{url|urlescape}help{sessionvars%urlparameter}">help</a>
26 </div>
26 </div>
27 {searchform}
27 {searchform}
28 </div>
28 </div>
29
29
30 <div class="title">&nbsp;</div>
30 <div class="title">&nbsp;</div>
31 <table cellspacing="0">
31 <table cellspacing="0">
32 <tr><td>description</td><td>{desc}</td></tr>
32 <tr><td>description</td><td>{desc}</td></tr>
33 <tr><td>owner</td><td>{owner|obfuscate}</td></tr>
33 <tr><td>owner</td><td>{owner|obfuscate}</td></tr>
34 <tr><td>last change</td><td class="date age">{lastchange|rfc822date}</td></tr>
34 <tr><td>last change</td><td class="date age">{lastchange|rfc822date}</td></tr>
35 </table>
35 </table>
36
36
37 <div><a class="title" href="{url|urlescape}shortlog{sessionvars%urlparameter}">changes</a></div>
37 <div><a class="title" href="{url|urlescape}shortlog{sessionvars%urlparameter}">changes</a></div>
38 <table cellspacing="0">
38 <table cellspacing="0">
39 {shortlog}
39 {shortlog%shortlogentry}
40 <tr class="light"><td colspan="4"><a class="list" href="{url|urlescape}shortlog{sessionvars%urlparameter}">...</a></td></tr>
40 <tr class="light"><td colspan="4"><a class="list" href="{url|urlescape}shortlog{sessionvars%urlparameter}">...</a></td></tr>
41 </table>
41 </table>
42
42
43 <div><a class="title" href="{url|urlescape}tags{sessionvars%urlparameter}">tags</a></div>
43 <div><a class="title" href="{url|urlescape}tags{sessionvars%urlparameter}">tags</a></div>
44 <table cellspacing="0">
44 <table cellspacing="0">
45 {tags}
45 {tags%tagentry}
46 <tr class="light"><td colspan="3"><a class="list" href="{url|urlescape}tags{sessionvars%urlparameter}">...</a></td></tr>
46 <tr class="light"><td colspan="3"><a class="list" href="{url|urlescape}tags{sessionvars%urlparameter}">...</a></td></tr>
47 </table>
47 </table>
48
48
49 <div><a class="title" href="{url|urlescape}bookmarks{sessionvars%urlparameter}">bookmarks</a></div>
49 <div><a class="title" href="{url|urlescape}bookmarks{sessionvars%urlparameter}">bookmarks</a></div>
50 <table cellspacing="0">
50 <table cellspacing="0">
51 {bookmarks%bookmarkentry}
51 {bookmarks%bookmarkentry}
52 <tr class="light"><td colspan="3"><a class="list" href="{url|urlescape}bookmarks{sessionvars%urlparameter}">...</a></td></tr>
52 <tr class="light"><td colspan="3"><a class="list" href="{url|urlescape}bookmarks{sessionvars%urlparameter}">...</a></td></tr>
53 </table>
53 </table>
54
54
55 <div><a class="title" href="{url|urlescape}branches{sessionvars%urlparameter}">branches</a></div>
55 <div><a class="title" href="{url|urlescape}branches{sessionvars%urlparameter}">branches</a></div>
56 <table cellspacing="0">
56 <table cellspacing="0">
57 {branches%branchentry}
57 {branches%branchentry}
58 <tr class="light">
58 <tr class="light">
59 <td colspan="3"><a class="list" href="{url|urlescape}branches{sessionvars%urlparameter}">...</a></td>
59 <td colspan="3"><a class="list" href="{url|urlescape}branches{sessionvars%urlparameter}">...</a></td>
60 </tr>
60 </tr>
61 </table>
61 </table>
62 {footer}
62 {footer}
@@ -1,71 +1,71 b''
1 {header}
1 {header}
2 <title>{repo|escape}: Summary</title>
2 <title>{repo|escape}: Summary</title>
3 <link rel="alternate" type="application/atom+xml" href="{url|urlescape}atom-log" title="Atom feed for {repo|escape}"/>
3 <link rel="alternate" type="application/atom+xml" href="{url|urlescape}atom-log" title="Atom feed for {repo|escape}"/>
4 <link rel="alternate" type="application/rss+xml" href="{url|urlescape}rss-log" title="RSS feed for {repo|escape}"/>
4 <link rel="alternate" type="application/rss+xml" href="{url|urlescape}rss-log" title="RSS feed for {repo|escape}"/>
5 </head>
5 </head>
6
6
7 <body>
7 <body>
8 <div id="container">
8 <div id="container">
9 <div class="page-header">
9 <div class="page-header">
10 <h1 class="breadcrumb"><a href="/">Mercurial</a> {pathdef%breadcrumb} / summary</h1>
10 <h1 class="breadcrumb"><a href="/">Mercurial</a> {pathdef%breadcrumb} / summary</h1>
11
11
12 {searchform}
12 {searchform}
13
13
14 <ul class="page-nav">
14 <ul class="page-nav">
15 <li class="current">summary</li>
15 <li class="current">summary</li>
16 <li><a href="{url|urlescape}shortlog{sessionvars%urlparameter}">shortlog</a></li>
16 <li><a href="{url|urlescape}shortlog{sessionvars%urlparameter}">shortlog</a></li>
17 <li><a href="{url|urlescape}log{sessionvars%urlparameter}">changelog</a></li>
17 <li><a href="{url|urlescape}log{sessionvars%urlparameter}">changelog</a></li>
18 <li><a href="{url|urlescape}graph{sessionvars%urlparameter}">graph</a></li>
18 <li><a href="{url|urlescape}graph{sessionvars%urlparameter}">graph</a></li>
19 <li><a href="{url|urlescape}tags{sessionvars%urlparameter}">tags</a></li>
19 <li><a href="{url|urlescape}tags{sessionvars%urlparameter}">tags</a></li>
20 <li><a href="{url|urlescape}bookmarks{sessionvars%urlparameter}">bookmarks</a></li>
20 <li><a href="{url|urlescape}bookmarks{sessionvars%urlparameter}">bookmarks</a></li>
21 <li><a href="{url|urlescape}branches{sessionvars%urlparameter}">branches</a></li>
21 <li><a href="{url|urlescape}branches{sessionvars%urlparameter}">branches</a></li>
22 <li><a href="{url|urlescape}file{sessionvars%urlparameter}">files</a></li>
22 <li><a href="{url|urlescape}file{sessionvars%urlparameter}">files</a></li>
23 {archives%archiveentry}
23 {archives%archiveentry}
24 <li><a href="{url|urlescape}help{sessionvars%urlparameter}">help</a></li>
24 <li><a href="{url|urlescape}help{sessionvars%urlparameter}">help</a></li>
25 </ul>
25 </ul>
26 </div>
26 </div>
27
27
28 <h2 class="no-link no-border">Mercurial Repository Overview</h2>
28 <h2 class="no-link no-border">Mercurial Repository Overview</h2>
29 <dl class="overview">
29 <dl class="overview">
30 <dt>name</dt>
30 <dt>name</dt>
31 <dd>{repo|escape}</dd>
31 <dd>{repo|escape}</dd>
32 <dt>description</dt>
32 <dt>description</dt>
33 <dd>{desc}</dd>
33 <dd>{desc}</dd>
34 <dt>owner</dt>
34 <dt>owner</dt>
35 <dd>{owner|obfuscate}</dd>
35 <dd>{owner|obfuscate}</dd>
36 <dt>last change</dt>
36 <dt>last change</dt>
37 <dd class="date age">{lastchange|rfc822date}</dd>
37 <dd class="date age">{lastchange|rfc822date}</dd>
38 </dl>
38 </dl>
39
39
40 <h2><a href="{url|urlescape}shortlog{sessionvars%urlparameter}">Changes</a></h2>
40 <h2><a href="{url|urlescape}shortlog{sessionvars%urlparameter}">Changes</a></h2>
41 <table>
41 <table>
42 {shortlog}
42 {shortlog%shortlogentry}
43 <tr class="light">
43 <tr class="light">
44 <td colspan="4"><a class="list" href="{url|urlescape}shortlog{sessionvars%urlparameter}">...</a></td>
44 <td colspan="4"><a class="list" href="{url|urlescape}shortlog{sessionvars%urlparameter}">...</a></td>
45 </tr>
45 </tr>
46 </table>
46 </table>
47
47
48 <h2><a href="{url|urlescape}tags{sessionvars%urlparameter}">Tags</a></h2>
48 <h2><a href="{url|urlescape}tags{sessionvars%urlparameter}">Tags</a></h2>
49 <table>
49 <table>
50 {tags}
50 {tags%tagentry}
51 <tr class="light">
51 <tr class="light">
52 <td colspan="3"><a class="list" href="{url|urlescape}tags{sessionvars%urlparameter}">...</a></td>
52 <td colspan="3"><a class="list" href="{url|urlescape}tags{sessionvars%urlparameter}">...</a></td>
53 </tr>
53 </tr>
54 </table>
54 </table>
55
55
56 <h2><a href="{url|urlescape}bookmarks{sessionvars%urlparameter}">Bookmarks</a></h2>
56 <h2><a href="{url|urlescape}bookmarks{sessionvars%urlparameter}">Bookmarks</a></h2>
57 <table>
57 <table>
58 {bookmarks%bookmarkentry}
58 {bookmarks%bookmarkentry}
59 <tr class="light">
59 <tr class="light">
60 <td colspan="3"><a class="list" href="{url|urlescape}bookmarks{sessionvars%urlparameter}">...</a></td>
60 <td colspan="3"><a class="list" href="{url|urlescape}bookmarks{sessionvars%urlparameter}">...</a></td>
61 </tr>
61 </tr>
62 </table>
62 </table>
63
63
64 <h2><a href="{url|urlescape}branches{sessionvars%urlparameter}">Branches</a></h2>
64 <h2><a href="{url|urlescape}branches{sessionvars%urlparameter}">Branches</a></h2>
65 <table>
65 <table>
66 {branches%branchentry}
66 {branches%branchentry}
67 <tr class="light">
67 <tr class="light">
68 <td colspan="3"><a class="list" href="{url|urlescape}branches{sessionvars%urlparameter}">...</a></td>
68 <td colspan="3"><a class="list" href="{url|urlescape}branches{sessionvars%urlparameter}">...</a></td>
69 </tr>
69 </tr>
70 </table>
70 </table>
71 {footer}
71 {footer}
General Comments 0
You need to be logged in to leave comments. Login now