author | Yuya Nishihara <yuya@tcha.org> |
Mon, 03 Apr 2017 22:07:09 +0900 | |
changeset 31921 | 2156934b7917 |
parent 31727 | 6be6e4becaaf |
child 31939 | 604d31507f86 |
permissions | -rw-r--r-- |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1 |
# |
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
2 |
# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> |
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
3 |
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
4 |
# |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
10263 | 6 |
# GNU General Public License version 2 or any later version. |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
7 |
|
27046
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
8 |
from __future__ import absolute_import |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
9 |
|
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
10 |
import cgi |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
11 |
import copy |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
12 |
import mimetypes |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
13 |
import os |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
14 |
import re |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
15 |
|
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
16 |
from ..i18n import _ |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
17 |
from ..node import hex, short |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
18 |
|
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
19 |
from .common import ( |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
20 |
ErrorResponse, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
21 |
HTTP_FORBIDDEN, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
22 |
HTTP_NOT_FOUND, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
23 |
HTTP_OK, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
24 |
get_contact, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
25 |
paritygen, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
26 |
staticfile, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
27 |
) |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
28 |
|
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
29 |
from .. import ( |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
30 |
archival, |
31665
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
31 |
context, |
27046
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
32 |
encoding, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
33 |
error, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
34 |
graphmod, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
35 |
revset, |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31023
diff
changeset
|
36 |
revsetlang, |
27046
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
37 |
scmutil, |
31023
aea06029919e
revset: import set classes directly from smartset module
Yuya Nishihara <yuya@tcha.org>
parents:
30826
diff
changeset
|
38 |
smartset, |
27046
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
39 |
templatefilters, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
40 |
templater, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
41 |
util, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
42 |
) |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
43 |
|
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
44 |
from . import ( |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
45 |
webutil, |
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
46 |
) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
47 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
48 |
__all__ = [] |
24077
e8046ca0405d
webcommands: define a dict of available commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24076
diff
changeset
|
49 |
commands = {} |
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
50 |
|
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
51 |
class webcommand(object): |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
52 |
"""Decorator used to register a web command handler. |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
53 |
|
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
54 |
The decorator takes as its positional arguments the name/path the |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
55 |
command should be accessible under. |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
56 |
|
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
57 |
Usage: |
5963
5be210afe1b8
hgweb: explicitly check if requested command exists
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5960
diff
changeset
|
58 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
59 |
@webcommand('mycommand') |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
60 |
def mycommand(web, req, tmpl): |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
61 |
pass |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
62 |
""" |
5963
5be210afe1b8
hgweb: explicitly check if requested command exists
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5960
diff
changeset
|
63 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
64 |
def __init__(self, name): |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
65 |
self.name = name |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
66 |
|
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
67 |
def __call__(self, func): |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
68 |
__all__.append(self.name) |
24077
e8046ca0405d
webcommands: define a dict of available commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24076
diff
changeset
|
69 |
commands[self.name] = func |
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
70 |
return func |
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
71 |
|
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
72 |
@webcommand('log') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
73 |
def log(web, req, tmpl): |
24087
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
74 |
""" |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
75 |
/log[/{revision}[/{path}]] |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
76 |
-------------------------- |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
77 |
|
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
78 |
Show repository or file history. |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
79 |
|
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
80 |
For URLs of the form ``/log/{revision}``, a list of changesets starting at |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
81 |
the specified changeset identifier is shown. If ``{revision}`` is not |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
82 |
defined, the default is ``tip``. This form is equivalent to the |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
83 |
``changelog`` handler. |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
84 |
|
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
85 |
For URLs of the form ``/log/{revision}/{file}``, the history for a specific |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
86 |
file will be shown. This form is equivalent to the ``filelog`` handler. |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
87 |
""" |
6f5b4393590c
webcommands: document "log" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24086
diff
changeset
|
88 |
|
5915
d0576d065993
Prefer i in d over d.has_key(i)
Christian Ebert <blacktrash@gmx.net>
parents:
5890
diff
changeset
|
89 |
if 'file' in req.form and req.form['file'][0]: |
5964
1cd1582ef25f
hgweb: centralize req.write() calls
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5963
diff
changeset
|
90 |
return filelog(web, req, tmpl) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
91 |
else: |
5964
1cd1582ef25f
hgweb: centralize req.write() calls
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5963
diff
changeset
|
92 |
return changelog(web, req, tmpl) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
93 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
94 |
@webcommand('rawfile') |
5890
a0e20a5eba3c
hgweb: fast path for sending raw files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5600
diff
changeset
|
95 |
def rawfile(web, req, tmpl): |
15004
d06b9c55ddab
hgweb: raw file mimetype guessing configurable, off by default (BC) (issue2923)
Matt Mackall <mpm@selenic.com>
parents:
14771
diff
changeset
|
96 |
guessmime = web.configbool('web', 'guessmime', False) |
d06b9c55ddab
hgweb: raw file mimetype guessing configurable, off by default (BC) (issue2923)
Matt Mackall <mpm@selenic.com>
parents:
14771
diff
changeset
|
97 |
|
6392
2540521dc7c1
hgweb: separate out utility functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6368
diff
changeset
|
98 |
path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) |
5890
a0e20a5eba3c
hgweb: fast path for sending raw files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5600
diff
changeset
|
99 |
if not path: |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
100 |
content = manifest(web, req, tmpl) |
5993
948a41e77902
hgweb: explicit response status
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5964
diff
changeset
|
101 |
req.respond(HTTP_OK, web.ctype) |
948a41e77902
hgweb: explicit response status
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5964
diff
changeset
|
102 |
return content |
5890
a0e20a5eba3c
hgweb: fast path for sending raw files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5600
diff
changeset
|
103 |
|
a0e20a5eba3c
hgweb: fast path for sending raw files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5600
diff
changeset
|
104 |
try: |
6392
2540521dc7c1
hgweb: separate out utility functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6368
diff
changeset
|
105 |
fctx = webutil.filectx(web.repo, req) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25602
diff
changeset
|
106 |
except error.LookupError as inst: |
6368
2c370f08c486
hgweb: better error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6217
diff
changeset
|
107 |
try: |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
108 |
content = manifest(web, req, tmpl) |
6368
2c370f08c486
hgweb: better error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6217
diff
changeset
|
109 |
req.respond(HTTP_OK, web.ctype) |
2c370f08c486
hgweb: better error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6217
diff
changeset
|
110 |
return content |
2c370f08c486
hgweb: better error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6217
diff
changeset
|
111 |
except ErrorResponse: |
2c370f08c486
hgweb: better error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6217
diff
changeset
|
112 |
raise inst |
5890
a0e20a5eba3c
hgweb: fast path for sending raw files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5600
diff
changeset
|
113 |
|
a0e20a5eba3c
hgweb: fast path for sending raw files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5600
diff
changeset
|
114 |
path = fctx.path() |
a0e20a5eba3c
hgweb: fast path for sending raw files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5600
diff
changeset
|
115 |
text = fctx.data() |
15004
d06b9c55ddab
hgweb: raw file mimetype guessing configurable, off by default (BC) (issue2923)
Matt Mackall <mpm@selenic.com>
parents:
14771
diff
changeset
|
116 |
mt = 'application/binary' |
d06b9c55ddab
hgweb: raw file mimetype guessing configurable, off by default (BC) (issue2923)
Matt Mackall <mpm@selenic.com>
parents:
14771
diff
changeset
|
117 |
if guessmime: |
d06b9c55ddab
hgweb: raw file mimetype guessing configurable, off by default (BC) (issue2923)
Matt Mackall <mpm@selenic.com>
parents:
14771
diff
changeset
|
118 |
mt = mimetypes.guess_type(path)[0] |
d06b9c55ddab
hgweb: raw file mimetype guessing configurable, off by default (BC) (issue2923)
Matt Mackall <mpm@selenic.com>
parents:
14771
diff
changeset
|
119 |
if mt is None: |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
120 |
if util.binary(text): |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
121 |
mt = 'application/binary' |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
122 |
else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
123 |
mt = 'text/plain' |
11332
716e176a4e01
hgweb: specify a charset when sending raw text files
Julian Cowley <julian@lava.net>
parents:
10394
diff
changeset
|
124 |
if mt.startswith('text/'): |
716e176a4e01
hgweb: specify a charset when sending raw text files
Julian Cowley <julian@lava.net>
parents:
10394
diff
changeset
|
125 |
mt += '; charset="%s"' % encoding.encoding |
5890
a0e20a5eba3c
hgweb: fast path for sending raw files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5600
diff
changeset
|
126 |
|
18352
e33b9b92a200
hgweb: pass the actual response body to request.response, not just the length
Mads Kiilerich <mads@kiilerich.com>
parents:
18348
diff
changeset
|
127 |
req.respond(HTTP_OK, mt, path, body=text) |
e33b9b92a200
hgweb: pass the actual response body to request.response, not just the length
Mads Kiilerich <mads@kiilerich.com>
parents:
18348
diff
changeset
|
128 |
return [] |
5890
a0e20a5eba3c
hgweb: fast path for sending raw files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5600
diff
changeset
|
129 |
|
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
130 |
def _filerevision(web, req, tmpl, fctx): |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
131 |
f = fctx.path() |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
132 |
text = fctx.data() |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
133 |
parity = paritygen(web.stripecount) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
134 |
|
19657
145636d31bb4
hgweb: import the whole util module in webcommands instead of just one function
Alexander Plavin <alexander@plav.in>
parents:
19656
diff
changeset
|
135 |
if util.binary(text): |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
136 |
mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
137 |
text = '(binary:%s)' % mt |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
138 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
139 |
def lines(): |
9136
31177742f54a
for calls expecting bool args, pass bool instead of int
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
8842
diff
changeset
|
140 |
for lineno, t in enumerate(text.splitlines(True)): |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
141 |
yield {"line": t, |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
142 |
"lineid": "l%d" % (lineno + 1), |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
143 |
"linenumber": "% 6d" % (lineno + 1), |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
144 |
"parity": next(parity)} |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
145 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
146 |
return tmpl("filerevision", |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
147 |
file=f, |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
148 |
path=webutil.up(f), |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
149 |
text=lines(), |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
150 |
symrev=webutil.symrevorshortnode(req, fctx), |
6434
62e0bb41e682
hgweb: minor improvements for new web style
Matt Mackall <mpm@selenic.com>
parents:
6410
diff
changeset
|
151 |
rename=webutil.renamelink(fctx), |
27294
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
152 |
permissions=fctx.manifest().flags(f), |
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
153 |
**webutil.commonentry(web.repo, fctx)) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
154 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
155 |
@webcommand('file') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
156 |
def file(web, req, tmpl): |
24088
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
157 |
""" |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
158 |
/file/{revision}[/{path}] |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
159 |
------------------------- |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
160 |
|
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
161 |
Show information about a directory or file in the repository. |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
162 |
|
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
163 |
Info about the ``path`` given as a URL parameter will be rendered. |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
164 |
|
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
165 |
If ``path`` is a directory, information about the entries in that |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
166 |
directory will be rendered. This form is equivalent to the ``manifest`` |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
167 |
handler. |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
168 |
|
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
169 |
If ``path`` is a file, information about that file will be shown via |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
170 |
the ``filerevision`` template. |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
171 |
|
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
172 |
If ``path`` is not defined, information about the root directory will |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
173 |
be rendered. |
fe3ee31b039f
webcommands: document "file" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24087
diff
changeset
|
174 |
""" |
6392
2540521dc7c1
hgweb: separate out utility functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6368
diff
changeset
|
175 |
path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) |
6853
2ff0829bdae5
hgweb: do not use unassigned variables in exception handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6669
diff
changeset
|
176 |
if not path: |
6857 | 177 |
return manifest(web, req, tmpl) |
6853
2ff0829bdae5
hgweb: do not use unassigned variables in exception handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6669
diff
changeset
|
178 |
try: |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
179 |
return _filerevision(web, req, tmpl, webutil.filectx(web.repo, req)) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25602
diff
changeset
|
180 |
except error.LookupError as inst: |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
181 |
try: |
6857 | 182 |
return manifest(web, req, tmpl) |
6853
2ff0829bdae5
hgweb: do not use unassigned variables in exception handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6669
diff
changeset
|
183 |
except ErrorResponse: |
2ff0829bdae5
hgweb: do not use unassigned variables in exception handling
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6669
diff
changeset
|
184 |
raise inst |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
185 |
|
10247
e8c7410371e0
hgweb: add less/more links for search logs (issue1972)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10246
diff
changeset
|
186 |
def _search(web, req, tmpl): |
19656
60ce14e41faf
hgweb: add string constants for search mode names
Alexander Plavin <alexander@plav.in>
parents:
19634
diff
changeset
|
187 |
MODE_REVISION = 'rev' |
60ce14e41faf
hgweb: add string constants for search mode names
Alexander Plavin <alexander@plav.in>
parents:
19634
diff
changeset
|
188 |
MODE_KEYWORD = 'keyword' |
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
189 |
MODE_REVSET = 'revset' |
10247
e8c7410371e0
hgweb: add less/more links for search logs (issue1972)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10246
diff
changeset
|
190 |
|
19633
217f2b9acee0
hgweb: search() function supports direct pointing to revision
Alexander Plavin <alexander@plav.in>
parents:
19632
diff
changeset
|
191 |
def revsearch(ctx): |
217f2b9acee0
hgweb: search() function supports direct pointing to revision
Alexander Plavin <alexander@plav.in>
parents:
19632
diff
changeset
|
192 |
yield ctx |
217f2b9acee0
hgweb: search() function supports direct pointing to revision
Alexander Plavin <alexander@plav.in>
parents:
19632
diff
changeset
|
193 |
|
19632
299511aabf85
hgweb: pass arguments which a function depends on explicitly in search
Alexander Plavin <alexander@plav.in>
parents:
19631
diff
changeset
|
194 |
def keywordsearch(query): |
15727
917f263eeb26
i18n: use "encoding.lower()" to normalize string in hgweb search query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15528
diff
changeset
|
195 |
lower = encoding.lower |
917f263eeb26
i18n: use "encoding.lower()" to normalize string in hgweb search query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15528
diff
changeset
|
196 |
qw = lower(query).split() |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
197 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
198 |
def revgen(): |
18497
a58d8936647a
hgweb: prevent traceback during search when filtered (issue3783)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18478
diff
changeset
|
199 |
cl = web.repo.changelog |
12059
0de6cfdcaad8
webcommands: remove unncessary access to repo.changelog
Patrick Mezard <pmezard@gmail.com>
parents:
11332
diff
changeset
|
200 |
for i in xrange(len(web.repo) - 1, 0, -100): |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
201 |
l = [] |
19491
e111d5e6bbbd
hgweb: fix duplication for some search queries
Alexander Plavin <me@aplavin.ru>
parents:
19487
diff
changeset
|
202 |
for j in cl.revs(max(0, i - 99), i): |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6720
diff
changeset
|
203 |
ctx = web.repo[j] |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
204 |
l.append(ctx) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
205 |
l.reverse() |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
206 |
for e in l: |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
207 |
yield e |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
208 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
209 |
for ctx in revgen(): |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
210 |
miss = 0 |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
211 |
for q in qw: |
15727
917f263eeb26
i18n: use "encoding.lower()" to normalize string in hgweb search query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15528
diff
changeset
|
212 |
if not (q in lower(ctx.user()) or |
917f263eeb26
i18n: use "encoding.lower()" to normalize string in hgweb search query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15528
diff
changeset
|
213 |
q in lower(ctx.description()) or |
917f263eeb26
i18n: use "encoding.lower()" to normalize string in hgweb search query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15528
diff
changeset
|
214 |
q in lower(" ".join(ctx.files()))): |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
215 |
miss = 1 |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
216 |
break |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
217 |
if miss: |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
218 |
continue |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
219 |
|
19533
9a020b354d93
hgweb: separate search itself and template generation
Alexander Plavin <alexander@plav.in>
parents:
19499
diff
changeset
|
220 |
yield ctx |
9a020b354d93
hgweb: separate search itself and template generation
Alexander Plavin <alexander@plav.in>
parents:
19499
diff
changeset
|
221 |
|
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
222 |
def revsetsearch(revs): |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
223 |
for r in revs: |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
224 |
yield web.repo[r] |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
225 |
|
19631
cf9e5e45c1d3
hgweb: add dynamic search function selection, depending on the query
Alexander Plavin <alexander@plav.in>
parents:
19534
diff
changeset
|
226 |
searchfuncs = { |
20004
06e118c097ff
hgweb, i18n: do not translate search mode description
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
19951
diff
changeset
|
227 |
MODE_REVISION: (revsearch, 'exact revision search'), |
06e118c097ff
hgweb, i18n: do not translate search mode description
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
19951
diff
changeset
|
228 |
MODE_KEYWORD: (keywordsearch, 'literal keyword search'), |
06e118c097ff
hgweb, i18n: do not translate search mode description
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
19951
diff
changeset
|
229 |
MODE_REVSET: (revsetsearch, 'revset expression search'), |
19631
cf9e5e45c1d3
hgweb: add dynamic search function selection, depending on the query
Alexander Plavin <alexander@plav.in>
parents:
19534
diff
changeset
|
230 |
} |
cf9e5e45c1d3
hgweb: add dynamic search function selection, depending on the query
Alexander Plavin <alexander@plav.in>
parents:
19534
diff
changeset
|
231 |
|
19632
299511aabf85
hgweb: pass arguments which a function depends on explicitly in search
Alexander Plavin <alexander@plav.in>
parents:
19631
diff
changeset
|
232 |
def getsearchmode(query): |
19633
217f2b9acee0
hgweb: search() function supports direct pointing to revision
Alexander Plavin <alexander@plav.in>
parents:
19632
diff
changeset
|
233 |
try: |
217f2b9acee0
hgweb: search() function supports direct pointing to revision
Alexander Plavin <alexander@plav.in>
parents:
19632
diff
changeset
|
234 |
ctx = web.repo[query] |
217f2b9acee0
hgweb: search() function supports direct pointing to revision
Alexander Plavin <alexander@plav.in>
parents:
19632
diff
changeset
|
235 |
except (error.RepoError, error.LookupError): |
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
236 |
# query is not an exact revision pointer, need to |
19951
d51c4d85ec23
spelling: random spell checker fixes
Mads Kiilerich <madski@unity3d.com>
parents:
19886
diff
changeset
|
237 |
# decide if it's a revset expression or keywords |
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
238 |
pass |
19633
217f2b9acee0
hgweb: search() function supports direct pointing to revision
Alexander Plavin <alexander@plav.in>
parents:
19632
diff
changeset
|
239 |
else: |
19656
60ce14e41faf
hgweb: add string constants for search mode names
Alexander Plavin <alexander@plav.in>
parents:
19634
diff
changeset
|
240 |
return MODE_REVISION, ctx |
19631
cf9e5e45c1d3
hgweb: add dynamic search function selection, depending on the query
Alexander Plavin <alexander@plav.in>
parents:
19534
diff
changeset
|
241 |
|
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
242 |
revdef = 'reverse(%s)' % query |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
243 |
try: |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31023
diff
changeset
|
244 |
tree = revsetlang.parse(revdef) |
27009
f5faef7e9119
hgweb: unify import style of error classes
Yuya Nishihara <yuya@tcha.org>
parents:
26894
diff
changeset
|
245 |
except error.ParseError: |
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
246 |
# can't parse to a revset tree |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
247 |
return MODE_KEYWORD, query |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
248 |
|
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31023
diff
changeset
|
249 |
if revsetlang.depth(tree) <= 2: |
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
250 |
# no revset syntax used |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
251 |
return MODE_KEYWORD, query |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
252 |
|
25149
3f0744eeaeaf
cleanup: use __builtins__.any instead of util.any
Augie Fackler <augie@google.com>
parents:
25136
diff
changeset
|
253 |
if any((token, (value or '')[:3]) == ('string', 're:') |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31023
diff
changeset
|
254 |
for token, value, pos in revsetlang.tokenize(revdef)): |
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
255 |
return MODE_KEYWORD, query |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
256 |
|
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31023
diff
changeset
|
257 |
funcsused = revsetlang.funcsused(tree) |
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
258 |
if not funcsused.issubset(revset.safesymbols): |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
259 |
return MODE_KEYWORD, query |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
260 |
|
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
261 |
mfunc = revset.match(web.repo.ui, revdef) |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
262 |
try: |
24114
fafd9a1284cf
revset: make match function initiate query from full set by default
Yuya Nishihara <yuya@tcha.org>
parents:
24097
diff
changeset
|
263 |
revs = mfunc(web.repo) |
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
264 |
return MODE_REVSET, revs |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
265 |
# ParseError: wrongly placed tokens, wrongs arguments, etc |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
266 |
# RepoLookupError: no such revision, e.g. in 'revision:' |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
267 |
# Abort: bookmark/tag not exists |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
268 |
# LookupError: ambiguous identifier, e.g. in '(bc)' on a large repo |
27009
f5faef7e9119
hgweb: unify import style of error classes
Yuya Nishihara <yuya@tcha.org>
parents:
26894
diff
changeset
|
269 |
except (error.ParseError, error.RepoLookupError, error.Abort, |
f5faef7e9119
hgweb: unify import style of error classes
Yuya Nishihara <yuya@tcha.org>
parents:
26894
diff
changeset
|
270 |
LookupError): |
19722
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
271 |
return MODE_KEYWORD, query |
bf15935b68a3
hgweb: add revset syntax support to search
Alexander Plavin <alexander@plav.in>
parents:
19657
diff
changeset
|
272 |
|
19533
9a020b354d93
hgweb: separate search itself and template generation
Alexander Plavin <alexander@plav.in>
parents:
19499
diff
changeset
|
273 |
def changelist(**map): |
9a020b354d93
hgweb: separate search itself and template generation
Alexander Plavin <alexander@plav.in>
parents:
19499
diff
changeset
|
274 |
count = 0 |
9a020b354d93
hgweb: separate search itself and template generation
Alexander Plavin <alexander@plav.in>
parents:
19499
diff
changeset
|
275 |
|
19765
521c373ff134
hgweb: pass variable with current search mode name to the search template
Alexander Plavin <alexander@plav.in>
parents:
19738
diff
changeset
|
276 |
for ctx in searchfunc[0](funcarg): |
6659
bc553c6d1ef9
webcommands: fix increments lost by 894875eae49b
Andrew Beekhof <beekhof@gmail.com>
parents:
6657
diff
changeset
|
277 |
count += 1 |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
278 |
n = ctx.node() |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
279 |
showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) |
7311
de9c87fe1620
hgweb: move another utility function into the webutil module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7310
diff
changeset
|
280 |
files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
281 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
282 |
yield tmpl('searchentry', |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
283 |
parity=next(parity), |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
284 |
changelogtag=showtags, |
7311
de9c87fe1620
hgweb: move another utility function into the webutil module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7310
diff
changeset
|
285 |
files=files, |
27294
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
286 |
**webutil.commonentry(web.repo, ctx)) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
287 |
|
10247
e8c7410371e0
hgweb: add less/more links for search logs (issue1972)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10246
diff
changeset
|
288 |
if count >= revcount: |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
289 |
break |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
290 |
|
19418
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
291 |
query = req.form['rev'][0] |
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
292 |
revcount = web.maxchanges |
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
293 |
if 'revcount' in req.form: |
20092
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
294 |
try: |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
295 |
revcount = int(req.form.get('revcount', [revcount])[0]) |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
296 |
revcount = max(revcount, 1) |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
297 |
tmpl.defaults['sessionvars']['revcount'] = revcount |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
298 |
except ValueError: |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
299 |
pass |
19418
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
300 |
|
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
301 |
lessvars = copy.copy(tmpl.defaults['sessionvars']) |
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
302 |
lessvars['revcount'] = max(revcount / 2, 1) |
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
303 |
lessvars['rev'] = query |
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
304 |
morevars = copy.copy(tmpl.defaults['sessionvars']) |
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
305 |
morevars['revcount'] = revcount * 2 |
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
306 |
morevars['rev'] = query |
55b9d98a1ef4
hgweb: move local changelist function to the beginning of the parent one
Alexander Plavin <me@aplavin.ru>
parents:
19396
diff
changeset
|
307 |
|
19632
299511aabf85
hgweb: pass arguments which a function depends on explicitly in search
Alexander Plavin <alexander@plav.in>
parents:
19631
diff
changeset
|
308 |
mode, funcarg = getsearchmode(query) |
19768
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
309 |
|
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
310 |
if 'forcekw' in req.form: |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
311 |
showforcekw = '' |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
312 |
showunforcekw = searchfuncs[mode][1] |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
313 |
mode = MODE_KEYWORD |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
314 |
funcarg = query |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
315 |
else: |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
316 |
if mode != MODE_KEYWORD: |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
317 |
showforcekw = searchfuncs[MODE_KEYWORD][1] |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
318 |
else: |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
319 |
showforcekw = '' |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
320 |
showunforcekw = '' |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
321 |
|
19631
cf9e5e45c1d3
hgweb: add dynamic search function selection, depending on the query
Alexander Plavin <alexander@plav.in>
parents:
19534
diff
changeset
|
322 |
searchfunc = searchfuncs[mode] |
cf9e5e45c1d3
hgweb: add dynamic search function selection, depending on the query
Alexander Plavin <alexander@plav.in>
parents:
19534
diff
changeset
|
323 |
|
12059
0de6cfdcaad8
webcommands: remove unncessary access to repo.changelog
Patrick Mezard <pmezard@gmail.com>
parents:
11332
diff
changeset
|
324 |
tip = web.repo['tip'] |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
325 |
parity = paritygen(web.stripecount) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
326 |
|
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
327 |
return tmpl('search', query=query, node=tip.hex(), symrev='tip', |
10247
e8c7410371e0
hgweb: add less/more links for search logs (issue1972)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10246
diff
changeset
|
328 |
entries=changelist, archives=web.archivelist("tip"), |
19765
521c373ff134
hgweb: pass variable with current search mode name to the search template
Alexander Plavin <alexander@plav.in>
parents:
19738
diff
changeset
|
329 |
morevars=morevars, lessvars=lessvars, |
19768
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
330 |
modedesc=searchfunc[1], |
186f54d40fdd
hgweb: add link to force literal keyword search
Alexander Plavin <alexander@plav.in>
parents:
19765
diff
changeset
|
331 |
showforcekw=showforcekw, showunforcekw=showunforcekw) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
332 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
333 |
@webcommand('changelog') |
10247
e8c7410371e0
hgweb: add less/more links for search logs (issue1972)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10246
diff
changeset
|
334 |
def changelog(web, req, tmpl, shortlog=False): |
24089
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
335 |
""" |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
336 |
/changelog[/{revision}] |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
337 |
----------------------- |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
338 |
|
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
339 |
Show information about multiple changesets. |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
340 |
|
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
341 |
If the optional ``revision`` URL argument is absent, information about |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
342 |
all changesets starting at ``tip`` will be rendered. If the ``revision`` |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
343 |
argument is present, changesets will be shown starting from the specified |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
344 |
revision. |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
345 |
|
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
346 |
If ``revision`` is absent, the ``rev`` query string argument may be |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
347 |
defined. This will perform a search for changesets. |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
348 |
|
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
349 |
The argument for ``rev`` can be a single revision, a revision set, |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
350 |
or a literal keyword to search for in changeset data (equivalent to |
24867
6d97ca3f05ba
webcommands: fix typo in changelog documentation
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
24859
diff
changeset
|
351 |
:hg:`log -k`). |
24089
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
352 |
|
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
353 |
The ``revcount`` query string argument defines the maximum numbers of |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
354 |
changesets to render. |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
355 |
|
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
356 |
For non-searches, the ``changelog`` template will be rendered. |
f17773432782
webcommands: document "changelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24088
diff
changeset
|
357 |
""" |
10247
e8c7410371e0
hgweb: add less/more links for search logs (issue1972)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10246
diff
changeset
|
358 |
|
19396
afc23eddc324
hgweb: show current search query in the input field
Alexander Plavin <me@aplavin.ru>
parents:
18968
diff
changeset
|
359 |
query = '' |
5915
d0576d065993
Prefer i in d over d.has_key(i)
Christian Ebert <blacktrash@gmx.net>
parents:
5890
diff
changeset
|
360 |
if 'node' in req.form: |
6392
2540521dc7c1
hgweb: separate out utility functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6368
diff
changeset
|
361 |
ctx = webutil.changectx(web.repo, req) |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
362 |
symrev = webutil.symrevorshortnode(req, ctx) |
19534
983bb4069004
hgweb: cleaner if conditions in changelog() function
Alexander Plavin <alexander@plav.in>
parents:
19533
diff
changeset
|
363 |
elif 'rev' in req.form: |
19634
49a068b8fb0c
hgweb: always run search when a query is entered (bc)
Alexander Plavin <alexander@plav.in>
parents:
19633
diff
changeset
|
364 |
return _search(web, req, tmpl) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
365 |
else: |
19534
983bb4069004
hgweb: cleaner if conditions in changelog() function
Alexander Plavin <alexander@plav.in>
parents:
19533
diff
changeset
|
366 |
ctx = web.repo['tip'] |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
367 |
symrev = 'tip' |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
368 |
|
19737
ab5442f45441
hgweb: always compute all entries and latestentry in changelog
Alexander Plavin <alexander@plav.in>
parents:
19735
diff
changeset
|
369 |
def changelist(): |
18427
56ca4443a343
hgweb: use changelog for iteration
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18409
diff
changeset
|
370 |
revs = [] |
19486
002b711a3e8a
hgweb: fix incorrect way to count revisions in log (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19485
diff
changeset
|
371 |
if pos != -1: |
002b711a3e8a
hgweb: fix incorrect way to count revisions in log (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19485
diff
changeset
|
372 |
revs = web.repo.changelog.revs(pos, 0) |
002b711a3e8a
hgweb: fix incorrect way to count revisions in log (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19485
diff
changeset
|
373 |
curcount = 0 |
23745
513d47905114
hgweb: extract changelist entry generation into own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23740
diff
changeset
|
374 |
for rev in revs: |
19486
002b711a3e8a
hgweb: fix incorrect way to count revisions in log (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19485
diff
changeset
|
375 |
curcount += 1 |
19738
93b8544c4482
hgweb: add nextentry variable for easy pagination in changelog
Alexander Plavin <alexander@plav.in>
parents:
19737
diff
changeset
|
376 |
if curcount > revcount + 1: |
19486
002b711a3e8a
hgweb: fix incorrect way to count revisions in log (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19485
diff
changeset
|
377 |
break |
23745
513d47905114
hgweb: extract changelist entry generation into own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23740
diff
changeset
|
378 |
|
513d47905114
hgweb: extract changelist entry generation into own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23740
diff
changeset
|
379 |
entry = webutil.changelistentry(web, web.repo[rev], tmpl) |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
380 |
entry['parity'] = next(parity) |
23745
513d47905114
hgweb: extract changelist entry generation into own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23740
diff
changeset
|
381 |
yield entry |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
382 |
|
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
383 |
if shortlog: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
384 |
revcount = web.maxshortchanges |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
385 |
else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
386 |
revcount = web.maxchanges |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
387 |
|
10246
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
388 |
if 'revcount' in req.form: |
20092
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
389 |
try: |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
390 |
revcount = int(req.form.get('revcount', [revcount])[0]) |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
391 |
revcount = max(revcount, 1) |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
392 |
tmpl.defaults['sessionvars']['revcount'] = revcount |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
393 |
except ValueError: |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
394 |
pass |
10246
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
395 |
|
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
396 |
lessvars = copy.copy(tmpl.defaults['sessionvars']) |
13931
c3372529247f
hgweb: set minimum number of revision to display to 1 when revcount is 0
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13924
diff
changeset
|
397 |
lessvars['revcount'] = max(revcount / 2, 1) |
10246
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
398 |
morevars = copy.copy(tmpl.defaults['sessionvars']) |
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
399 |
morevars['revcount'] = revcount * 2 |
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
400 |
|
12059
0de6cfdcaad8
webcommands: remove unncessary access to repo.changelog
Patrick Mezard <pmezard@gmail.com>
parents:
11332
diff
changeset
|
401 |
count = len(web.repo) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
402 |
pos = ctx.rev() |
19486
002b711a3e8a
hgweb: fix incorrect way to count revisions in log (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19485
diff
changeset
|
403 |
parity = paritygen(web.stripecount) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
404 |
|
18409
e3f5cef11d6a
hgweb: pass repo object to revnav construction
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18408
diff
changeset
|
405 |
changenav = webutil.revnav(web.repo).gen(pos, revcount, count) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
406 |
|
19737
ab5442f45441
hgweb: always compute all entries and latestentry in changelog
Alexander Plavin <alexander@plav.in>
parents:
19735
diff
changeset
|
407 |
entries = list(changelist()) |
ab5442f45441
hgweb: always compute all entries and latestentry in changelog
Alexander Plavin <alexander@plav.in>
parents:
19735
diff
changeset
|
408 |
latestentry = entries[:1] |
19738
93b8544c4482
hgweb: add nextentry variable for easy pagination in changelog
Alexander Plavin <alexander@plav.in>
parents:
19737
diff
changeset
|
409 |
if len(entries) > revcount: |
93b8544c4482
hgweb: add nextentry variable for easy pagination in changelog
Alexander Plavin <alexander@plav.in>
parents:
19737
diff
changeset
|
410 |
nextentry = entries[-1:] |
93b8544c4482
hgweb: add nextentry variable for easy pagination in changelog
Alexander Plavin <alexander@plav.in>
parents:
19737
diff
changeset
|
411 |
entries = entries[:-1] |
93b8544c4482
hgweb: add nextentry variable for easy pagination in changelog
Alexander Plavin <alexander@plav.in>
parents:
19737
diff
changeset
|
412 |
else: |
93b8544c4482
hgweb: add nextentry variable for easy pagination in changelog
Alexander Plavin <alexander@plav.in>
parents:
19737
diff
changeset
|
413 |
nextentry = [] |
19737
ab5442f45441
hgweb: always compute all entries and latestentry in changelog
Alexander Plavin <alexander@plav.in>
parents:
19735
diff
changeset
|
414 |
|
10246
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
415 |
return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav, |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
416 |
node=ctx.hex(), rev=pos, symrev=symrev, changesets=count, |
19737
ab5442f45441
hgweb: always compute all entries and latestentry in changelog
Alexander Plavin <alexander@plav.in>
parents:
19735
diff
changeset
|
417 |
entries=entries, |
19738
93b8544c4482
hgweb: add nextentry variable for easy pagination in changelog
Alexander Plavin <alexander@plav.in>
parents:
19737
diff
changeset
|
418 |
latestentry=latestentry, nextentry=nextentry, |
10246
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
419 |
archives=web.archivelist("tip"), revcount=revcount, |
19396
afc23eddc324
hgweb: show current search query in the input field
Alexander Plavin <me@aplavin.ru>
parents:
18968
diff
changeset
|
420 |
morevars=morevars, lessvars=lessvars, query=query) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
421 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
422 |
@webcommand('shortlog') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
423 |
def shortlog(web, req, tmpl): |
24086
2d8e93554822
webcommands: document "shortlog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24085
diff
changeset
|
424 |
""" |
2d8e93554822
webcommands: document "shortlog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24085
diff
changeset
|
425 |
/shortlog |
2d8e93554822
webcommands: document "shortlog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24085
diff
changeset
|
426 |
--------- |
2d8e93554822
webcommands: document "shortlog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24085
diff
changeset
|
427 |
|
2d8e93554822
webcommands: document "shortlog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24085
diff
changeset
|
428 |
Show basic information about a set of changesets. |
2d8e93554822
webcommands: document "shortlog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24085
diff
changeset
|
429 |
|
2d8e93554822
webcommands: document "shortlog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24085
diff
changeset
|
430 |
This accepts the same parameters as the ``changelog`` handler. The only |
2d8e93554822
webcommands: document "shortlog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24085
diff
changeset
|
431 |
difference is the ``shortlog`` template will be rendered instead of the |
2d8e93554822
webcommands: document "shortlog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24085
diff
changeset
|
432 |
``changelog`` template. |
2d8e93554822
webcommands: document "shortlog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24085
diff
changeset
|
433 |
""" |
19872
681f7b9213a4
check-code: check for spaces around = for named parameters
Mads Kiilerich <madski@unity3d.com>
parents:
19768
diff
changeset
|
434 |
return changelog(web, req, tmpl, shortlog=True) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
435 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
436 |
@webcommand('changeset') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
437 |
def changeset(web, req, tmpl): |
24085
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
438 |
""" |
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
439 |
/changeset[/{revision}] |
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
440 |
----------------------- |
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
441 |
|
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
442 |
Show information about a single changeset. |
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
443 |
|
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
444 |
A URL path argument is the changeset identifier to show. See ``hg help |
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
445 |
revisions`` for possible values. If not defined, the ``tip`` changeset |
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
446 |
will be shown. |
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
447 |
|
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
448 |
The ``changeset`` template is rendered. Contents of the ``changesettag``, |
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
449 |
``changesetbookmark``, ``filenodelink``, ``filenolink``, and the many |
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
450 |
templates related to diffs may all be used to produce the output. |
0bf61eae67ab
webcommands: document "changeset" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24084
diff
changeset
|
451 |
""" |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
452 |
ctx = webutil.changectx(web.repo, req) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
453 |
|
24177
f53b7174facf
hgweb: extract changeset template mapping generation to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24114
diff
changeset
|
454 |
return tmpl('changeset', **webutil.changesetentry(web, req, tmpl, ctx)) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
455 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
456 |
rev = webcommand('rev')(changeset) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
457 |
|
16448
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
458 |
def decodepath(path): |
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
459 |
"""Hook for mapping a path in the repository to a path in the |
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
460 |
working copy. |
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
461 |
|
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
462 |
Extensions (e.g., largefiles) can override this to remap files in |
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
463 |
the virtual file system presented by the manifest command below.""" |
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
464 |
return path |
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
465 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
466 |
@webcommand('manifest') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
467 |
def manifest(web, req, tmpl): |
24090
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
468 |
""" |
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
469 |
/manifest[/{revision}[/{path}]] |
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
470 |
------------------------------- |
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
471 |
|
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
472 |
Show information about a directory. |
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
473 |
|
24868
9668c653eb9d
webcommands: fix description of manifest default behavior
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
24867
diff
changeset
|
474 |
If the URL path arguments are omitted, information about the root |
24090
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
475 |
directory for the ``tip`` changeset will be shown. |
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
476 |
|
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
477 |
Because this handler can only show information for directories, it |
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
478 |
is recommended to use the ``file`` handler instead, as it can handle both |
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
479 |
directories and files. |
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
480 |
|
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
481 |
The ``manifest`` template will be rendered for this handler. |
a86b2922ea30
webcommands: document "manifest" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24089
diff
changeset
|
482 |
""" |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
483 |
if 'node' in req.form: |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
484 |
ctx = webutil.changectx(web.repo, req) |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
485 |
symrev = webutil.symrevorshortnode(req, ctx) |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
486 |
else: |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
487 |
ctx = web.repo['tip'] |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
488 |
symrev = 'tip' |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
489 |
path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
490 |
mf = ctx.manifest() |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
491 |
node = ctx.node() |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
492 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
493 |
files = {} |
7305
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
494 |
dirs = {} |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
495 |
parity = paritygen(web.stripecount) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
496 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
497 |
if path and path[-1] != "/": |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
498 |
path += "/" |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
499 |
l = len(path) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
500 |
abspath = "/" + path |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
501 |
|
16448
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
502 |
for full, n in mf.iteritems(): |
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
503 |
# the virtual path (working copy path) used for the full |
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
504 |
# (repository) path |
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
505 |
f = decodepath(full) |
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
506 |
|
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
507 |
if f[:l] != path: |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
508 |
continue |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
509 |
remain = f[l:] |
7305
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
510 |
elements = remain.split('/') |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
511 |
if len(elements) == 1: |
16448
e6b45e9a75dc
hgweb: add hook for remapping repository path into virtual paths
Martin Geisler <mg@lazybytes.net>
parents:
16308
diff
changeset
|
512 |
files[remain] = full |
7305
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
513 |
else: |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
514 |
h = dirs # need to retain ref to dirs (root) |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
515 |
for elem in elements[0:-1]: |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
516 |
if elem not in h: |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
517 |
h[elem] = {} |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
518 |
h = h[elem] |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
519 |
if len(h) > 1: |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
520 |
break |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
521 |
h[None] = None # denotes files present |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
522 |
|
7565
5f162f61e479
hgweb: fix problems with empty repositories
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7434
diff
changeset
|
523 |
if mf and not files and not dirs: |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
524 |
raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
525 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
526 |
def filelist(**map): |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
7966
diff
changeset
|
527 |
for f in sorted(files): |
7305
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
528 |
full = files[f] |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
529 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
530 |
fctx = ctx.filectx(full) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
531 |
yield {"file": full, |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
532 |
"parity": next(parity), |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
533 |
"basename": f, |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6720
diff
changeset
|
534 |
"date": fctx.date(), |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
535 |
"size": fctx.size(), |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
536 |
"permissions": mf.flags(full)} |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
537 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
538 |
def dirlist(**map): |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
7966
diff
changeset
|
539 |
for d in sorted(dirs): |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
540 |
|
7305
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
541 |
emptydirs = [] |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
542 |
h = dirs[d] |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
543 |
while isinstance(h, dict) and len(h) == 1: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
544 |
k, v = h.items()[0] |
7305
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
545 |
if v: |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
546 |
emptydirs.append(k) |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
547 |
h = v |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
548 |
|
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
549 |
path = "%s%s" % (abspath, d) |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
550 |
yield {"parity": next(parity), |
7305
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
551 |
"path": path, |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
552 |
"emptydirs": "/".join(emptydirs), |
c21d236ca897
hgweb: descend empty directories in web view
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
7300
diff
changeset
|
553 |
"basename": d} |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
554 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
555 |
return tmpl("manifest", |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
556 |
symrev=symrev, |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
557 |
path=abspath, |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
558 |
up=webutil.up(abspath), |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
559 |
upparity=next(parity), |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
560 |
fentries=filelist, |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
561 |
dentries=dirlist, |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
562 |
archives=web.archivelist(hex(node)), |
27294
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
563 |
**webutil.commonentry(web.repo, ctx)) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
564 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
565 |
@webcommand('tags') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
566 |
def tags(web, req, tmpl): |
24084
ef06e2b1a3d1
webcommands: document "tags" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24083
diff
changeset
|
567 |
""" |
ef06e2b1a3d1
webcommands: document "tags" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24083
diff
changeset
|
568 |
/tags |
ef06e2b1a3d1
webcommands: document "tags" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24083
diff
changeset
|
569 |
----- |
ef06e2b1a3d1
webcommands: document "tags" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24083
diff
changeset
|
570 |
|
ef06e2b1a3d1
webcommands: document "tags" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24083
diff
changeset
|
571 |
Show information about tags. |
ef06e2b1a3d1
webcommands: document "tags" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24083
diff
changeset
|
572 |
|
ef06e2b1a3d1
webcommands: document "tags" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24083
diff
changeset
|
573 |
No arguments are accepted. |
ef06e2b1a3d1
webcommands: document "tags" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24083
diff
changeset
|
574 |
|
ef06e2b1a3d1
webcommands: document "tags" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24083
diff
changeset
|
575 |
The ``tags`` template is rendered. |
ef06e2b1a3d1
webcommands: document "tags" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24083
diff
changeset
|
576 |
""" |
18029
109a6a9dcca8
hgweb: fix iterator reuse in atom feed generation
Matt Mackall <mpm@selenic.com>
parents:
17322
diff
changeset
|
577 |
i = list(reversed(web.repo.tagslist())) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
578 |
parity = paritygen(web.stripecount) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
579 |
|
18402
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
580 |
def entries(notip, latestonly, **map): |
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
581 |
t = i |
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
582 |
if notip: |
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
583 |
t = [(k, n) for k, n in i if k != "tip"] |
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
584 |
if latestonly: |
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
585 |
t = t[:1] |
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
586 |
for k, n in t: |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
587 |
yield {"parity": next(parity), |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
588 |
"tag": k, |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6720
diff
changeset
|
589 |
"date": web.repo[n].date(), |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
590 |
"node": hex(n)} |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
591 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
592 |
return tmpl("tags", |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
593 |
node=hex(web.repo.changelog.tip()), |
18402
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
594 |
entries=lambda **x: entries(False, False, **x), |
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
595 |
entriesnotip=lambda **x: entries(True, False, **x), |
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
596 |
latestentry=lambda **x: entries(True, True, **x)) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
597 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
598 |
@webcommand('bookmarks') |
13597
38c9837b1f75
hgweb: add separate page with bookmarks listing
Alexander Solovyov <alexander@solovyov.net>
parents:
13596
diff
changeset
|
599 |
def bookmarks(web, req, tmpl): |
24083
5fbb5217a6c8
webcommands: document "bookmarks" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24082
diff
changeset
|
600 |
""" |
5fbb5217a6c8
webcommands: document "bookmarks" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24082
diff
changeset
|
601 |
/bookmarks |
5fbb5217a6c8
webcommands: document "bookmarks" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24082
diff
changeset
|
602 |
---------- |
5fbb5217a6c8
webcommands: document "bookmarks" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24082
diff
changeset
|
603 |
|
5fbb5217a6c8
webcommands: document "bookmarks" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24082
diff
changeset
|
604 |
Show information about bookmarks. |
5fbb5217a6c8
webcommands: document "bookmarks" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24082
diff
changeset
|
605 |
|
5fbb5217a6c8
webcommands: document "bookmarks" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24082
diff
changeset
|
606 |
No arguments are accepted. |
5fbb5217a6c8
webcommands: document "bookmarks" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24082
diff
changeset
|
607 |
|
5fbb5217a6c8
webcommands: document "bookmarks" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24082
diff
changeset
|
608 |
The ``bookmarks`` template is rendered. |
5fbb5217a6c8
webcommands: document "bookmarks" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24082
diff
changeset
|
609 |
""" |
18478
886936ecc21b
hgweb: don't attempt to show hidden bookmarks (issue3774)
Kevin Bullock <kbullock@ringworld.org>
parents:
18477
diff
changeset
|
610 |
i = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] |
28711
06ae7a6daad0
hgweb: sort bookmarks in revlog order of their nodes
Anton Shestakov <av6@dwimlabs.net>
parents:
28710
diff
changeset
|
611 |
sortkey = lambda b: (web.repo[b[1]].rev(), b[0]) |
06ae7a6daad0
hgweb: sort bookmarks in revlog order of their nodes
Anton Shestakov <av6@dwimlabs.net>
parents:
28710
diff
changeset
|
612 |
i = sorted(i, key=sortkey, reverse=True) |
13597
38c9837b1f75
hgweb: add separate page with bookmarks listing
Alexander Solovyov <alexander@solovyov.net>
parents:
13596
diff
changeset
|
613 |
parity = paritygen(web.stripecount) |
38c9837b1f75
hgweb: add separate page with bookmarks listing
Alexander Solovyov <alexander@solovyov.net>
parents:
13596
diff
changeset
|
614 |
|
18402
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
615 |
def entries(latestonly, **map): |
28710
ca0c0ca30c62
hgweb: sort bookmarks early
Anton Shestakov <av6@dwimlabs.net>
parents:
28212
diff
changeset
|
616 |
t = i |
18402
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
617 |
if latestonly: |
28710
ca0c0ca30c62
hgweb: sort bookmarks early
Anton Shestakov <av6@dwimlabs.net>
parents:
28212
diff
changeset
|
618 |
t = i[:1] |
18402
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
619 |
for k, n in t: |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
620 |
yield {"parity": next(parity), |
13597
38c9837b1f75
hgweb: add separate page with bookmarks listing
Alexander Solovyov <alexander@solovyov.net>
parents:
13596
diff
changeset
|
621 |
"bookmark": k, |
38c9837b1f75
hgweb: add separate page with bookmarks listing
Alexander Solovyov <alexander@solovyov.net>
parents:
13596
diff
changeset
|
622 |
"date": web.repo[n].date(), |
38c9837b1f75
hgweb: add separate page with bookmarks listing
Alexander Solovyov <alexander@solovyov.net>
parents:
13596
diff
changeset
|
623 |
"node": hex(n)} |
38c9837b1f75
hgweb: add separate page with bookmarks listing
Alexander Solovyov <alexander@solovyov.net>
parents:
13596
diff
changeset
|
624 |
|
28712
80e922479891
hgweb: generate last change date for an empty atom-bookmarks feed (issue5022)
Anton Shestakov <av6@dwimlabs.net>
parents:
28711
diff
changeset
|
625 |
if i: |
80e922479891
hgweb: generate last change date for an empty atom-bookmarks feed (issue5022)
Anton Shestakov <av6@dwimlabs.net>
parents:
28711
diff
changeset
|
626 |
latestrev = i[0][1] |
80e922479891
hgweb: generate last change date for an empty atom-bookmarks feed (issue5022)
Anton Shestakov <av6@dwimlabs.net>
parents:
28711
diff
changeset
|
627 |
else: |
80e922479891
hgweb: generate last change date for an empty atom-bookmarks feed (issue5022)
Anton Shestakov <av6@dwimlabs.net>
parents:
28711
diff
changeset
|
628 |
latestrev = -1 |
80e922479891
hgweb: generate last change date for an empty atom-bookmarks feed (issue5022)
Anton Shestakov <av6@dwimlabs.net>
parents:
28711
diff
changeset
|
629 |
|
13597
38c9837b1f75
hgweb: add separate page with bookmarks listing
Alexander Solovyov <alexander@solovyov.net>
parents:
13596
diff
changeset
|
630 |
return tmpl("bookmarks", |
38c9837b1f75
hgweb: add separate page with bookmarks listing
Alexander Solovyov <alexander@solovyov.net>
parents:
13596
diff
changeset
|
631 |
node=hex(web.repo.changelog.tip()), |
28712
80e922479891
hgweb: generate last change date for an empty atom-bookmarks feed (issue5022)
Anton Shestakov <av6@dwimlabs.net>
parents:
28711
diff
changeset
|
632 |
lastchange=[{"date": web.repo[latestrev].date()}], |
18402
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
633 |
entries=lambda **x: entries(latestonly=False, **x), |
bfba6d954108
hgweb: `limit` argument is actually `latestonly` renames and enforce
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18352
diff
changeset
|
634 |
latestentry=lambda **x: entries(latestonly=True, **x)) |
13597
38c9837b1f75
hgweb: add separate page with bookmarks listing
Alexander Solovyov <alexander@solovyov.net>
parents:
13596
diff
changeset
|
635 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
636 |
@webcommand('branches') |
8352
eefcb59d44d6
webcommands: add 'branches' command, similar to 'tags'
Sune Foldager <cryo@cyanite.org>
parents:
8236
diff
changeset
|
637 |
def branches(web, req, tmpl): |
24082
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
638 |
""" |
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
639 |
/branches |
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
640 |
--------- |
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
641 |
|
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
642 |
Show information about branches. |
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
643 |
|
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
644 |
All known branches are contained in the output, even closed branches. |
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
645 |
|
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
646 |
No arguments are accepted. |
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
647 |
|
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
648 |
The ``branches`` template is rendered. |
32dabf811b39
webcommands: document "branches" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24081
diff
changeset
|
649 |
""" |
26129
a103ecb8a04a
hgweb: move branchentries code from webcommands to webutil
Anton Shestakov <av6@dwimlabs.net>
parents:
25660
diff
changeset
|
650 |
entries = webutil.branchentries(web.repo, web.stripecount) |
a103ecb8a04a
hgweb: move branchentries code from webcommands to webutil
Anton Shestakov <av6@dwimlabs.net>
parents:
25660
diff
changeset
|
651 |
latestentry = webutil.branchentries(web.repo, web.stripecount, 1) |
8352
eefcb59d44d6
webcommands: add 'branches' command, similar to 'tags'
Sune Foldager <cryo@cyanite.org>
parents:
8236
diff
changeset
|
652 |
return tmpl('branches', node=hex(web.repo.changelog.tip()), |
26129
a103ecb8a04a
hgweb: move branchentries code from webcommands to webutil
Anton Shestakov <av6@dwimlabs.net>
parents:
25660
diff
changeset
|
653 |
entries=entries, latestentry=latestentry) |
8352
eefcb59d44d6
webcommands: add 'branches' command, similar to 'tags'
Sune Foldager <cryo@cyanite.org>
parents:
8236
diff
changeset
|
654 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
655 |
@webcommand('summary') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
656 |
def summary(web, req, tmpl): |
24091
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
657 |
""" |
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
658 |
/summary |
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
659 |
-------- |
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
660 |
|
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
661 |
Show a summary of repository state. |
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
662 |
|
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
663 |
Information about the latest changesets, bookmarks, tags, and branches |
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
664 |
is captured by this handler. |
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
665 |
|
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
666 |
The ``summary`` template is rendered. |
6b6ec887c79b
webcommands: document "summary" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24090
diff
changeset
|
667 |
""" |
17261
c0068b058fcd
webcommands: do not modify repo.tagslist()
Patrick Mezard <patrick@mezard.eu>
parents:
17202
diff
changeset
|
668 |
i = reversed(web.repo.tagslist()) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
669 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
670 |
def tagentries(**map): |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
671 |
parity = paritygen(web.stripecount) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
672 |
count = 0 |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
673 |
for k, n in i: |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
674 |
if k == "tip": # skip tip |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
675 |
continue |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
676 |
|
6659
bc553c6d1ef9
webcommands: fix increments lost by 894875eae49b
Andrew Beekhof <beekhof@gmail.com>
parents:
6657
diff
changeset
|
677 |
count += 1 |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
678 |
if count > 10: # limit to 10 tags |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
679 |
break |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
680 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
681 |
yield tmpl("tagentry", |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
682 |
parity=next(parity), |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
683 |
tag=k, |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
684 |
node=hex(n), |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6720
diff
changeset
|
685 |
date=web.repo[n].date()) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
686 |
|
13924
ea726c97c1b6
hgweb: add bookmarks listing to summary page of gitweb/monoblue styles
Yuya Nishihara <yuya@tcha.org>
parents:
13923
diff
changeset
|
687 |
def bookmarks(**map): |
ea726c97c1b6
hgweb: add bookmarks listing to summary page of gitweb/monoblue styles
Yuya Nishihara <yuya@tcha.org>
parents:
13923
diff
changeset
|
688 |
parity = paritygen(web.stripecount) |
18563
6d098adc5a46
hgweb: make 'summary' work with hidden changesets (issue3810)
Kevin Bullock <kbullock@ringworld.org>
parents:
18524
diff
changeset
|
689 |
marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] |
28711
06ae7a6daad0
hgweb: sort bookmarks in revlog order of their nodes
Anton Shestakov <av6@dwimlabs.net>
parents:
28710
diff
changeset
|
690 |
sortkey = lambda b: (web.repo[b[1]].rev(), b[0]) |
06ae7a6daad0
hgweb: sort bookmarks in revlog order of their nodes
Anton Shestakov <av6@dwimlabs.net>
parents:
28710
diff
changeset
|
691 |
marks = sorted(marks, key=sortkey, reverse=True) |
06ae7a6daad0
hgweb: sort bookmarks in revlog order of their nodes
Anton Shestakov <av6@dwimlabs.net>
parents:
28710
diff
changeset
|
692 |
for k, n in marks[:10]: # limit to 10 bookmarks |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
693 |
yield {'parity': next(parity), |
13924
ea726c97c1b6
hgweb: add bookmarks listing to summary page of gitweb/monoblue styles
Yuya Nishihara <yuya@tcha.org>
parents:
13923
diff
changeset
|
694 |
'bookmark': k, |
ea726c97c1b6
hgweb: add bookmarks listing to summary page of gitweb/monoblue styles
Yuya Nishihara <yuya@tcha.org>
parents:
13923
diff
changeset
|
695 |
'date': web.repo[n].date(), |
ea726c97c1b6
hgweb: add bookmarks listing to summary page of gitweb/monoblue styles
Yuya Nishihara <yuya@tcha.org>
parents:
13923
diff
changeset
|
696 |
'node': hex(n)} |
ea726c97c1b6
hgweb: add bookmarks listing to summary page of gitweb/monoblue styles
Yuya Nishihara <yuya@tcha.org>
parents:
13923
diff
changeset
|
697 |
|
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
698 |
def changelist(**map): |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
699 |
parity = paritygen(web.stripecount, offset=start - end) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
700 |
l = [] # build a list in forward order for efficiency |
18563
6d098adc5a46
hgweb: make 'summary' work with hidden changesets (issue3810)
Kevin Bullock <kbullock@ringworld.org>
parents:
18524
diff
changeset
|
701 |
revs = [] |
6d098adc5a46
hgweb: make 'summary' work with hidden changesets (issue3810)
Kevin Bullock <kbullock@ringworld.org>
parents:
18524
diff
changeset
|
702 |
if start < end: |
6d098adc5a46
hgweb: make 'summary' work with hidden changesets (issue3810)
Kevin Bullock <kbullock@ringworld.org>
parents:
18524
diff
changeset
|
703 |
revs = web.repo.changelog.revs(start, end - 1) |
6d098adc5a46
hgweb: make 'summary' work with hidden changesets (issue3810)
Kevin Bullock <kbullock@ringworld.org>
parents:
18524
diff
changeset
|
704 |
for i in revs: |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6720
diff
changeset
|
705 |
ctx = web.repo[i] |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
706 |
|
18319
e350ce798b63
hgweb: no do not use listinsert(0, ...)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18037
diff
changeset
|
707 |
l.append(tmpl( |
27294
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
708 |
'shortlogentry', |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
709 |
parity=next(parity), |
27294
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
710 |
**webutil.commonentry(web.repo, ctx))) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
711 |
|
29382
e4b777fe1576
templates: add support for summary webcommand in json style
Laura Médioni <laura.medioni@logilab.fr>
parents:
29325
diff
changeset
|
712 |
for entry in reversed(l): |
e4b777fe1576
templates: add support for summary webcommand in json style
Laura Médioni <laura.medioni@logilab.fr>
parents:
29325
diff
changeset
|
713 |
yield entry |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
714 |
|
12059
0de6cfdcaad8
webcommands: remove unncessary access to repo.changelog
Patrick Mezard <pmezard@gmail.com>
parents:
11332
diff
changeset
|
715 |
tip = web.repo['tip'] |
0de6cfdcaad8
webcommands: remove unncessary access to repo.changelog
Patrick Mezard <pmezard@gmail.com>
parents:
11332
diff
changeset
|
716 |
count = len(web.repo) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
717 |
start = max(0, count - web.maxchanges) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
718 |
end = min(count, start + web.maxchanges) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
719 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
720 |
return tmpl("summary", |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
721 |
desc=web.config("web", "description", "unknown"), |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
722 |
owner=get_contact(web.config) or "unknown", |
12059
0de6cfdcaad8
webcommands: remove unncessary access to repo.changelog
Patrick Mezard <pmezard@gmail.com>
parents:
11332
diff
changeset
|
723 |
lastchange=tip.date(), |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
724 |
tags=tagentries, |
13924
ea726c97c1b6
hgweb: add bookmarks listing to summary page of gitweb/monoblue styles
Yuya Nishihara <yuya@tcha.org>
parents:
13923
diff
changeset
|
725 |
bookmarks=bookmarks, |
26131
0a9009d56fea
hgweb: limit branches shown on summary page to 10
Anton Shestakov <av6@dwimlabs.net>
parents:
26130
diff
changeset
|
726 |
branches=webutil.branchentries(web.repo, web.stripecount, 10), |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
727 |
shortlog=changelist, |
12059
0de6cfdcaad8
webcommands: remove unncessary access to repo.changelog
Patrick Mezard <pmezard@gmail.com>
parents:
11332
diff
changeset
|
728 |
node=tip.hex(), |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
729 |
symrev='tip', |
29471
c4fc33c477da
hgweb: expose list of per-repo labels to templates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29388
diff
changeset
|
730 |
archives=web.archivelist("tip"), |
c4fc33c477da
hgweb: expose list of per-repo labels to templates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29388
diff
changeset
|
731 |
labels=web.configlist('web', 'labels')) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
732 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
733 |
@webcommand('filediff') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
734 |
def filediff(web, req, tmpl): |
24092
55dfea651b7f
webcommands: document "filediff" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24091
diff
changeset
|
735 |
""" |
55dfea651b7f
webcommands: document "filediff" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24091
diff
changeset
|
736 |
/diff/{revision}/{path} |
55dfea651b7f
webcommands: document "filediff" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24091
diff
changeset
|
737 |
----------------------- |
55dfea651b7f
webcommands: document "filediff" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24091
diff
changeset
|
738 |
|
55dfea651b7f
webcommands: document "filediff" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24091
diff
changeset
|
739 |
Show how a file changed in a particular commit. |
55dfea651b7f
webcommands: document "filediff" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24091
diff
changeset
|
740 |
|
55dfea651b7f
webcommands: document "filediff" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24091
diff
changeset
|
741 |
The ``filediff`` template is rendered. |
55dfea651b7f
webcommands: document "filediff" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24091
diff
changeset
|
742 |
|
26781
1aee2ab0f902
spelling: trivial spell checking
Mads Kiilerich <madski@unity3d.com>
parents:
26136
diff
changeset
|
743 |
This handler is registered under both the ``/diff`` and ``/filediff`` |
24092
55dfea651b7f
webcommands: document "filediff" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24091
diff
changeset
|
744 |
paths. ``/diff`` is used in modern code. |
55dfea651b7f
webcommands: document "filediff" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24091
diff
changeset
|
745 |
""" |
7183
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
746 |
fctx, ctx = None, None |
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
747 |
try: |
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
748 |
fctx = webutil.filectx(web.repo, req) |
7280
810ca383da9c
remove unused variables
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7183
diff
changeset
|
749 |
except LookupError: |
7183
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
750 |
ctx = webutil.changectx(web.repo, req) |
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
751 |
path = webutil.cleanpath(web.repo, req.form['file'][0]) |
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
752 |
if path not in ctx.files(): |
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
753 |
raise |
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
754 |
|
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
755 |
if fctx is not None: |
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
756 |
path = fctx.path() |
16722
7bf48bc7de23
hgweb: fix filediff base calculation
Matt Mackall <mpm@selenic.com>
parents:
16469
diff
changeset
|
757 |
ctx = fctx.changectx() |
31082
abb92b3d370e
hgweb: explictly pass basectx in webutil.diffs
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31024
diff
changeset
|
758 |
basectx = ctx.p1() |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
759 |
|
9402
5d49fdef6fd0
hgweb: show diff header line in raw diffs
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8842
diff
changeset
|
760 |
style = web.config('web', 'style', 'paper') |
5d49fdef6fd0
hgweb: show diff header line in raw diffs
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8842
diff
changeset
|
761 |
if 'style' in req.form: |
5d49fdef6fd0
hgweb: show diff header line in raw diffs
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8842
diff
changeset
|
762 |
style = req.form['style'][0] |
5d49fdef6fd0
hgweb: show diff header line in raw diffs
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8842
diff
changeset
|
763 |
|
31660
c2dbd818e884
hgweb: handle "parity" internally in webutil.diffs()
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31082
diff
changeset
|
764 |
diffs = webutil.diffs(web, tmpl, ctx, basectx, [path], style) |
27160
c533435cbc37
webcommands: test that fctx is not None in filediff()
Anton Shestakov <av6@dwimlabs.net>
parents:
27159
diff
changeset
|
765 |
if fctx is not None: |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
766 |
rename = webutil.renamelink(fctx) |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
767 |
ctx = fctx |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
768 |
else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
769 |
rename = [] |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24177
diff
changeset
|
770 |
ctx = ctx |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
771 |
return tmpl("filediff", |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
772 |
file=path, |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
773 |
symrev=webutil.symrevorshortnode(req, ctx), |
7183
099b4f9be5ab
hgweb: working diff for removed files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7182
diff
changeset
|
774 |
rename=rename, |
27294
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
775 |
diff=diffs, |
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
776 |
**webutil.commonentry(web.repo, ctx)) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
777 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
778 |
diff = webcommand('diff')(filediff) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
779 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
780 |
@webcommand('comparison') |
17202
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
781 |
def comparison(web, req, tmpl): |
24093
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
782 |
""" |
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
783 |
/comparison/{revision}/{path} |
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
784 |
----------------------------- |
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
785 |
|
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
786 |
Show a comparison between the old and new versions of a file from changes |
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
787 |
made on a particular revision. |
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
788 |
|
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
789 |
This is similar to the ``diff`` handler. However, this form features |
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
790 |
a split or side-by-side diff rather than a unified diff. |
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
791 |
|
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
792 |
The ``context`` query string argument can be used to control the lines of |
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
793 |
context in the diff. |
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
794 |
|
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
795 |
The ``filecomparison`` template is rendered. |
c8639f90a715
webcommands: document "comparison" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24092
diff
changeset
|
796 |
""" |
17202
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
797 |
ctx = webutil.changectx(web.repo, req) |
17289
f2d6b4f8e78c
hgweb: avoid traceback when file or node parameters are missing
Ross Lagerwall <rosslagerwall@gmail.com>
parents:
17261
diff
changeset
|
798 |
if 'file' not in req.form: |
f2d6b4f8e78c
hgweb: avoid traceback when file or node parameters are missing
Ross Lagerwall <rosslagerwall@gmail.com>
parents:
17261
diff
changeset
|
799 |
raise ErrorResponse(HTTP_NOT_FOUND, 'file not given') |
17202
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
800 |
path = webutil.cleanpath(web.repo, req.form['file'][0]) |
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
801 |
|
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
802 |
parsecontext = lambda v: v == 'full' and -1 or int(v) |
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
803 |
if 'context' in req.form: |
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
804 |
context = parsecontext(req.form['context'][0]) |
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
805 |
else: |
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
806 |
context = parsecontext(web.config('web', 'comparisoncontext', '5')) |
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
807 |
|
17302
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
808 |
def filelines(f): |
19657
145636d31bb4
hgweb: import the whole util module in webcommands instead of just one function
Alexander Plavin <alexander@plav.in>
parents:
19656
diff
changeset
|
809 |
if util.binary(f.data()): |
17302
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
810 |
mt = mimetypes.guess_type(f.path())[0] |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
811 |
if not mt: |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
812 |
mt = 'application/octet-stream' |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
813 |
return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))] |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
814 |
return f.data().splitlines() |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
815 |
|
27158
522ffc189671
webcommands: get correct parents when comparing a removed file (issue4962)
Anton Shestakov <av6@dwimlabs.net>
parents:
27081
diff
changeset
|
816 |
fctx = None |
21123
92fab48dfec1
hgweb: show revisions and hashes gotten from changelog in "comparison" page
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21121
diff
changeset
|
817 |
parent = ctx.p1() |
92fab48dfec1
hgweb: show revisions and hashes gotten from changelog in "comparison" page
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21121
diff
changeset
|
818 |
leftrev = parent.rev() |
92fab48dfec1
hgweb: show revisions and hashes gotten from changelog in "comparison" page
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21121
diff
changeset
|
819 |
leftnode = parent.node() |
92fab48dfec1
hgweb: show revisions and hashes gotten from changelog in "comparison" page
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21121
diff
changeset
|
820 |
rightrev = ctx.rev() |
92fab48dfec1
hgweb: show revisions and hashes gotten from changelog in "comparison" page
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21121
diff
changeset
|
821 |
rightnode = ctx.node() |
17302
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
822 |
if path in ctx: |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
823 |
fctx = ctx[path] |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
824 |
rightlines = filelines(fctx) |
21121
8c9e84b44221
hgweb: make "comparison" get parent from not filelog but changelog
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20761
diff
changeset
|
825 |
if path not in parent: |
17302
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
826 |
leftlines = () |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
827 |
else: |
21121
8c9e84b44221
hgweb: make "comparison" get parent from not filelog but changelog
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20761
diff
changeset
|
828 |
pfctx = parent[path] |
17302
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
829 |
leftlines = filelines(pfctx) |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
830 |
else: |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
831 |
rightlines = () |
27158
522ffc189671
webcommands: get correct parents when comparing a removed file (issue4962)
Anton Shestakov <av6@dwimlabs.net>
parents:
27081
diff
changeset
|
832 |
pfctx = ctx.parents()[0][path] |
522ffc189671
webcommands: get correct parents when comparing a removed file (issue4962)
Anton Shestakov <av6@dwimlabs.net>
parents:
27081
diff
changeset
|
833 |
leftlines = filelines(pfctx) |
17302
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
834 |
|
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
835 |
comparison = webutil.compare(tmpl, context, leftlines, rightlines) |
27158
522ffc189671
webcommands: get correct parents when comparing a removed file (issue4962)
Anton Shestakov <av6@dwimlabs.net>
parents:
27081
diff
changeset
|
836 |
if fctx is not None: |
27159
7e10b860c174
webcommands: stop using ersatz if-else ternary operator for rename variable
Anton Shestakov <av6@dwimlabs.net>
parents:
27158
diff
changeset
|
837 |
rename = webutil.renamelink(fctx) |
27158
522ffc189671
webcommands: get correct parents when comparing a removed file (issue4962)
Anton Shestakov <av6@dwimlabs.net>
parents:
27081
diff
changeset
|
838 |
ctx = fctx |
522ffc189671
webcommands: get correct parents when comparing a removed file (issue4962)
Anton Shestakov <av6@dwimlabs.net>
parents:
27081
diff
changeset
|
839 |
else: |
27159
7e10b860c174
webcommands: stop using ersatz if-else ternary operator for rename variable
Anton Shestakov <av6@dwimlabs.net>
parents:
27158
diff
changeset
|
840 |
rename = [] |
27158
522ffc189671
webcommands: get correct parents when comparing a removed file (issue4962)
Anton Shestakov <av6@dwimlabs.net>
parents:
27081
diff
changeset
|
841 |
ctx = ctx |
17202
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
842 |
return tmpl('filecomparison', |
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
843 |
file=path, |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
844 |
symrev=webutil.symrevorshortnode(req, ctx), |
17202
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
845 |
rename=rename, |
17302
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
846 |
leftrev=leftrev, |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
847 |
leftnode=hex(leftnode), |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
848 |
rightrev=rightrev, |
5c64ce6168da
hgweb: fixes traceback for invalid files by removing top-level template
wujek srujek <wujek.srujek@googlemail.com>
parents:
17289
diff
changeset
|
849 |
rightnode=hex(rightnode), |
27294
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
850 |
comparison=comparison, |
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
851 |
**webutil.commonentry(web.repo, ctx)) |
17202
1ae119269ddc
hgweb: side-by-side comparison functionality
wujek srujek
parents:
17146
diff
changeset
|
852 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
853 |
@webcommand('annotate') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
854 |
def annotate(web, req, tmpl): |
24094
9c810d46a093
webcommands: document "annotate" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24093
diff
changeset
|
855 |
""" |
9c810d46a093
webcommands: document "annotate" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24093
diff
changeset
|
856 |
/annotate/{revision}/{path} |
9c810d46a093
webcommands: document "annotate" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24093
diff
changeset
|
857 |
--------------------------- |
9c810d46a093
webcommands: document "annotate" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24093
diff
changeset
|
858 |
|
9c810d46a093
webcommands: document "annotate" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24093
diff
changeset
|
859 |
Show changeset information for each line in a file. |
9c810d46a093
webcommands: document "annotate" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24093
diff
changeset
|
860 |
|
9c810d46a093
webcommands: document "annotate" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24093
diff
changeset
|
861 |
The ``fileannotate`` template is rendered. |
9c810d46a093
webcommands: document "annotate" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24093
diff
changeset
|
862 |
""" |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
863 |
fctx = webutil.filectx(web.repo, req) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
864 |
f = fctx.path() |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
865 |
parity = paritygen(web.stripecount) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
866 |
|
30298
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
867 |
# parents() is called once per line and several lines likely belong to |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
868 |
# same revision. So it is worth caching. |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
869 |
# TODO there are still redundant operations within basefilectx.parents() |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
870 |
# and from the fctx.annotate() call itself that could be cached. |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
871 |
parentscache = {} |
29522
9c37df347485
hgweb: add link to parents of annotated revision in annotate view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
29471
diff
changeset
|
872 |
def parents(f): |
30298
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
873 |
rev = f.rev() |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
874 |
if rev not in parentscache: |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
875 |
parentscache[rev] = [] |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
876 |
for p in f.parents(): |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
877 |
entry = { |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
878 |
'node': p.hex(), |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
879 |
'rev': p.rev(), |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
880 |
} |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
881 |
parentscache[rev].append(entry) |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
882 |
|
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
883 |
for p in parentscache[rev]: |
4ed8bb8a153f
hgweb: cache fctx.parents() in annotate command (issue5414)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30081
diff
changeset
|
884 |
yield p |
29522
9c37df347485
hgweb: add link to parents of annotated revision in annotate view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
29471
diff
changeset
|
885 |
|
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
886 |
def annotate(**map): |
19657
145636d31bb4
hgweb: import the whole util module in webcommands instead of just one function
Alexander Plavin <alexander@plav.in>
parents:
19656
diff
changeset
|
887 |
if util.binary(fctx.data()): |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
888 |
mt = (mimetypes.guess_type(fctx.path())[0] |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
889 |
or 'application/octet-stream') |
29538
df7d8ea90695
hgweb: enumerate lines in loop header, not before
Anton Shestakov <av6@dwimlabs.net>
parents:
29522
diff
changeset
|
890 |
lines = [((fctx.filectx(fctx.filerev()), 1), '(binary:%s)' % mt)] |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
891 |
else: |
30081
dd0ff715a82c
hgweb: make fctx.annotate a separated function so it could be wrapped
Jun Wu <quark@fb.com>
parents:
29572
diff
changeset
|
892 |
lines = webutil.annotate(fctx, web.repo.ui) |
dd0ff715a82c
hgweb: make fctx.annotate a separated function so it could be wrapped
Jun Wu <quark@fb.com>
parents:
29572
diff
changeset
|
893 |
|
29388
f694e20193f2
hgweb: display blamed revision once per block in annotate view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
29382
diff
changeset
|
894 |
previousrev = None |
29572
d86b54d9bb0c
paper: make different blocks of annotated lines have different colors
Anton Shestakov <av6@dwimlabs.net>
parents:
29538
diff
changeset
|
895 |
blockparitygen = paritygen(1) |
29538
df7d8ea90695
hgweb: enumerate lines in loop header, not before
Anton Shestakov <av6@dwimlabs.net>
parents:
29522
diff
changeset
|
896 |
for lineno, ((f, targetline), l) in enumerate(lines): |
29388
f694e20193f2
hgweb: display blamed revision once per block in annotate view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
29382
diff
changeset
|
897 |
rev = f.rev() |
29572
d86b54d9bb0c
paper: make different blocks of annotated lines have different colors
Anton Shestakov <av6@dwimlabs.net>
parents:
29538
diff
changeset
|
898 |
if rev != previousrev: |
d86b54d9bb0c
paper: make different blocks of annotated lines have different colors
Anton Shestakov <av6@dwimlabs.net>
parents:
29538
diff
changeset
|
899 |
blockhead = True |
d86b54d9bb0c
paper: make different blocks of annotated lines have different colors
Anton Shestakov <av6@dwimlabs.net>
parents:
29538
diff
changeset
|
900 |
blockparity = next(blockparitygen) |
d86b54d9bb0c
paper: make different blocks of annotated lines have different colors
Anton Shestakov <av6@dwimlabs.net>
parents:
29538
diff
changeset
|
901 |
else: |
d86b54d9bb0c
paper: make different blocks of annotated lines have different colors
Anton Shestakov <av6@dwimlabs.net>
parents:
29538
diff
changeset
|
902 |
blockhead = None |
29388
f694e20193f2
hgweb: display blamed revision once per block in annotate view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
29382
diff
changeset
|
903 |
previousrev = rev |
29216
ead25aa27a43
py3: convert to next() function
timeless <timeless@mozdev.org>
parents:
28712
diff
changeset
|
904 |
yield {"parity": next(parity), |
14055
421d56a055fd
drop {short,hex}(ctx.node()) calls in favor of ctx methods
Alexander Solovyov <alexander@solovyov.net>
parents:
14043
diff
changeset
|
905 |
"node": f.hex(), |
29388
f694e20193f2
hgweb: display blamed revision once per block in annotate view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
29382
diff
changeset
|
906 |
"rev": rev, |
6564
ccc2481e3954
webcommands: pass full author to annotate, fix templates (issue 1054)
Patrick Mezard <pmezard@gmail.com>
parents:
6437
diff
changeset
|
907 |
"author": f.user(), |
29522
9c37df347485
hgweb: add link to parents of annotated revision in annotate view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
29471
diff
changeset
|
908 |
"parents": parents(f), |
6657
a51093361e1c
hgweb: show cset node and description when hovering over annotate prefix
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6564
diff
changeset
|
909 |
"desc": f.description(), |
18581
3490c91a1fcb
templates: export extra as a dict to templates
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
18563
diff
changeset
|
910 |
"extra": f.extra(), |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
911 |
"file": f.path(), |
29388
f694e20193f2
hgweb: display blamed revision once per block in annotate view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
29382
diff
changeset
|
912 |
"blockhead": blockhead, |
29572
d86b54d9bb0c
paper: make different blocks of annotated lines have different colors
Anton Shestakov <av6@dwimlabs.net>
parents:
29538
diff
changeset
|
913 |
"blockparity": blockparity, |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
914 |
"targetline": targetline, |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
915 |
"line": l, |
24712
bbf1ae6b6a44
hgweb: expose raw line numbers to templates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24306
diff
changeset
|
916 |
"lineno": lineno + 1, |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
917 |
"lineid": "l%d" % (lineno + 1), |
13199
a38df1250945
hgweb: added revision date to annotate line data
Oli Thissen <oli@tonick.net>
parents:
12696
diff
changeset
|
918 |
"linenumber": "% 6d" % (lineno + 1), |
a38df1250945
hgweb: added revision date to annotate line data
Oli Thissen <oli@tonick.net>
parents:
12696
diff
changeset
|
919 |
"revdate": f.date()} |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
920 |
|
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
921 |
return tmpl("fileannotate", |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
922 |
file=f, |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
923 |
annotate=annotate, |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
924 |
path=webutil.up(f), |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
925 |
symrev=webutil.symrevorshortnode(req, fctx), |
6434
62e0bb41e682
hgweb: minor improvements for new web style
Matt Mackall <mpm@selenic.com>
parents:
6410
diff
changeset
|
926 |
rename=webutil.renamelink(fctx), |
27294
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
927 |
permissions=fctx.manifest().flags(f), |
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
928 |
**webutil.commonentry(web.repo, fctx)) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
929 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
930 |
@webcommand('filelog') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
931 |
def filelog(web, req, tmpl): |
24095
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
932 |
""" |
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
933 |
/filelog/{revision}/{path} |
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
934 |
-------------------------- |
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
935 |
|
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
936 |
Show information about the history of a file in the repository. |
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
937 |
|
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
938 |
The ``revcount`` query string argument can be defined to control the |
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
939 |
maximum number of entries to show. |
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
940 |
|
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
941 |
The ``filelog`` template will be rendered. |
1f48b157dccf
webcommands: document "filelog" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24094
diff
changeset
|
942 |
""" |
7300
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
943 |
|
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
944 |
try: |
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
945 |
fctx = webutil.filectx(web.repo, req) |
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
946 |
f = fctx.path() |
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
947 |
fl = fctx.filelog() |
7633 | 948 |
except error.LookupError: |
7300
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
949 |
f = webutil.cleanpath(web.repo, req.form['file'][0]) |
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
950 |
fl = web.repo.file(f) |
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
951 |
numrevs = len(fl) |
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
952 |
if not numrevs: # file doesn't exist at all |
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
953 |
raise |
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
954 |
rev = webutil.changectx(web.repo, req).rev() |
7361
9fe97eea5510
linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents:
7345
diff
changeset
|
955 |
first = fl.linkrev(0) |
7300
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
956 |
if rev < first: # current rev is from before file existed |
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
957 |
raise |
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
958 |
frev = numrevs - 1 |
7361
9fe97eea5510
linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents:
7345
diff
changeset
|
959 |
while fl.linkrev(frev) > rev: |
7300
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
960 |
frev -= 1 |
7361
9fe97eea5510
linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents:
7345
diff
changeset
|
961 |
fctx = web.repo.filectx(f, fl.linkrev(frev)) |
7300
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
962 |
|
10246
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
963 |
revcount = web.maxshortchanges |
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
964 |
if 'revcount' in req.form: |
20092
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
965 |
try: |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
966 |
revcount = int(req.form.get('revcount', [revcount])[0]) |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
967 |
revcount = max(revcount, 1) |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
968 |
tmpl.defaults['sessionvars']['revcount'] = revcount |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
969 |
except ValueError: |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
970 |
pass |
10246
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
971 |
|
31665
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
972 |
lrange = webutil.linerange(req) |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
973 |
|
10246
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
974 |
lessvars = copy.copy(tmpl.defaults['sessionvars']) |
13931
c3372529247f
hgweb: set minimum number of revision to display to 1 when revcount is 0
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13924
diff
changeset
|
975 |
lessvars['revcount'] = max(revcount / 2, 1) |
10246
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
976 |
morevars = copy.copy(tmpl.defaults['sessionvars']) |
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
977 |
morevars['revcount'] = revcount * 2 |
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
978 |
|
31661
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
979 |
patch = 'patch' in req.form |
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
980 |
if patch: |
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
981 |
lessvars['patch'] = morevars['patch'] = req.form['patch'][0] |
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
982 |
|
7300
591767e6ea7a
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7288
diff
changeset
|
983 |
count = fctx.filerev() + 1 |
30826
923336cf8b8a
hgweb: simplify calculation of first revision in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30825
diff
changeset
|
984 |
start = max(0, count - revcount) # first rev on this page |
10246
b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
10245
diff
changeset
|
985 |
end = min(count, start + revcount) # last rev on this page |
30825
4deb7c1a07ab
hgweb: restore ascending iteration on revs in filelog web command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30816
diff
changeset
|
986 |
parity = paritygen(web.stripecount, offset=start - end) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
987 |
|
30816
96f811bceb85
hgweb: build the "entries" list directly in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30734
diff
changeset
|
988 |
repo = web.repo |
96f811bceb85
hgweb: build the "entries" list directly in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30734
diff
changeset
|
989 |
revs = fctx.filelog().revs(start, end - 1) |
96f811bceb85
hgweb: build the "entries" list directly in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30734
diff
changeset
|
990 |
entries = [] |
31661
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
991 |
|
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
992 |
diffstyle = web.config('web', 'style', 'paper') |
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
993 |
if 'style' in req.form: |
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
994 |
diffstyle = req.form['style'][0] |
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
995 |
|
31667
e540846c67e0
hgweb: filter diff hunks when 'linerange' and 'patch' are specified in filelog
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31665
diff
changeset
|
996 |
def diff(fctx, linerange=None): |
31661
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
997 |
ctx = fctx.changectx() |
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
998 |
basectx = ctx.p1() |
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
999 |
path = fctx.path() |
31667
e540846c67e0
hgweb: filter diff hunks when 'linerange' and 'patch' are specified in filelog
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31665
diff
changeset
|
1000 |
return webutil.diffs(web, tmpl, ctx, basectx, [path], diffstyle, |
31727
6be6e4becaaf
hgweb: prefix line id by ctx shortnode in filelog when patches are shown
Denis Laxalde <denis@laxalde.org>
parents:
31667
diff
changeset
|
1001 |
linerange=linerange, |
6be6e4becaaf
hgweb: prefix line id by ctx shortnode in filelog when patches are shown
Denis Laxalde <denis@laxalde.org>
parents:
31667
diff
changeset
|
1002 |
lineidprefix='%s-' % ctx.hex()[:12]) |
31661
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
1003 |
|
31665
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1004 |
linerange = None |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1005 |
if lrange is not None: |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1006 |
linerange = webutil.formatlinerange(*lrange) |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1007 |
# deactivate numeric nav links when linerange is specified as this |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1008 |
# would required a dedicated "revnav" class |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1009 |
nav = None |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1010 |
ancestors = context.blockancestors(fctx, *lrange) |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1011 |
for i, (c, lr) in enumerate(ancestors, 1): |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1012 |
diffs = None |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1013 |
if patch: |
31667
e540846c67e0
hgweb: filter diff hunks when 'linerange' and 'patch' are specified in filelog
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31665
diff
changeset
|
1014 |
diffs = diff(c, linerange=lr) |
31665
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1015 |
# follow renames accross filtered (not in range) revisions |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1016 |
path = c.path() |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1017 |
entries.append(dict( |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1018 |
parity=next(parity), |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1019 |
filerev=c.rev(), |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1020 |
file=path, |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1021 |
diff=diffs, |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1022 |
linerange=webutil.formatlinerange(*lr), |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1023 |
**webutil.commonentry(repo, c))) |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1024 |
if i == revcount: |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1025 |
break |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1026 |
lessvars['linerange'] = webutil.formatlinerange(*lrange) |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1027 |
morevars['linerange'] = lessvars['linerange'] |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1028 |
else: |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1029 |
for i in revs: |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1030 |
iterfctx = fctx.filectx(i) |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1031 |
diffs = None |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1032 |
if patch: |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1033 |
diffs = diff(iterfctx) |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1034 |
entries.append(dict( |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1035 |
parity=next(parity), |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1036 |
filerev=i, |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1037 |
file=f, |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1038 |
diff=diffs, |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1039 |
rename=webutil.renamelink(iterfctx), |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1040 |
**webutil.commonentry(repo, iterfctx))) |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1041 |
entries.reverse() |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1042 |
revnav = webutil.filerevnav(web.repo, fctx.path()) |
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1043 |
nav = revnav.gen(end - 1, revcount, count) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1044 |
|
20022
d85dfe211c71
hgweb: always compute all entries and latestentry in filelog
Alexander Plavin <alexander@plav.in>
parents:
20021
diff
changeset
|
1045 |
latestentry = entries[:1] |
d85dfe211c71
hgweb: always compute all entries and latestentry in filelog
Alexander Plavin <alexander@plav.in>
parents:
20021
diff
changeset
|
1046 |
|
27294
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
1047 |
return tmpl("filelog", |
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
1048 |
file=f, |
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
1049 |
nav=nav, |
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
1050 |
symrev=webutil.symrevorshortnode(req, fctx), |
20022
d85dfe211c71
hgweb: always compute all entries and latestentry in filelog
Alexander Plavin <alexander@plav.in>
parents:
20021
diff
changeset
|
1051 |
entries=entries, |
31661
f36dc643ffdc
hgweb: add a "patch" query parameter to filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31660
diff
changeset
|
1052 |
patch=patch, |
20022
d85dfe211c71
hgweb: always compute all entries and latestentry in filelog
Alexander Plavin <alexander@plav.in>
parents:
20021
diff
changeset
|
1053 |
latestentry=latestentry, |
31665
5e6d44511317
hgweb: handle a "linerange" request parameter in filelog command
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31661
diff
changeset
|
1054 |
linerange=linerange, |
27294
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
1055 |
revcount=revcount, |
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
1056 |
morevars=morevars, |
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
1057 |
lessvars=lessvars, |
5aa2afb4f81a
hgweb: move entry-preparing code from webcommands to webutils.commonentry()
Anton Shestakov <av6@dwimlabs.net>
parents:
27160
diff
changeset
|
1058 |
**webutil.commonentry(web.repo, fctx)) |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1059 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
1060 |
@webcommand('archive') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
1061 |
def archive(web, req, tmpl): |
24096
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1062 |
""" |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1063 |
/archive/{revision}.{format}[/{path}] |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1064 |
------------------------------------- |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1065 |
|
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1066 |
Obtain an archive of repository content. |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1067 |
|
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1068 |
The content and type of the archive is defined by a URL path parameter. |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1069 |
``format`` is the file extension of the archive type to be generated. e.g. |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1070 |
``zip`` or ``tar.bz2``. Not all archive types may be allowed by your |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1071 |
server configuration. |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1072 |
|
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1073 |
The optional ``path`` URL parameter controls content to include in the |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1074 |
archive. If omitted, every file in the specified revision is present in the |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1075 |
archive. If included, only the specified file or contents of the specified |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1076 |
directory will be included in the archive. |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1077 |
|
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1078 |
No template is used for this handler. Raw, binary content is generated. |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1079 |
""" |
bb8b6d44fe1d
webcommands: document "archive" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24095
diff
changeset
|
1080 |
|
6669
782dbbdfb1d7
fix traceback in hgweb when URL doesn't end in one of the archive specs
Ali Saidi <saidi@eecs.umich.edu>
parents:
6368
diff
changeset
|
1081 |
type_ = req.form.get('type', [None])[0] |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1082 |
allowed = web.configlist("web", "allow_archive") |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1083 |
key = req.form['node'][0] |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1084 |
|
30734
b9e49f7b0220
hgweb: use archivespecs (dict) instead of archives (tuple) for "in" check
Anton Shestakov <av6@dwimlabs.net>
parents:
30559
diff
changeset
|
1085 |
if type_ not in web.archivespecs: |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1086 |
msg = 'Unsupported archive type: %s' % type_ |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1087 |
raise ErrorResponse(HTTP_NOT_FOUND, msg) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1088 |
|
7029
b84d27386285
hgweb: Respond with HTTP 403 for disabled archive types instead of 404
Rocco Rutte <pdmef@gmx.net>
parents:
6981
diff
changeset
|
1089 |
if not ((type_ in allowed or |
b84d27386285
hgweb: Respond with HTTP 403 for disabled archive types instead of 404
Rocco Rutte <pdmef@gmx.net>
parents:
6981
diff
changeset
|
1090 |
web.configbool("web", "allow" + type_, False))): |
b84d27386285
hgweb: Respond with HTTP 403 for disabled archive types instead of 404
Rocco Rutte <pdmef@gmx.net>
parents:
6981
diff
changeset
|
1091 |
msg = 'Archive type not allowed: %s' % type_ |
b84d27386285
hgweb: Respond with HTTP 403 for disabled archive types instead of 404
Rocco Rutte <pdmef@gmx.net>
parents:
6981
diff
changeset
|
1092 |
raise ErrorResponse(HTTP_FORBIDDEN, msg) |
b84d27386285
hgweb: Respond with HTTP 403 for disabled archive types instead of 404
Rocco Rutte <pdmef@gmx.net>
parents:
6981
diff
changeset
|
1093 |
|
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1094 |
reponame = re.sub(r"\W+", "-", os.path.basename(web.reponame)) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1095 |
cnode = web.repo.lookup(key) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1096 |
arch_version = key |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1097 |
if cnode == key or key == 'tip': |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1098 |
arch_version = short(cnode) |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1099 |
name = "%s-%s" % (reponame, arch_version) |
18771
bb38f4f78104
hgweb: teach archive how to download a specific directory or file
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18747
diff
changeset
|
1100 |
|
bb38f4f78104
hgweb: teach archive how to download a specific directory or file
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18747
diff
changeset
|
1101 |
ctx = webutil.changectx(web.repo, req) |
bb38f4f78104
hgweb: teach archive how to download a specific directory or file
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18747
diff
changeset
|
1102 |
pats = [] |
23232
a0ccb66f344d
hgweb: fix a crash when using web.archivesubrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
22634
diff
changeset
|
1103 |
matchfn = scmutil.match(ctx, []) |
18771
bb38f4f78104
hgweb: teach archive how to download a specific directory or file
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18747
diff
changeset
|
1104 |
file = req.form.get('file', None) |
bb38f4f78104
hgweb: teach archive how to download a specific directory or file
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18747
diff
changeset
|
1105 |
if file: |
18968
7d2a7f8e9da4
hgweb: respond HTTP_NOT_FOUND when an archive request does not match any files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18771
diff
changeset
|
1106 |
pats = ['path:' + file[0]] |
7d2a7f8e9da4
hgweb: respond HTTP_NOT_FOUND when an archive request does not match any files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18771
diff
changeset
|
1107 |
matchfn = scmutil.match(ctx, pats, default='path') |
7d2a7f8e9da4
hgweb: respond HTTP_NOT_FOUND when an archive request does not match any files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18771
diff
changeset
|
1108 |
if pats: |
7d2a7f8e9da4
hgweb: respond HTTP_NOT_FOUND when an archive request does not match any files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18771
diff
changeset
|
1109 |
files = [f for f in ctx.manifest().keys() if matchfn(f)] |
7d2a7f8e9da4
hgweb: respond HTTP_NOT_FOUND when an archive request does not match any files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18771
diff
changeset
|
1110 |
if not files: |
7d2a7f8e9da4
hgweb: respond HTTP_NOT_FOUND when an archive request does not match any files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18771
diff
changeset
|
1111 |
raise ErrorResponse(HTTP_NOT_FOUND, |
7d2a7f8e9da4
hgweb: respond HTTP_NOT_FOUND when an archive request does not match any files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18771
diff
changeset
|
1112 |
'file(s) not found: %s' % file[0]) |
18771
bb38f4f78104
hgweb: teach archive how to download a specific directory or file
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18747
diff
changeset
|
1113 |
|
26136
6defc74f3066
hgweb: move archive related attributes to requestcontext
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26131
diff
changeset
|
1114 |
mimetype, artype, extension, encoding = web.archivespecs[type_] |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1115 |
headers = [ |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1116 |
('Content-Disposition', 'attachment; filename=%s%s' % (name, extension)) |
18347
853221386f48
hgweb: make type a mandatory parameter to request.respond
Mads Kiilerich <mads@kiilerich.com>
parents:
18319
diff
changeset
|
1117 |
] |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1118 |
if encoding: |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1119 |
headers.append(('Content-Encoding', encoding)) |
18348
764a758780b6
hgweb: simplify wsgirequest header handling
Mads Kiilerich <mads@kiilerich.com>
parents:
18347
diff
changeset
|
1120 |
req.headers.extend(headers) |
18347
853221386f48
hgweb: make type a mandatory parameter to request.respond
Mads Kiilerich <mads@kiilerich.com>
parents:
18319
diff
changeset
|
1121 |
req.respond(HTTP_OK, mimetype) |
17933
8243dd66e0e3
webcommands: allow hgweb's archive to recurse into subrepos
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17322
diff
changeset
|
1122 |
|
8243dd66e0e3
webcommands: allow hgweb's archive to recurse into subrepos
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17322
diff
changeset
|
1123 |
archival.archive(web.repo, req, cnode, artype, prefix=name, |
18771
bb38f4f78104
hgweb: teach archive how to download a specific directory or file
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18747
diff
changeset
|
1124 |
matchfn=matchfn, |
17933
8243dd66e0e3
webcommands: allow hgweb's archive to recurse into subrepos
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17322
diff
changeset
|
1125 |
subrepos=web.configbool("web", "archivesubrepos")) |
6393
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1126 |
return [] |
894875eae49b
hgweb: refactor hgweb code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6392
diff
changeset
|
1127 |
|
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1128 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
1129 |
@webcommand('static') |
5600
9d900f7282e6
hgweb: explicitly pass around the templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5598
diff
changeset
|
1130 |
def static(web, req, tmpl): |
5591
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1131 |
fname = req.form['file'][0] |
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1132 |
# a repo owner may set web.static in .hg/hgrc to get any file |
08887121a652
split out hgweb commands into a separate file, move some code around
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1133 |
# readable by the user running the CGI script |
7107
125c8fedcbe0
Allow hgweb to search for templates in more than one path.
Brendan Cully <brendan@kublai.com>
parents:
7102
diff
changeset
|
1134 |
static = web.config("web", "static", None, untrusted=False) |
125c8fedcbe0
Allow hgweb to search for templates in more than one path.
Brendan Cully <brendan@kublai.com>
parents:
7102
diff
changeset
|
1135 |
if not static: |
22634
e48a5d3996c2
templater: introduce templatepaths for getting paths searched for templates
Mads Kiilerich <madski@unity3d.com>
parents:
22199
diff
changeset
|
1136 |
tp = web.templatepath or templater.templatepaths() |
7107
125c8fedcbe0
Allow hgweb to search for templates in more than one path.
Brendan Cully <brendan@kublai.com>
parents:
7102
diff
changeset
|
1137 |
if isinstance(tp, str): |
125c8fedcbe0
Allow hgweb to search for templates in more than one path.
Brendan Cully <brendan@kublai.com>
parents:
7102
diff
changeset
|
1138 |
tp = [tp] |
7288
9c399c53469d
Allow per-file shadowing of static directory in templatepath
Brendan Cully <brendan@kublai.com>
parents:
7280
diff
changeset
|
1139 |
static = [os.path.join(p, 'static') for p in tp] |
18645
76ff3a715cf2
hgweb: simplify internal staticfile return codes
Mads Kiilerich <mads@kiilerich.com>
parents:
18581
diff
changeset
|
1140 |
staticfile(static, fname, req) |
76ff3a715cf2
hgweb: simplify internal staticfile return codes
Mads Kiilerich <mads@kiilerich.com>
parents:
18581
diff
changeset
|
1141 |
return [] |
6691
0dba955c2636
add graph page to hgweb
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6670
diff
changeset
|
1142 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
1143 |
@webcommand('graph') |
6691
0dba955c2636
add graph page to hgweb
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6670
diff
changeset
|
1144 |
def graph(web, req, tmpl): |
24097
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1145 |
""" |
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1146 |
/graph[/{revision}] |
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1147 |
------------------- |
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1148 |
|
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1149 |
Show information about the graphical topology of the repository. |
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1150 |
|
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1151 |
Information rendered by this handler can be used to create visual |
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1152 |
representations of repository topology. |
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1153 |
|
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1154 |
The ``revision`` URL parameter controls the starting changeset. |
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1155 |
|
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1156 |
The ``revcount`` query string argument can define the number of changesets |
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1157 |
to show information for. |
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1158 |
|
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1159 |
This handler will render the ``graph`` template. |
8e04a73b5502
webcommands: document "graph" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24096
diff
changeset
|
1160 |
""" |
10245
207b94f6b65d
hgweb: make graph page size equal to shortlog
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9404
diff
changeset
|
1161 |
|
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
1162 |
if 'node' in req.form: |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
1163 |
ctx = webutil.changectx(web.repo, req) |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
1164 |
symrev = webutil.symrevorshortnode(req, ctx) |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
1165 |
else: |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
1166 |
ctx = web.repo['tip'] |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
1167 |
symrev = 'tip' |
17318
7ac5800dbc8f
hgweb: fix graph view paging
Patrick Mezard <patrick@mezard.eu>
parents:
17303
diff
changeset
|
1168 |
rev = ctx.rev() |
7ac5800dbc8f
hgweb: fix graph view paging
Patrick Mezard <patrick@mezard.eu>
parents:
17303
diff
changeset
|
1169 |
|
6691
0dba955c2636
add graph page to hgweb
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6670
diff
changeset
|
1170 |
bg_height = 39 |
10245
207b94f6b65d
hgweb: make graph page size equal to shortlog
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9404
diff
changeset
|
1171 |
revcount = web.maxshortchanges |
7345
55651328dfcc
hgweb: fix up the less/more links on the graph page
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7332
diff
changeset
|
1172 |
if 'revcount' in req.form: |
20092
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
1173 |
try: |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
1174 |
revcount = int(req.form.get('revcount', [revcount])[0]) |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
1175 |
revcount = max(revcount, 1) |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
1176 |
tmpl.defaults['sessionvars']['revcount'] = revcount |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
1177 |
except ValueError: |
77acd8ce01ce
hgweb: ignore non numeric "revcount" parameter values (issue4091)
Isaac Jurado <diptongo@gmail.com>
parents:
20004
diff
changeset
|
1178 |
pass |
7345
55651328dfcc
hgweb: fix up the less/more links on the graph page
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7332
diff
changeset
|
1179 |
|
55651328dfcc
hgweb: fix up the less/more links on the graph page
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7332
diff
changeset
|
1180 |
lessvars = copy.copy(tmpl.defaults['sessionvars']) |
13931
c3372529247f
hgweb: set minimum number of revision to display to 1 when revcount is 0
Md. O. Shayan <mdoshayan@gmail.com>
parents:
13924
diff
changeset
|
1181 |
lessvars['revcount'] = max(revcount / 2, 1) |
7345
55651328dfcc
hgweb: fix up the less/more links on the graph page
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7332
diff
changeset
|
1182 |
morevars = copy.copy(tmpl.defaults['sessionvars']) |
55651328dfcc
hgweb: fix up the less/more links on the graph page
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7332
diff
changeset
|
1183 |
morevars['revcount'] = revcount * 2 |
55651328dfcc
hgweb: fix up the less/more links on the graph page
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7332
diff
changeset
|
1184 |
|
17318
7ac5800dbc8f
hgweb: fix graph view paging
Patrick Mezard <patrick@mezard.eu>
parents:
17303
diff
changeset
|
1185 |
count = len(web.repo) |
7ac5800dbc8f
hgweb: fix graph view paging
Patrick Mezard <patrick@mezard.eu>
parents:
17303
diff
changeset
|
1186 |
pos = rev |
7ac5800dbc8f
hgweb: fix graph view paging
Patrick Mezard <patrick@mezard.eu>
parents:
17303
diff
changeset
|
1187 |
|
7ac5800dbc8f
hgweb: fix graph view paging
Patrick Mezard <patrick@mezard.eu>
parents:
17303
diff
changeset
|
1188 |
uprev = min(max(0, count - 1), rev + revcount) |
6691
0dba955c2636
add graph page to hgweb
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6670
diff
changeset
|
1189 |
downrev = max(0, rev - revcount) |
18409
e3f5cef11d6a
hgweb: pass repo object to revnav construction
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18408
diff
changeset
|
1190 |
changenav = webutil.revnav(web.repo).gen(pos, revcount, count) |
6691
0dba955c2636
add graph page to hgweb
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6670
diff
changeset
|
1191 |
|
18428
8c10f760ca34
hgweb: walk the graph through the changelog
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18427
diff
changeset
|
1192 |
tree = [] |
19487
8cfa3a3664a5
hgweb: fix incorrect revisions count in graph (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19486
diff
changeset
|
1193 |
if pos != -1: |
8cfa3a3664a5
hgweb: fix incorrect revisions count in graph (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19486
diff
changeset
|
1194 |
allrevs = web.repo.changelog.revs(pos, 0) |
8cfa3a3664a5
hgweb: fix incorrect revisions count in graph (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19486
diff
changeset
|
1195 |
revs = [] |
8cfa3a3664a5
hgweb: fix incorrect revisions count in graph (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19486
diff
changeset
|
1196 |
for i in allrevs: |
8cfa3a3664a5
hgweb: fix incorrect revisions count in graph (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19486
diff
changeset
|
1197 |
revs.append(i) |
8cfa3a3664a5
hgweb: fix incorrect revisions count in graph (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19486
diff
changeset
|
1198 |
if len(revs) >= revcount: |
8cfa3a3664a5
hgweb: fix incorrect revisions count in graph (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19486
diff
changeset
|
1199 |
break |
8cfa3a3664a5
hgweb: fix incorrect revisions count in graph (issue3977)
Alexander Plavin <me@aplavin.ru>
parents:
19486
diff
changeset
|
1200 |
|
20761
46f93b7660b6
webcommands: changed code to use lazy classes when calling dagwalker
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20678
diff
changeset
|
1201 |
# We have to feed a baseset to dagwalker as it is expecting smartset |
46f93b7660b6
webcommands: changed code to use lazy classes when calling dagwalker
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20678
diff
changeset
|
1202 |
# object. This does not have a big impact on hgweb performance itself |
46f93b7660b6
webcommands: changed code to use lazy classes when calling dagwalker
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20678
diff
changeset
|
1203 |
# since hgweb graphing code is not itself lazy yet. |
31023
aea06029919e
revset: import set classes directly from smartset module
Yuya Nishihara <yuya@tcha.org>
parents:
30826
diff
changeset
|
1204 |
dag = graphmod.dagwalker(web.repo, smartset.baseset(revs)) |
20761
46f93b7660b6
webcommands: changed code to use lazy classes when calling dagwalker
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20678
diff
changeset
|
1205 |
# As we said one line above... not lazy. |
18428
8c10f760ca34
hgweb: walk the graph through the changelog
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18427
diff
changeset
|
1206 |
tree = list(graphmod.colored(dag, web.repo)) |
16773
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1207 |
|
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1208 |
def getcolumns(tree): |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1209 |
cols = 0 |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1210 |
for (id, type, ctx, vtx, edges) in tree: |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1211 |
if type != graphmod.CHANGESET: |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1212 |
continue |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1213 |
cols = max(cols, max([edge[0] for edge in edges] or [0]), |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1214 |
max([edge[1] for edge in edges] or [0])) |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1215 |
return cols |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1216 |
|
28211
446465888119
hgweb: add option to convert encoding of graphdata()
Yuya Nishihara <yuya@tcha.org>
parents:
28210
diff
changeset
|
1217 |
def graphdata(usetuples, encodestr): |
16773
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1218 |
data = [] |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1219 |
|
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1220 |
row = 0 |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1221 |
for (id, type, ctx, vtx, edges) in tree: |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1222 |
if type != graphmod.CHANGESET: |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1223 |
continue |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1224 |
node = str(ctx) |
28211
446465888119
hgweb: add option to convert encoding of graphdata()
Yuya Nishihara <yuya@tcha.org>
parents:
28210
diff
changeset
|
1225 |
age = encodestr(templatefilters.age(ctx.date())) |
446465888119
hgweb: add option to convert encoding of graphdata()
Yuya Nishihara <yuya@tcha.org>
parents:
28210
diff
changeset
|
1226 |
desc = templatefilters.firstline(encodestr(ctx.description())) |
16773
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1227 |
desc = cgi.escape(templatefilters.nonempty(desc)) |
28211
446465888119
hgweb: add option to convert encoding of graphdata()
Yuya Nishihara <yuya@tcha.org>
parents:
28210
diff
changeset
|
1228 |
user = cgi.escape(templatefilters.person(encodestr(ctx.user()))) |
446465888119
hgweb: add option to convert encoding of graphdata()
Yuya Nishihara <yuya@tcha.org>
parents:
28210
diff
changeset
|
1229 |
branch = cgi.escape(encodestr(ctx.branch())) |
16773
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1230 |
try: |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1231 |
branchnode = web.repo.branchtip(branch) |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1232 |
except error.RepoLookupError: |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1233 |
branchnode = None |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1234 |
branch = branch, branchnode == ctx.node() |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1235 |
|
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1236 |
if usetuples: |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1237 |
data.append((node, vtx, edges, desc, user, age, branch, |
28211
446465888119
hgweb: add option to convert encoding of graphdata()
Yuya Nishihara <yuya@tcha.org>
parents:
28210
diff
changeset
|
1238 |
[cgi.escape(encodestr(x)) for x in ctx.tags()], |
446465888119
hgweb: add option to convert encoding of graphdata()
Yuya Nishihara <yuya@tcha.org>
parents:
28210
diff
changeset
|
1239 |
[cgi.escape(encodestr(x)) |
446465888119
hgweb: add option to convert encoding of graphdata()
Yuya Nishihara <yuya@tcha.org>
parents:
28210
diff
changeset
|
1240 |
for x in ctx.bookmarks()])) |
16773
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1241 |
else: |
20678
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1242 |
edgedata = [{'col': edge[0], 'nextcol': edge[1], |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1243 |
'color': (edge[2] - 1) % 6 + 1, |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1244 |
'width': edge[3], 'bcolor': edge[4]} |
16773
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1245 |
for edge in edges] |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1246 |
|
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1247 |
data.append( |
20678
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1248 |
{'node': node, |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1249 |
'col': vtx[0], |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1250 |
'color': (vtx[1] - 1) % 6 + 1, |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1251 |
'edges': edgedata, |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1252 |
'row': row, |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1253 |
'nextrow': row + 1, |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1254 |
'desc': desc, |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1255 |
'user': user, |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1256 |
'age': age, |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1257 |
'bookmarks': webutil.nodebookmarksdict( |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1258 |
web.repo, ctx.node()), |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1259 |
'branches': webutil.nodebranchdict(web.repo, ctx), |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1260 |
'inbranch': webutil.nodeinbranch(web.repo, ctx), |
da6bea33007b
webcommands: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
20364
diff
changeset
|
1261 |
'tags': webutil.nodetagsdict(web.repo, ctx.node())}) |
16773
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1262 |
|
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1263 |
row += 1 |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1264 |
|
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1265 |
return data |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1266 |
|
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1267 |
cols = getcolumns(tree) |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1268 |
rows = len(tree) |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1269 |
canvasheight = (rows + 1) * bg_height - 27 |
6691
0dba955c2636
add graph page to hgweb
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6670
diff
changeset
|
1270 |
|
25602
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
1271 |
return tmpl('graph', rev=rev, symrev=symrev, revcount=revcount, |
85fb416f2fa7
hgweb: provide symrev (symbolic revision) property to the templates
Anton Shestakov <av6@dwimlabs.net>
parents:
25251
diff
changeset
|
1272 |
uprev=uprev, |
7345
55651328dfcc
hgweb: fix up the less/more links on the graph page
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7332
diff
changeset
|
1273 |
lessvars=lessvars, morevars=morevars, downrev=downrev, |
16773
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1274 |
cols=cols, rows=rows, |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1275 |
canvaswidth=(cols + 1) * bg_height, |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1276 |
truecanvasheight=rows * bg_height, |
d490edc71146
hgweb: make graph data suitable for template usage
Paul Boddie <paul@boddie.org.uk>
parents:
16727
diff
changeset
|
1277 |
canvasheight=canvasheight, bg_height=bg_height, |
28212
d4419c01532b
templatefilters: make json filter be byte-transparent (BC) (issue4926)
Yuya Nishihara <yuya@tcha.org>
parents:
28211
diff
changeset
|
1278 |
# {jsdata} will be passed to |json, so it must be in utf-8 |
d4419c01532b
templatefilters: make json filter be byte-transparent (BC) (issue4926)
Yuya Nishihara <yuya@tcha.org>
parents:
28211
diff
changeset
|
1279 |
jsdata=lambda **x: graphdata(True, encoding.fromlocal), |
28211
446465888119
hgweb: add option to convert encoding of graphdata()
Yuya Nishihara <yuya@tcha.org>
parents:
28210
diff
changeset
|
1280 |
nodes=lambda **x: graphdata(False, str), |
17318
7ac5800dbc8f
hgweb: fix graph view paging
Patrick Mezard <patrick@mezard.eu>
parents:
17303
diff
changeset
|
1281 |
node=ctx.hex(), changenav=changenav) |
12666
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1282 |
|
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1283 |
def _getdoc(e): |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1284 |
doc = e[0].__doc__ |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1285 |
if doc: |
26846
7c1b4840c2cd
hgweb: replace some str.split() calls by str.partition() or str.rpartition()
Anton Shestakov <av6@dwimlabs.net>
parents:
26781
diff
changeset
|
1286 |
doc = _(doc).partition('\n')[0] |
12666
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1287 |
else: |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1288 |
doc = _('(no help text available)') |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1289 |
return doc |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1290 |
|
24076
b53d2afd11fb
webcommands: define web commands using a decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23992
diff
changeset
|
1291 |
@webcommand('help') |
12666
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1292 |
def help(web, req, tmpl): |
24081
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1293 |
""" |
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1294 |
/help[/{topic}] |
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1295 |
--------------- |
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1296 |
|
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1297 |
Render help documentation. |
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1298 |
|
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1299 |
This web command is roughly equivalent to :hg:`help`. If a ``topic`` |
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1300 |
is defined, that help topic will be rendered. If not, an index of |
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1301 |
available help topics will be rendered. |
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1302 |
|
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1303 |
The ``help`` template will be rendered when requesting help for a topic. |
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1304 |
``helptopics`` will be rendered for the index of help topics. |
ff42de48193c
webcommands: document "help" web command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24078
diff
changeset
|
1305 |
""" |
27046
37fcfe52c68c
hgweb: use absolute_import
Yuya Nishihara <yuya@tcha.org>
parents:
27009
diff
changeset
|
1306 |
from .. import commands, help as helpmod # avoid cycle |
12666
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1307 |
|
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1308 |
topicname = req.form.get('node', [None])[0] |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1309 |
if not topicname: |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1310 |
def topics(**map): |
22199
b3e51675f98e
cleanup: avoid _ for local unused tmp variables - that is reserved for i18n
Mads Kiilerich <madski@unity3d.com>
parents:
21123
diff
changeset
|
1311 |
for entries, summary, _doc in helpmod.helptable: |
17322
7124f984dc8d
help: use the first topic name from helptable, not the longest alias
Mads Kiilerich <mads@kiilerich.com>
parents:
17318
diff
changeset
|
1312 |
yield {'topic': entries[0], 'summary': summary} |
12666
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1313 |
|
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1314 |
early, other = [], [] |
26846
7c1b4840c2cd
hgweb: replace some str.split() calls by str.partition() or str.rpartition()
Anton Shestakov <av6@dwimlabs.net>
parents:
26781
diff
changeset
|
1315 |
primary = lambda s: s.partition('|')[0] |
12666
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1316 |
for c, e in commands.table.iteritems(): |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1317 |
doc = _getdoc(e) |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1318 |
if 'DEPRECATED' in doc or c.startswith('debug'): |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1319 |
continue |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1320 |
cmd = primary(c) |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1321 |
if cmd.startswith('^'): |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1322 |
early.append((cmd[1:], doc)) |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1323 |
else: |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1324 |
other.append((cmd, doc)) |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1325 |
|
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1326 |
early.sort() |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1327 |
other.sort() |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1328 |
|
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1329 |
def earlycommands(**map): |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1330 |
for c, doc in early: |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1331 |
yield {'topic': c, 'summary': doc} |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1332 |
|
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1333 |
def othercommands(**map): |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1334 |
for c, doc in other: |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1335 |
yield {'topic': c, 'summary': doc} |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1336 |
|
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1337 |
return tmpl('helptopics', topics=topics, earlycommands=earlycommands, |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1338 |
othercommands=othercommands, title='Index') |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1339 |
|
27581
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1340 |
# Render an index of sub-topics. |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1341 |
if topicname in helpmod.subtopics: |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1342 |
topics = [] |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1343 |
for entries, summary, _doc in helpmod.subtopics[topicname]: |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1344 |
topics.append({ |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1345 |
'topic': '%s.%s' % (topicname, entries[0]), |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1346 |
'basename': entries[0], |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1347 |
'summary': summary, |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1348 |
}) |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1349 |
|
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1350 |
return tmpl('helptopics', topics=topics, title=topicname, |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1351 |
subindex=True) |
3aa6a8135557
hgweb: support rendering sub-topic indexes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27294
diff
changeset
|
1352 |
|
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30298
diff
changeset
|
1353 |
u = webutil.wsgiui.load() |
17146
6b40cc67ceb4
hgweb: show help with verbose sections included
Adrian Buehlmann <adrian@cadifra.com>
parents:
16773
diff
changeset
|
1354 |
u.verbose = True |
27582
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1355 |
|
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1356 |
# Render a page from a sub-topic. |
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1357 |
if '.' in topicname: |
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1358 |
# TODO implement support for rendering sections, like |
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1359 |
# `hg help` works. |
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1360 |
topic, subtopic = topicname.split('.', 1) |
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1361 |
if topic not in helpmod.subtopics: |
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1362 |
raise ErrorResponse(HTTP_NOT_FOUND) |
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1363 |
else: |
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1364 |
topic = topicname |
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1365 |
subtopic = None |
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1366 |
|
12666
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1367 |
try: |
27582
8f8f3b13252d
hgweb: support rendering a sub-topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27581
diff
changeset
|
1368 |
doc = helpmod.help_(u, topic, subtopic=subtopic) |
12666
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1369 |
except error.UnknownCommand: |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1370 |
raise ErrorResponse(HTTP_NOT_FOUND) |
ead4e21f49f1
web: add a help view for getting hg help output
Augie Fackler <durin42@gmail.com>
parents:
12063
diff
changeset
|
1371 |
return tmpl('help', topic=topicname, doc=doc) |
24859
64e3f97bdf08
i18n: extract doc string of each web commands as translatable one
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24712
diff
changeset
|
1372 |
|
64e3f97bdf08
i18n: extract doc string of each web commands as translatable one
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24712
diff
changeset
|
1373 |
# tell hggettext to extract docstrings from these functions: |
64e3f97bdf08
i18n: extract doc string of each web commands as translatable one
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24712
diff
changeset
|
1374 |
i18nfunctions = commands.values() |