author | Vadim Gelfer <vadim.gelfer@gmail.com> |
Tue, 20 Jun 2006 15:16:50 -0700 | |
changeset 2464 | 09b1c9ef317c |
parent 2442 | c660691fb45d |
child 2466 | e10665147d26 |
permissions | -rw-r--r-- |
2391
d351a3be3371
Fixing up comment headers for split up code.
Eric Hopper <hopper@omnifarious.org>
parents:
2361
diff
changeset
|
1 |
# hgweb/hgweb_mod.py - Web interface for a repository. |
131 | 2 |
# |
238
3b92f8fe47ae
hgweb.py: kill #! line, clean up copyright notice
mpm@selenic.com
parents:
222
diff
changeset
|
3 |
# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> |
575 | 4 |
# Copyright 2005 Matt Mackall <mpm@selenic.com> |
131 | 5 |
# |
6 |
# This software may be used and distributed according to the terms |
|
7 |
# of the GNU General Public License, incorporated herein by reference. |
|
8 |
||
2356
2db831b33e8f
Final stage of the hgweb split up.
Eric Hopper <hopper@omnifarious.org>
parents:
2355
diff
changeset
|
9 |
import os |
2db831b33e8f
Final stage of the hgweb split up.
Eric Hopper <hopper@omnifarious.org>
parents:
2355
diff
changeset
|
10 |
import os.path |
1777
a2316878f19d
[hgweb] Static content serving
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1703
diff
changeset
|
11 |
import mimetypes |
2311
b832b6eb65ab
Moving hgweb.py into it's own module in preparation for breaking it up.
Eric Hopper <hopper@omnifarious.org>
parents:
2275
diff
changeset
|
12 |
from mercurial.demandload import demandload |
2464
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
13 |
demandload(globals(), "re zlib ConfigParser cStringIO sys tempfile") |
2311
b832b6eb65ab
Moving hgweb.py into it's own module in preparation for breaking it up.
Eric Hopper <hopper@omnifarious.org>
parents:
2275
diff
changeset
|
14 |
demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,templater") |
2355
eb08fb4d41e1
Splitting up hgweb so it's easier to change.
Eric Hopper <hopper@omnifarious.org>
parents:
2328
diff
changeset
|
15 |
demandload(globals(), "mercurial.hgweb.request:hgrequest") |
2356
2db831b33e8f
Final stage of the hgweb split up.
Eric Hopper <hopper@omnifarious.org>
parents:
2355
diff
changeset
|
16 |
demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile") |
2311
b832b6eb65ab
Moving hgweb.py into it's own module in preparation for breaking it up.
Eric Hopper <hopper@omnifarious.org>
parents:
2275
diff
changeset
|
17 |
from mercurial.node import * |
b832b6eb65ab
Moving hgweb.py into it's own module in preparation for breaking it up.
Eric Hopper <hopper@omnifarious.org>
parents:
2275
diff
changeset
|
18 |
from mercurial.i18n import gettext as _ |
138 | 19 |
|
2356
2db831b33e8f
Final stage of the hgweb split up.
Eric Hopper <hopper@omnifarious.org>
parents:
2355
diff
changeset
|
20 |
def _up(p): |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
21 |
if p[0] != "/": |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
22 |
p = "/" + p |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
23 |
if p[-1] == "/": |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
24 |
p = p[:-1] |
138 | 25 |
up = os.path.dirname(p) |
26 |
if up == "/": |
|
27 |
return "/" |
|
28 |
return up + "/" |
|
131 | 29 |
|
1559
59b3639df0a9
Convert all classes to new-style classes by deriving them from object.
Eric Hopper <hopper@omnifarious.org>
parents:
1554
diff
changeset
|
30 |
class hgweb(object): |
987 | 31 |
def __init__(self, repo, name=None): |
32 |
if type(repo) == type(""): |
|
1213 | 33 |
self.repo = hg.repository(ui.ui(), repo) |
987 | 34 |
else: |
35 |
self.repo = repo |
|
133
fb84d3e71042
added template support for some hgweb output, also, template files for
jake@edge2.net
parents:
132
diff
changeset
|
36 |
|
258 | 37 |
self.mtime = -1 |
1172
3f30a5e7e15b
Use path relative to document root as reponame if published via a web server.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1170
diff
changeset
|
38 |
self.reponame = name |
1078 | 39 |
self.archives = 'zip', 'gz', 'bz2' |
2436
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
40 |
self.templatepath = self.repo.ui.config("web", "templates", |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
41 |
templater.templatepath()) |
131 | 42 |
|
258 | 43 |
def refresh(self): |
1418
68f81ba07b2a
Make hgweb work when the repository is empty (no 00changelog.i)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1416
diff
changeset
|
44 |
mtime = get_mtime(self.repo.root) |
68f81ba07b2a
Make hgweb work when the repository is empty (no 00changelog.i)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1416
diff
changeset
|
45 |
if mtime != self.mtime: |
68f81ba07b2a
Make hgweb work when the repository is empty (no 00changelog.i)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1416
diff
changeset
|
46 |
self.mtime = mtime |
1213 | 47 |
self.repo = hg.repository(self.repo.ui, self.repo.root) |
1275
a1a84dd489ff
Fix cut and paste error in hgweb.py
Florian La Roche <laroche@redhat.com>
parents:
1260
diff
changeset
|
48 |
self.maxchanges = int(self.repo.ui.config("web", "maxchanges", 10)) |
a1a84dd489ff
Fix cut and paste error in hgweb.py
Florian La Roche <laroche@redhat.com>
parents:
1260
diff
changeset
|
49 |
self.maxfiles = int(self.repo.ui.config("web", "maxfiles", 10)) |
964
3f37720e7dc7
hgweb: Make maxfiles, maxchanges, and allowpull proper config options
mpm@selenic.com
parents:
957
diff
changeset
|
50 |
self.allowpull = self.repo.ui.configbool("web", "allowpull", True) |
258 | 51 |
|
1498
78590fb4a82b
hgweb: Added archive download buttons to manifest page.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1473
diff
changeset
|
52 |
def archivelist(self, nodeid): |
2359
a392eaa81f29
Allow comma to separate types in allow_archive, too. Use longer variable name.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2358
diff
changeset
|
53 |
allowed = (self.repo.ui.config("web", "allow_archive", "") |
a392eaa81f29
Allow comma to separate types in allow_archive, too. Use longer variable name.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2358
diff
changeset
|
54 |
.replace(",", " ").split()) |
1498
78590fb4a82b
hgweb: Added archive download buttons to manifest page.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1473
diff
changeset
|
55 |
for i in self.archives: |
2359
a392eaa81f29
Allow comma to separate types in allow_archive, too. Use longer variable name.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2358
diff
changeset
|
56 |
if i in allowed or self.repo.ui.configbool("web", "allow" + i): |
2171
290534ee163c
Add download links to hgwebdir index page for allowed archive types.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2170
diff
changeset
|
57 |
yield {"type" : i, "node" : nodeid, "url": ""} |
1498
78590fb4a82b
hgweb: Added archive download buttons to manifest page.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1473
diff
changeset
|
58 |
|
138 | 59 |
def listfiles(self, files, mf): |
60 |
for f in files[:self.maxfiles]: |
|
1062 | 61 |
yield self.t("filenodelink", node=hex(mf[f]), file=f) |
138 | 62 |
if len(files) > self.maxfiles: |
63 |
yield self.t("fileellipses") |
|
64 |
||
65 |
def listfilediffs(self, files, changeset): |
|
66 |
for f in files[:self.maxfiles]: |
|
1062 | 67 |
yield self.t("filedifflink", node=hex(changeset), file=f) |
138 | 68 |
if len(files) > self.maxfiles: |
69 |
yield self.t("fileellipses") |
|
70 |
||
1606
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
71 |
def siblings(self, siblings=[], rev=None, hiderev=None, **args): |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
72 |
if not rev: |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
73 |
rev = lambda x: "" |
1606
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
74 |
siblings = [s for s in siblings if s != nullid] |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
75 |
if len(siblings) == 1 and rev(siblings[0]) == hiderev: |
1416
19d2776f1725
hgweb: hide trivial parent (like in show_changeset)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1411
diff
changeset
|
76 |
return |
1606
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
77 |
for s in siblings: |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
78 |
yield dict(node=hex(s), rev=rev(s), **args) |
569
3e347929f5f9
[PATCH 1/5]: cleaning the template parent management in hgweb
mpm@selenic.com
parents:
568
diff
changeset
|
79 |
|
1653
e8a3df8b62b3
hgweb: show copy/rename links in file history
Matt Mackall <mpm@selenic.com>
parents:
1650
diff
changeset
|
80 |
def renamelink(self, fl, node): |
e8a3df8b62b3
hgweb: show copy/rename links in file history
Matt Mackall <mpm@selenic.com>
parents:
1650
diff
changeset
|
81 |
r = fl.renamed(node) |
e8a3df8b62b3
hgweb: show copy/rename links in file history
Matt Mackall <mpm@selenic.com>
parents:
1650
diff
changeset
|
82 |
if r: |
e8a3df8b62b3
hgweb: show copy/rename links in file history
Matt Mackall <mpm@selenic.com>
parents:
1650
diff
changeset
|
83 |
return [dict(file=r[0], node=hex(r[1]))] |
e8a3df8b62b3
hgweb: show copy/rename links in file history
Matt Mackall <mpm@selenic.com>
parents:
1650
diff
changeset
|
84 |
return [] |
e8a3df8b62b3
hgweb: show copy/rename links in file history
Matt Mackall <mpm@selenic.com>
parents:
1650
diff
changeset
|
85 |
|
568 | 86 |
def showtag(self, t1, node=nullid, **args): |
87 |
for t in self.repo.nodetags(node): |
|
1062 | 88 |
yield self.t(t1, tag=t, **args) |
568 | 89 |
|
138 | 90 |
def diff(self, node1, node2, files): |
1626
f2b1df3dbcbb
make the order of the arguments for filterfiles consistent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
91 |
def filterfiles(filters, files): |
1627
11cd38286fdb
fix for hgweb.filterfiles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1626
diff
changeset
|
92 |
l = [x for x in files if x in filters] |
515 | 93 |
|
1626
f2b1df3dbcbb
make the order of the arguments for filterfiles consistent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
94 |
for t in filters: |
1627
11cd38286fdb
fix for hgweb.filterfiles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1626
diff
changeset
|
95 |
if t and t[-1] != os.sep: |
1626
f2b1df3dbcbb
make the order of the arguments for filterfiles consistent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
96 |
t += os.sep |
f2b1df3dbcbb
make the order of the arguments for filterfiles consistent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
97 |
l += [x for x in files if x.startswith(t)] |
138 | 98 |
return l |
131 | 99 |
|
172
e9b1147db448
hgweb: alternating colors for multifile diffs
mpm@selenic.com
parents:
168
diff
changeset
|
100 |
parity = [0] |
e9b1147db448
hgweb: alternating colors for multifile diffs
mpm@selenic.com
parents:
168
diff
changeset
|
101 |
def diffblock(diff, f, fn): |
e9b1147db448
hgweb: alternating colors for multifile diffs
mpm@selenic.com
parents:
168
diff
changeset
|
102 |
yield self.t("diffblock", |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
103 |
lines=prettyprintlines(diff), |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
104 |
parity=parity[0], |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
105 |
file=f, |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
106 |
filenode=hex(fn or nullid)) |
172
e9b1147db448
hgweb: alternating colors for multifile diffs
mpm@selenic.com
parents:
168
diff
changeset
|
107 |
parity[0] = 1 - parity[0] |
515 | 108 |
|
172
e9b1147db448
hgweb: alternating colors for multifile diffs
mpm@selenic.com
parents:
168
diff
changeset
|
109 |
def prettyprintlines(diff): |
138 | 110 |
for l in diff.splitlines(1): |
201
f918a6fa2572
hgweb: add template filters, template style maps, and raw pages
mpm@selenic.com
parents:
198
diff
changeset
|
111 |
if l.startswith('+'): |
1062 | 112 |
yield self.t("difflineplus", line=l) |
201
f918a6fa2572
hgweb: add template filters, template style maps, and raw pages
mpm@selenic.com
parents:
198
diff
changeset
|
113 |
elif l.startswith('-'): |
1062 | 114 |
yield self.t("difflineminus", line=l) |
201
f918a6fa2572
hgweb: add template filters, template style maps, and raw pages
mpm@selenic.com
parents:
198
diff
changeset
|
115 |
elif l.startswith('@'): |
1062 | 116 |
yield self.t("difflineat", line=l) |
138 | 117 |
else: |
1062 | 118 |
yield self.t("diffline", line=l) |
131 | 119 |
|
138 | 120 |
r = self.repo |
121 |
cl = r.changelog |
|
122 |
mf = r.manifest |
|
123 |
change1 = cl.read(node1) |
|
124 |
change2 = cl.read(node2) |
|
125 |
mmap1 = mf.read(change1[0]) |
|
126 |
mmap2 = mf.read(change2[0]) |
|
1333
901c645c1943
hgweb: fix date bug in hgweb diff generation
mpm@selenic.com
parents:
1324
diff
changeset
|
127 |
date1 = util.datestr(change1[2]) |
901c645c1943
hgweb: fix date bug in hgweb diff generation
mpm@selenic.com
parents:
1324
diff
changeset
|
128 |
date2 = util.datestr(change2[2]) |
131 | 129 |
|
1619
1ba0d7041ac4
Distinguish removed and deleted files. Tests are not fixed yet.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1618
diff
changeset
|
130 |
modified, added, removed, deleted, unknown = r.changes(node1, node2) |
645
a55048b2ae3a
this patch permits hgweb to show the deleted files in the changeset diff
kreijack@inwind.REMOVEME.it
parents:
635
diff
changeset
|
131 |
if files: |
1626
f2b1df3dbcbb
make the order of the arguments for filterfiles consistent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1619
diff
changeset
|
132 |
modified, added, removed = map(lambda x: filterfiles(files, x), |
1618
ff339dd21976
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1606
diff
changeset
|
133 |
(modified, added, removed)) |
131 | 134 |
|
1637 | 135 |
diffopts = self.repo.ui.diffopts() |
136 |
showfunc = diffopts['showfunc'] |
|
137 |
ignorews = diffopts['ignorews'] |
|
1618
ff339dd21976
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1606
diff
changeset
|
138 |
for f in modified: |
138 | 139 |
to = r.file(f).read(mmap1[f]) |
140 |
tn = r.file(f).read(mmap2[f]) |
|
1637 | 141 |
yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, |
142 |
showfunc=showfunc, ignorews=ignorews), f, tn) |
|
1618
ff339dd21976
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1606
diff
changeset
|
143 |
for f in added: |
265
7ca05593bd30
hgweb: fix non-existent source or destination for diff
mpm@selenic.com
parents:
258
diff
changeset
|
144 |
to = None |
138 | 145 |
tn = r.file(f).read(mmap2[f]) |
1637 | 146 |
yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, |
147 |
showfunc=showfunc, ignorews=ignorews), f, tn) |
|
1618
ff339dd21976
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1606
diff
changeset
|
148 |
for f in removed: |
138 | 149 |
to = r.file(f).read(mmap1[f]) |
265
7ca05593bd30
hgweb: fix non-existent source or destination for diff
mpm@selenic.com
parents:
258
diff
changeset
|
150 |
tn = None |
1637 | 151 |
yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, |
152 |
showfunc=showfunc, ignorews=ignorews), f, tn) |
|
131 | 153 |
|
180 | 154 |
def changelog(self, pos): |
857
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
155 |
def changenav(**map): |
1703
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
156 |
def seq(factor, maxchanges=None): |
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
157 |
if maxchanges: |
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
158 |
yield maxchanges |
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
159 |
if maxchanges >= 20 and maxchanges <= 40: |
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
160 |
yield 50 |
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
161 |
else: |
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
162 |
yield 1 * factor |
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
163 |
yield 3 * factor |
138 | 164 |
for f in seq(factor * 10): |
165 |
yield f |
|
131 | 166 |
|
173
8da1df932c16
hgweb: make navigation of changesets a bit nicer
mpm@selenic.com
parents:
172
diff
changeset
|
167 |
l = [] |
1703
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
168 |
last = 0 |
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
169 |
for f in seq(1, self.maxchanges): |
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
170 |
if f < self.maxchanges or f <= last: |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
171 |
continue |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
172 |
if f > count: |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
173 |
break |
1703
41d884f741ca
fix changenav for maxchanges != 10
Johannes Stezenbach <js@linuxtv.org>
parents:
1653
diff
changeset
|
174 |
last = f |
173
8da1df932c16
hgweb: make navigation of changesets a bit nicer
mpm@selenic.com
parents:
172
diff
changeset
|
175 |
r = "%d" % f |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
176 |
if pos + f < count: |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
177 |
l.append(("+" + r, pos + f)) |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
178 |
if pos - f >= 0: |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
179 |
l.insert(0, ("-" + r, pos - f)) |
173
8da1df932c16
hgweb: make navigation of changesets a bit nicer
mpm@selenic.com
parents:
172
diff
changeset
|
180 |
|
975
bdd7c53fca00
hgweb: Changed changelog page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
974
diff
changeset
|
181 |
yield {"rev": 0, "label": "(0)"} |
515 | 182 |
|
173
8da1df932c16
hgweb: make navigation of changesets a bit nicer
mpm@selenic.com
parents:
172
diff
changeset
|
183 |
for label, rev in l: |
975
bdd7c53fca00
hgweb: Changed changelog page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
974
diff
changeset
|
184 |
yield {"label": label, "rev": rev} |
173
8da1df932c16
hgweb: make navigation of changesets a bit nicer
mpm@selenic.com
parents:
172
diff
changeset
|
185 |
|
1409
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
186 |
yield {"label": "tip", "rev": "tip"} |
131 | 187 |
|
857
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
188 |
def changelist(**map): |
142 | 189 |
parity = (start - end) & 1 |
138 | 190 |
cl = self.repo.changelog |
191 |
l = [] # build a list in forward order for efficiency |
|
351 | 192 |
for i in range(start, end): |
138 | 193 |
n = cl.node(i) |
194 |
changes = cl.read(n) |
|
195 |
hn = hex(n) |
|
131 | 196 |
|
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
197 |
l.insert(0, {"parity": parity, |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
198 |
"author": changes[1], |
1606
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
199 |
"parent": self.siblings(cl.parents(n), cl.rev, |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
200 |
cl.rev(n) - 1), |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
201 |
"child": self.siblings(cl.children(n), cl.rev, |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
202 |
cl.rev(n) + 1), |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
203 |
"changelogtag": self.showtag("changelogtag",n), |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
204 |
"manifest": hex(changes[0]), |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
205 |
"desc": changes[4], |
1324
77cd8068dbf4
hgweb: pass date tuples around rather than whole changesets for dates
mpm@selenic.com
parents:
1321
diff
changeset
|
206 |
"date": changes[2], |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
207 |
"files": self.listfilediffs(changes[3], n), |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
208 |
"rev": i, |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
209 |
"node": hn}) |
142 | 210 |
parity = 1 - parity |
138 | 211 |
|
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
212 |
for e in l: |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
213 |
yield e |
131 | 214 |
|
168 | 215 |
cl = self.repo.changelog |
216 |
mf = cl.read(cl.tip())[0] |
|
217 |
count = cl.count() |
|
351 | 218 |
start = max(0, pos - self.maxchanges + 1) |
219 |
end = min(count, start + self.maxchanges) |
|
220 |
pos = end - 1 |
|
138 | 221 |
|
142 | 222 |
yield self.t('changelog', |
1062 | 223 |
changenav=changenav, |
224 |
manifest=hex(mf), |
|
2170
29eeb2717915
Add archive download links to tip on main changeset list page
Colin McMillen <mcmillen@cs.cmu.edu>
parents:
2148
diff
changeset
|
225 |
rev=pos, changesets=count, entries=changelist, |
29eeb2717915
Add archive download links to tip on main changeset list page
Colin McMillen <mcmillen@cs.cmu.edu>
parents:
2148
diff
changeset
|
226 |
archives=self.archivelist("tip")) |
131 | 227 |
|
538 | 228 |
def search(self, query): |
229 |
||
857
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
230 |
def changelist(**map): |
538 | 231 |
cl = self.repo.changelog |
232 |
count = 0 |
|
233 |
qw = query.lower().split() |
|
234 |
||
235 |
def revgen(): |
|
236 |
for i in range(cl.count() - 1, 0, -100): |
|
237 |
l = [] |
|
238 |
for j in range(max(0, i - 100), i): |
|
239 |
n = cl.node(j) |
|
240 |
changes = cl.read(n) |
|
1023 | 241 |
l.append((n, j, changes)) |
242 |
l.reverse() |
|
538 | 243 |
for e in l: |
244 |
yield e |
|
245 |
||
246 |
for n, i, changes in revgen(): |
|
247 |
miss = 0 |
|
248 |
for q in qw: |
|
249 |
if not (q in changes[1].lower() or |
|
250 |
q in changes[4].lower() or |
|
251 |
q in " ".join(changes[3][:20]).lower()): |
|
252 |
miss = 1 |
|
253 |
break |
|
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
254 |
if miss: |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
255 |
continue |
538 | 256 |
|
257 |
count += 1 |
|
258 |
hn = hex(n) |
|
259 |
||
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
260 |
yield self.t('searchentry', |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
261 |
parity=count & 1, |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
262 |
author=changes[1], |
1606
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
263 |
parent=self.siblings(cl.parents(n), cl.rev), |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
264 |
child=self.siblings(cl.children(n), cl.rev), |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
265 |
changelogtag=self.showtag("changelogtag",n), |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
266 |
manifest=hex(changes[0]), |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
267 |
desc=changes[4], |
1324
77cd8068dbf4
hgweb: pass date tuples around rather than whole changesets for dates
mpm@selenic.com
parents:
1321
diff
changeset
|
268 |
date=changes[2], |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
269 |
files=self.listfilediffs(changes[3], n), |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
270 |
rev=i, |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
271 |
node=hn) |
538 | 272 |
|
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
273 |
if count >= self.maxchanges: |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
274 |
break |
538 | 275 |
|
276 |
cl = self.repo.changelog |
|
277 |
mf = cl.read(cl.tip())[0] |
|
278 |
||
279 |
yield self.t('search', |
|
1062 | 280 |
query=query, |
281 |
manifest=hex(mf), |
|
282 |
entries=changelist) |
|
538 | 283 |
|
138 | 284 |
def changeset(self, nodeid): |
285 |
cl = self.repo.changelog |
|
1369
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
286 |
n = self.repo.lookup(nodeid) |
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
287 |
nodeid = hex(n) |
138 | 288 |
changes = cl.read(n) |
598
f8d44a2e6928
[PATCH 4/5]: cleaning the template parent management in hgweb
mpm@selenic.com
parents:
582
diff
changeset
|
289 |
p1 = cl.parents(n)[0] |
515 | 290 |
|
133
fb84d3e71042
added template support for some hgweb output, also, template files for
jake@edge2.net
parents:
132
diff
changeset
|
291 |
files = [] |
138 | 292 |
mf = self.repo.manifest.read(changes[0]) |
131 | 293 |
for f in changes[3]: |
138 | 294 |
files.append(self.t("filenodelink", |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
295 |
filenode=hex(mf.get(f, nullid)), file=f)) |
138 | 296 |
|
857
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
297 |
def diff(**map): |
645
a55048b2ae3a
this patch permits hgweb to show the deleted files in the changeset diff
kreijack@inwind.REMOVEME.it
parents:
635
diff
changeset
|
298 |
yield self.diff(p1, n, None) |
131 | 299 |
|
138 | 300 |
yield self.t('changeset', |
1062 | 301 |
diff=diff, |
302 |
rev=cl.rev(n), |
|
303 |
node=nodeid, |
|
1606
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
304 |
parent=self.siblings(cl.parents(n), cl.rev), |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
305 |
child=self.siblings(cl.children(n), cl.rev), |
1062 | 306 |
changesettag=self.showtag("changesettag",n), |
307 |
manifest=hex(changes[0]), |
|
308 |
author=changes[1], |
|
309 |
desc=changes[4], |
|
1324
77cd8068dbf4
hgweb: pass date tuples around rather than whole changesets for dates
mpm@selenic.com
parents:
1321
diff
changeset
|
310 |
date=changes[2], |
1076
01db658cc78a
tarball support v0.3
Wojciech Milkowski <wmilkowski@interia.pl>
parents:
1073
diff
changeset
|
311 |
files=files, |
1498
78590fb4a82b
hgweb: Added archive download buttons to manifest page.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1473
diff
changeset
|
312 |
archives=self.archivelist(nodeid)) |
131 | 313 |
|
138 | 314 |
def filelog(self, f, filenode): |
315 |
cl = self.repo.changelog |
|
316 |
fl = self.repo.file(f) |
|
1369
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
317 |
filenode = hex(fl.lookup(filenode)) |
138 | 318 |
count = fl.count() |
319 |
||
857
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
320 |
def entries(**map): |
138 | 321 |
l = [] |
142 | 322 |
parity = (count - 1) & 1 |
515 | 323 |
|
138 | 324 |
for i in range(count): |
325 |
n = fl.node(i) |
|
326 |
lr = fl.linkrev(n) |
|
327 |
cn = cl.node(lr) |
|
328 |
cs = cl.read(cl.node(lr)) |
|
133
fb84d3e71042
added template support for some hgweb output, also, template files for
jake@edge2.net
parents:
132
diff
changeset
|
329 |
|
978
ea67e5b37043
hgweb: Changed file revision page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
977
diff
changeset
|
330 |
l.insert(0, {"parity": parity, |
ea67e5b37043
hgweb: Changed file revision page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
977
diff
changeset
|
331 |
"filenode": hex(n), |
ea67e5b37043
hgweb: Changed file revision page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
977
diff
changeset
|
332 |
"filerev": i, |
ea67e5b37043
hgweb: Changed file revision page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
977
diff
changeset
|
333 |
"file": f, |
ea67e5b37043
hgweb: Changed file revision page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
977
diff
changeset
|
334 |
"node": hex(cn), |
ea67e5b37043
hgweb: Changed file revision page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
977
diff
changeset
|
335 |
"author": cs[1], |
1324
77cd8068dbf4
hgweb: pass date tuples around rather than whole changesets for dates
mpm@selenic.com
parents:
1321
diff
changeset
|
336 |
"date": cs[2], |
1653
e8a3df8b62b3
hgweb: show copy/rename links in file history
Matt Mackall <mpm@selenic.com>
parents:
1650
diff
changeset
|
337 |
"rename": self.renamelink(fl, n), |
1606
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
338 |
"parent": self.siblings(fl.parents(n), |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
339 |
fl.rev, file=f), |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
340 |
"child": self.siblings(fl.children(n), |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
341 |
fl.rev, file=f), |
978
ea67e5b37043
hgweb: Changed file revision page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
977
diff
changeset
|
342 |
"desc": cs[4]}) |
142 | 343 |
parity = 1 - parity |
138 | 344 |
|
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
345 |
for e in l: |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
346 |
yield e |
138 | 347 |
|
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
348 |
yield self.t("filelog", file=f, filenode=filenode, entries=entries) |
131 | 349 |
|
138 | 350 |
def filerevision(self, f, node): |
351 |
fl = self.repo.file(f) |
|
1369
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
352 |
n = fl.lookup(node) |
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
353 |
node = hex(n) |
201
f918a6fa2572
hgweb: add template filters, template style maps, and raw pages
mpm@selenic.com
parents:
198
diff
changeset
|
354 |
text = fl.read(n) |
138 | 355 |
changerev = fl.linkrev(n) |
356 |
cl = self.repo.changelog |
|
357 |
cn = cl.node(changerev) |
|
358 |
cs = cl.read(cn) |
|
359 |
mfn = cs[0] |
|
142 | 360 |
|
1411
e2ba788545bf
hgweb: make viewing of non-text work in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1409
diff
changeset
|
361 |
mt = mimetypes.guess_type(f)[0] |
e2ba788545bf
hgweb: make viewing of non-text work in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1409
diff
changeset
|
362 |
rawtext = text |
e2ba788545bf
hgweb: make viewing of non-text work in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1409
diff
changeset
|
363 |
if util.binary(text): |
2103
caccf539c9a4
Use application/octet-stream as the content-type of unknown binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2095
diff
changeset
|
364 |
mt = mt or 'application/octet-stream' |
caccf539c9a4
Use application/octet-stream as the content-type of unknown binary files
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2095
diff
changeset
|
365 |
text = "(binary:%s)" % mt |
2095
0bf2a9e5eff1
Don't send "Content-Type: none"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1964
diff
changeset
|
366 |
mt = mt or 'text/plain' |
1411
e2ba788545bf
hgweb: make viewing of non-text work in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1409
diff
changeset
|
367 |
|
142 | 368 |
def lines(): |
369 |
for l, t in enumerate(text.splitlines(1)): |
|
976
5d5ab159d197
hgweb: Changed file page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
975
diff
changeset
|
370 |
yield {"line": t, |
5d5ab159d197
hgweb: Changed file page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
975
diff
changeset
|
371 |
"linenumber": "% 6d" % (l + 1), |
5d5ab159d197
hgweb: Changed file page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
975
diff
changeset
|
372 |
"parity": l & 1} |
359 | 373 |
|
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
374 |
yield self.t("filerevision", |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
375 |
file=f, |
1062 | 376 |
filenode=node, |
2356
2db831b33e8f
Final stage of the hgweb split up.
Eric Hopper <hopper@omnifarious.org>
parents:
2355
diff
changeset
|
377 |
path=_up(f), |
1062 | 378 |
text=lines(), |
1411
e2ba788545bf
hgweb: make viewing of non-text work in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1409
diff
changeset
|
379 |
raw=rawtext, |
e2ba788545bf
hgweb: make viewing of non-text work in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1409
diff
changeset
|
380 |
mimetype=mt, |
1062 | 381 |
rev=changerev, |
382 |
node=hex(cn), |
|
383 |
manifest=hex(mfn), |
|
384 |
author=cs[1], |
|
1324
77cd8068dbf4
hgweb: pass date tuples around rather than whole changesets for dates
mpm@selenic.com
parents:
1321
diff
changeset
|
385 |
date=cs[2], |
1606
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
386 |
parent=self.siblings(fl.parents(n), fl.rev, file=f), |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
387 |
child=self.siblings(fl.children(n), fl.rev, file=f), |
1653
e8a3df8b62b3
hgweb: show copy/rename links in file history
Matt Mackall <mpm@selenic.com>
parents:
1650
diff
changeset
|
388 |
rename=self.renamelink(fl, n), |
1062 | 389 |
permissions=self.repo.manifest.readflags(mfn)[f]) |
138 | 390 |
|
391 |
def fileannotate(self, f, node): |
|
392 |
bcache = {} |
|
393 |
ncache = {} |
|
394 |
fl = self.repo.file(f) |
|
1369
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
395 |
n = fl.lookup(node) |
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
396 |
node = hex(n) |
138 | 397 |
changerev = fl.linkrev(n) |
398 |
||
399 |
cl = self.repo.changelog |
|
400 |
cn = cl.node(changerev) |
|
401 |
cs = cl.read(cn) |
|
402 |
mfn = cs[0] |
|
131 | 403 |
|
857
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
404 |
def annotate(**map): |
142 | 405 |
parity = 1 |
406 |
last = None |
|
138 | 407 |
for r, l in fl.annotate(n): |
408 |
try: |
|
409 |
cnode = ncache[r] |
|
410 |
except KeyError: |
|
411 |
cnode = ncache[r] = self.repo.changelog.node(r) |
|
515 | 412 |
|
138 | 413 |
try: |
414 |
name = bcache[r] |
|
415 |
except KeyError: |
|
416 |
cl = self.repo.changelog.read(cnode) |
|
1129
ee4f60abad93
Move generating short username to display in hg/hgweb annotate to ui module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1123
diff
changeset
|
417 |
bcache[r] = name = self.repo.ui.shortuser(cl[1]) |
131 | 418 |
|
142 | 419 |
if last != cnode: |
420 |
parity = 1 - parity |
|
421 |
last = cnode |
|
422 |
||
977
289975641886
hgweb: Changed annotate page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
976
diff
changeset
|
423 |
yield {"parity": parity, |
289975641886
hgweb: Changed annotate page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
976
diff
changeset
|
424 |
"node": hex(cnode), |
289975641886
hgweb: Changed annotate page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
976
diff
changeset
|
425 |
"rev": r, |
289975641886
hgweb: Changed annotate page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
976
diff
changeset
|
426 |
"author": name, |
289975641886
hgweb: Changed annotate page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
976
diff
changeset
|
427 |
"file": f, |
289975641886
hgweb: Changed annotate page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
976
diff
changeset
|
428 |
"line": l} |
138 | 429 |
|
430 |
yield self.t("fileannotate", |
|
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
431 |
file=f, |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
432 |
filenode=node, |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
433 |
annotate=annotate, |
2356
2db831b33e8f
Final stage of the hgweb split up.
Eric Hopper <hopper@omnifarious.org>
parents:
2355
diff
changeset
|
434 |
path=_up(f), |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
435 |
rev=changerev, |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
436 |
node=hex(cn), |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
437 |
manifest=hex(mfn), |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
438 |
author=cs[1], |
1324
77cd8068dbf4
hgweb: pass date tuples around rather than whole changesets for dates
mpm@selenic.com
parents:
1321
diff
changeset
|
439 |
date=cs[2], |
1653
e8a3df8b62b3
hgweb: show copy/rename links in file history
Matt Mackall <mpm@selenic.com>
parents:
1650
diff
changeset
|
440 |
rename=self.renamelink(fl, n), |
1606
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
441 |
parent=self.siblings(fl.parents(n), fl.rev, file=f), |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
442 |
child=self.siblings(fl.children(n), fl.rev, file=f), |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
443 |
permissions=self.repo.manifest.readflags(mfn)[f]) |
136 | 444 |
|
138 | 445 |
def manifest(self, mnode, path): |
1369
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
446 |
man = self.repo.manifest |
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
447 |
mn = man.lookup(mnode) |
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
448 |
mnode = hex(mn) |
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
449 |
mf = man.read(mn) |
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
450 |
rev = man.rev(mn) |
2328
f789602ba840
hgweb.manifest: revno of manifest and changelog aren't always the same
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2311
diff
changeset
|
451 |
changerev = man.linkrev(mn) |
f789602ba840
hgweb.manifest: revno of manifest and changelog aren't always the same
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2311
diff
changeset
|
452 |
node = self.repo.changelog.node(changerev) |
1369
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
453 |
mff = man.readflags(mn) |
138 | 454 |
|
455 |
files = {} |
|
515 | 456 |
|
138 | 457 |
p = path[1:] |
1649
beb7da710c8a
hgweb: fix breakage on manifest subdirs from path cleaning
Matt Mackall <mpm@selenic.com>
parents:
1646
diff
changeset
|
458 |
if p and p[-1] != "/": |
beb7da710c8a
hgweb: fix breakage on manifest subdirs from path cleaning
Matt Mackall <mpm@selenic.com>
parents:
1646
diff
changeset
|
459 |
p += "/" |
138 | 460 |
l = len(p) |
131 | 461 |
|
138 | 462 |
for f,n in mf.items(): |
463 |
if f[:l] != p: |
|
464 |
continue |
|
465 |
remain = f[l:] |
|
466 |
if "/" in remain: |
|
467 |
short = remain[:remain.find("/") + 1] # bleah |
|
142 | 468 |
files[short] = (f, None) |
138 | 469 |
else: |
470 |
short = os.path.basename(remain) |
|
471 |
files[short] = (f, n) |
|
131 | 472 |
|
857
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
473 |
def filelist(**map): |
142 | 474 |
parity = 0 |
138 | 475 |
fl = files.keys() |
476 |
fl.sort() |
|
477 |
for f in fl: |
|
478 |
full, fnode = files[f] |
|
979
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
479 |
if not fnode: |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
480 |
continue |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
481 |
|
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
482 |
yield {"file": full, |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
483 |
"manifest": mnode, |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
484 |
"filenode": hex(fnode), |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
485 |
"parity": parity, |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
486 |
"basename": f, |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
487 |
"permissions": mff[full]} |
142 | 488 |
parity = 1 - parity |
138 | 489 |
|
979
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
490 |
def dirlist(**map): |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
491 |
parity = 0 |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
492 |
fl = files.keys() |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
493 |
fl.sort() |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
494 |
for f in fl: |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
495 |
full, fnode = files[f] |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
496 |
if fnode: |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
497 |
continue |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
498 |
|
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
499 |
yield {"parity": parity, |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
500 |
"path": os.path.join(path, f), |
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
501 |
"manifest": mnode, |
980 | 502 |
"basename": f[:-1]} |
979
87d40e085e08
hgweb: Changed manifest page to list format syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
978
diff
changeset
|
503 |
parity = 1 - parity |
982
8d2e24bae760
hgweb: convert index entries to list expansion style
mpm@selenic.com
parents:
981
diff
changeset
|
504 |
|
138 | 505 |
yield self.t("manifest", |
1062 | 506 |
manifest=mnode, |
507 |
rev=rev, |
|
508 |
node=hex(node), |
|
509 |
path=path, |
|
2356
2db831b33e8f
Final stage of the hgweb split up.
Eric Hopper <hopper@omnifarious.org>
parents:
2355
diff
changeset
|
510 |
up=_up(path), |
1062 | 511 |
fentries=filelist, |
1498
78590fb4a82b
hgweb: Added archive download buttons to manifest page.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1473
diff
changeset
|
512 |
dentries=dirlist, |
78590fb4a82b
hgweb: Added archive download buttons to manifest page.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1473
diff
changeset
|
513 |
archives=self.archivelist(hex(node))) |
131 | 514 |
|
168 | 515 |
def tags(self): |
516 |
cl = self.repo.changelog |
|
517 |
mf = cl.read(cl.tip())[0] |
|
518 |
||
343 | 519 |
i = self.repo.tagslist() |
520 |
i.reverse() |
|
168 | 521 |
|
1767
adbc392dfd9e
implement entriesnotip for tags in hgweb.py ; change entries to entriesnotip in templates/tags-rss.tmpl
Peter van Dijk <peter@dataloss.nl>
parents:
1653
diff
changeset
|
522 |
def entries(notip=False, **map): |
168 | 523 |
parity = 0 |
524 |
for k,n in i: |
|
1767
adbc392dfd9e
implement entriesnotip for tags in hgweb.py ; change entries to entriesnotip in templates/tags-rss.tmpl
Peter van Dijk <peter@dataloss.nl>
parents:
1653
diff
changeset
|
525 |
if notip and k == "tip": continue |
974
aedb47764f29
Added support for #foo%bar# syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
938
diff
changeset
|
526 |
yield {"parity": parity, |
aedb47764f29
Added support for #foo%bar# syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
938
diff
changeset
|
527 |
"tag": k, |
1579
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
528 |
"tagmanifest": hex(cl.read(n)[0]), |
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
529 |
"date": cl.read(n)[2], |
974
aedb47764f29
Added support for #foo%bar# syntax
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
938
diff
changeset
|
530 |
"node": hex(n)} |
168 | 531 |
parity = 1 - parity |
532 |
||
533 |
yield self.t("tags", |
|
1062 | 534 |
manifest=hex(mf), |
1767
adbc392dfd9e
implement entriesnotip for tags in hgweb.py ; change entries to entriesnotip in templates/tags-rss.tmpl
Peter van Dijk <peter@dataloss.nl>
parents:
1653
diff
changeset
|
535 |
entries=lambda **x: entries(False, **x), |
adbc392dfd9e
implement entriesnotip for tags in hgweb.py ; change entries to entriesnotip in templates/tags-rss.tmpl
Peter van Dijk <peter@dataloss.nl>
parents:
1653
diff
changeset
|
536 |
entriesnotip=lambda **x: entries(True, **x)) |
168 | 537 |
|
1572
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
538 |
def summary(self): |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
539 |
cl = self.repo.changelog |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
540 |
mf = cl.read(cl.tip())[0] |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
541 |
|
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
542 |
i = self.repo.tagslist() |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
543 |
i.reverse() |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
544 |
|
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
545 |
def tagentries(**map): |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
546 |
parity = 0 |
1579
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
547 |
count = 0 |
1572
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
548 |
for k,n in i: |
1579
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
549 |
if k == "tip": # skip tip |
1572
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
550 |
continue; |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
551 |
|
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
552 |
count += 1 |
1579
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
553 |
if count > 10: # limit to 10 tags |
1572
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
554 |
break; |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
555 |
|
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
556 |
c = cl.read(n) |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
557 |
m = c[0] |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
558 |
t = c[2] |
1579
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
559 |
|
1572
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
560 |
yield self.t("tagentry", |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
561 |
parity = parity, |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
562 |
tag = k, |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
563 |
node = hex(n), |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
564 |
date = t, |
1575
0a1cca912fda
[hgweb] gitweb style: File annotate converted, file revision made more like the deafault style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1574
diff
changeset
|
565 |
tagmanifest = hex(m)) |
1572
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
566 |
parity = 1 - parity |
1579
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
567 |
|
1572
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
568 |
def changelist(**map): |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
569 |
parity = 0 |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
570 |
cl = self.repo.changelog |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
571 |
l = [] # build a list in forward order for efficiency |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
572 |
for i in range(start, end): |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
573 |
n = cl.node(i) |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
574 |
changes = cl.read(n) |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
575 |
hn = hex(n) |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
576 |
t = changes[2] |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
577 |
|
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
578 |
l.insert(0, self.t( |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
579 |
'shortlogentry', |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
580 |
parity = parity, |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
581 |
author = changes[1], |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
582 |
manifest = hex(changes[0]), |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
583 |
desc = changes[4], |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
584 |
date = t, |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
585 |
rev = i, |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
586 |
node = hn)) |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
587 |
parity = 1 - parity |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
588 |
|
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
589 |
yield l |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
590 |
|
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
591 |
cl = self.repo.changelog |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
592 |
mf = cl.read(cl.tip())[0] |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
593 |
count = cl.count() |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
594 |
start = max(0, count - self.maxchanges) |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
595 |
end = min(count, start + self.maxchanges) |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
596 |
|
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
597 |
yield self.t("summary", |
1579
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
598 |
desc = self.repo.ui.config("web", "description", "unknown"), |
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
599 |
owner = (self.repo.ui.config("ui", "username") or # preferred |
1572
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
600 |
self.repo.ui.config("web", "contact") or # deprecated |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
601 |
self.repo.ui.config("web", "author", "unknown")), # also |
1579
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
602 |
lastchange = (0, 0), # FIXME |
1572
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
603 |
manifest = hex(mf), |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
604 |
tags = tagentries, |
385b8872b8e3
[hgweb] Initial import of the "gitweb" style
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1559
diff
changeset
|
605 |
shortlog = changelist) |
1579
85803ec2daab
Remove tabs, and trailing whitespace from hgweb.py
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1575
diff
changeset
|
606 |
|
138 | 607 |
def filediff(self, file, changeset): |
608 |
cl = self.repo.changelog |
|
1369
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
609 |
n = self.repo.lookup(changeset) |
b6d4ebebc35c
Allows abbreviated hashes in hgweb
Matt Mackall <mpm@selenic.com>
parents:
1348
diff
changeset
|
610 |
changeset = hex(n) |
138 | 611 |
p1 = cl.parents(n)[0] |
612 |
cs = cl.read(n) |
|
613 |
mf = self.repo.manifest.read(cs[0]) |
|
515 | 614 |
|
857
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
615 |
def diff(**map): |
2275
714f4d25a7a9
Fix hgweb.filediff
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2174
diff
changeset
|
616 |
yield self.diff(p1, n, [file]) |
131 | 617 |
|
138 | 618 |
yield self.t("filediff", |
1062 | 619 |
file=file, |
620 |
filenode=hex(mf.get(file, nullid)), |
|
621 |
node=changeset, |
|
622 |
rev=self.repo.changelog.rev(n), |
|
1606
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
623 |
parent=self.siblings(cl.parents(n), cl.rev), |
ba625c8083d8
- duplicate the parent link logic to show child links
Muli Ben-Yehuda <mulix@mulix.org>
parents:
1579
diff
changeset
|
624 |
child=self.siblings(cl.children(n), cl.rev), |
1062 | 625 |
diff=diff) |
515 | 626 |
|
2113
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
627 |
archive_specs = { |
2361
d3adb454c5a9
Fix automatic decompression of tarballs with Firefox.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2359
diff
changeset
|
628 |
'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), |
d3adb454c5a9
Fix automatic decompression of tarballs with Firefox.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2359
diff
changeset
|
629 |
'gz': ('application/x-tar', 'tgz', '.tar.gz', None), |
2113
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
630 |
'zip': ('application/zip', 'zip', '.zip', None), |
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
631 |
} |
1076
01db658cc78a
tarball support v0.3
Wojciech Milkowski <wmilkowski@interia.pl>
parents:
1073
diff
changeset
|
632 |
|
2394
a8f1049d1d2d
hgweb: fix errors and warnings found by pychecker
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2391
diff
changeset
|
633 |
def archive(self, req, cnode, type_): |
2113
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
634 |
reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame)) |
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
635 |
name = "%s-%s" % (reponame, short(cnode)) |
2394
a8f1049d1d2d
hgweb: fix errors and warnings found by pychecker
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2391
diff
changeset
|
636 |
mimetype, artype, extension, encoding = self.archive_specs[type_] |
2113
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
637 |
headers = [('Content-type', mimetype), |
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
638 |
('Content-disposition', 'attachment; filename=%s%s' % |
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
639 |
(name, extension))] |
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
640 |
if encoding: |
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
641 |
headers.append(('Content-encoding', encoding)) |
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
642 |
req.header(headers) |
633d733e7b11
make hgweb use new archival module.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2103
diff
changeset
|
643 |
archival.archive(self.repo, req.out, cnode, artype, prefix=name) |
1076
01db658cc78a
tarball support v0.3
Wojciech Milkowski <wmilkowski@interia.pl>
parents:
1073
diff
changeset
|
644 |
|
138 | 645 |
# add tags to things |
646 |
# tags -> list of changesets corresponding to tags |
|
647 |
# find tag, changeset, file |
|
131 | 648 |
|
2436
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
649 |
def cleanpath(self, path): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
650 |
p = util.normpath(path) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
651 |
if p[:2] == "..": |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
652 |
raise Exception("suspicious path") |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
653 |
return p |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
654 |
|
1159
b6f5a947e62e
Change use of global sys.stdout, sys.stdin os.environ to a hgrequest object.
Vincent Wagelaar <vincent@ricardis.tudelft.nl>
parents:
1143
diff
changeset
|
655 |
def run(self, req=hgrequest()): |
857
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
656 |
def header(**map): |
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
657 |
yield self.t("header", **map) |
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
658 |
|
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
659 |
def footer(**map): |
2148
c72e618c1204
Add MOTD display to hgweb and hgwebdir.
Colin McMillen <mcmillen@cs.cmu.edu>
parents:
2127
diff
changeset
|
660 |
yield self.t("footer", |
c72e618c1204
Add MOTD display to hgweb and hgwebdir.
Colin McMillen <mcmillen@cs.cmu.edu>
parents:
2127
diff
changeset
|
661 |
motd=self.repo.ui.config("web", "motd", ""), |
c72e618c1204
Add MOTD display to hgweb and hgwebdir.
Colin McMillen <mcmillen@cs.cmu.edu>
parents:
2127
diff
changeset
|
662 |
**map) |
1409
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
663 |
|
1406
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
664 |
def expand_form(form): |
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
665 |
shortcuts = { |
1409
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
666 |
'cl': [('cmd', ['changelog']), ('rev', None)], |
1406
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
667 |
'cs': [('cmd', ['changeset']), ('node', None)], |
1409
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
668 |
'f': [('cmd', ['file']), ('filenode', None)], |
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
669 |
'fl': [('cmd', ['filelog']), ('filenode', None)], |
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
670 |
'fd': [('cmd', ['filediff']), ('node', None)], |
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
671 |
'fa': [('cmd', ['annotate']), ('filenode', None)], |
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
672 |
'mf': [('cmd', ['manifest']), ('manifest', None)], |
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
673 |
'ca': [('cmd', ['archive']), ('node', None)], |
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
674 |
'tags': [('cmd', ['tags'])], |
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
675 |
'tip': [('cmd', ['changeset']), ('node', ['tip'])], |
1777
a2316878f19d
[hgweb] Static content serving
Josef "Jeff" Sipek <jeffpc@optonline.net>
parents:
1703
diff
changeset
|
676 |
'static': [('cmd', ['static']), ('file', None)] |
1406
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
677 |
} |
1409
964baa35faf8
hgweb: add shortcuts for all the web commands / fix empty arg bug
Matt Mackall <mpm@selenic.com>
parents:
1407
diff
changeset
|
678 |
|
1406
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
679 |
for k in shortcuts.iterkeys(): |
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
680 |
if form.has_key(k): |
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
681 |
for name, value in shortcuts[k]: |
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
682 |
if value is None: |
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
683 |
value = form[k] |
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
684 |
form[name] = value |
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
685 |
del form[k] |
857
41b344235bb7
[PATCH] Propagate the template map though recursively
Jeff Sipek <jeffpc@optonline.net>
parents:
839
diff
changeset
|
686 |
|
258 | 687 |
self.refresh() |
132 | 688 |
|
1406
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
689 |
expand_form(req.form) |
34cb3957d875
hgweb: allow urls to be shorter by using shortcuts
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1402
diff
changeset
|
690 |
|
2436
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
691 |
m = os.path.join(self.templatepath, "map") |
986 | 692 |
style = self.repo.ui.config("web", "style", "") |
1159
b6f5a947e62e
Change use of global sys.stdout, sys.stdin os.environ to a hgrequest object.
Vincent Wagelaar <vincent@ricardis.tudelft.nl>
parents:
1143
diff
changeset
|
693 |
if req.form.has_key('style'): |
b6f5a947e62e
Change use of global sys.stdout, sys.stdin os.environ to a hgrequest object.
Vincent Wagelaar <vincent@ricardis.tudelft.nl>
parents:
1143
diff
changeset
|
694 |
style = req.form['style'][0] |
986 | 695 |
if style: |
696 |
b = os.path.basename("map-" + style) |
|
2436
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
697 |
p = os.path.join(self.templatepath, b) |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
698 |
if os.path.isfile(p): |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
699 |
m = p |
515 | 700 |
|
1159
b6f5a947e62e
Change use of global sys.stdout, sys.stdin os.environ to a hgrequest object.
Vincent Wagelaar <vincent@ricardis.tudelft.nl>
parents:
1143
diff
changeset
|
701 |
port = req.env["SERVER_PORT"] |
601 | 702 |
port = port != "80" and (":" + port) or "" |
1159
b6f5a947e62e
Change use of global sys.stdout, sys.stdin os.environ to a hgrequest object.
Vincent Wagelaar <vincent@ricardis.tudelft.nl>
parents:
1143
diff
changeset
|
703 |
uri = req.env["REQUEST_URI"] |
1063
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
704 |
if "?" in uri: |
58eefdfb8472
Some more spacing/indentation/linebreak cleanups to hgweb.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
705 |
uri = uri.split("?")[0] |
1159
b6f5a947e62e
Change use of global sys.stdout, sys.stdin os.environ to a hgrequest object.
Vincent Wagelaar <vincent@ricardis.tudelft.nl>
parents:
1143
diff
changeset
|
706 |
url = "http://%s%s%s" % (req.env["SERVER_NAME"], port, uri) |
1172
3f30a5e7e15b
Use path relative to document root as reponame if published via a web server.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1170
diff
changeset
|
707 |
if not self.reponame: |
3f30a5e7e15b
Use path relative to document root as reponame if published via a web server.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1170
diff
changeset
|
708 |
self.reponame = (self.repo.ui.config("web", "name") |
3f30a5e7e15b
Use path relative to document root as reponame if published via a web server.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1170
diff
changeset
|
709 |
or uri.strip('/') or self.repo.root) |
601 | 710 |
|
1896
f8f818a04f5b
move hgweb template code out to templater
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1796
diff
changeset
|
711 |
self.t = templater.templater(m, templater.common_filters, |
1964
778281d46bb2
fix template bug that made hgweb break.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1920
diff
changeset
|
712 |
defaults={"url": url, |
778281d46bb2
fix template bug that made hgweb break.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1920
diff
changeset
|
713 |
"repo": self.reponame, |
778281d46bb2
fix template bug that made hgweb break.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1920
diff
changeset
|
714 |
"header": header, |
778281d46bb2
fix template bug that made hgweb break.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1920
diff
changeset
|
715 |
"footer": footer, |
778281d46bb2
fix template bug that made hgweb break.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1920
diff
changeset
|
716 |
}) |
201
f918a6fa2572
hgweb: add template filters, template style maps, and raw pages
mpm@selenic.com
parents:
198
diff
changeset
|
717 |
|
1159
b6f5a947e62e
Change use of global sys.stdout, sys.stdin os.environ to a hgrequest object.
Vincent Wagelaar <vincent@ricardis.tudelft.nl>
parents:
1143
diff
changeset
|
718 |
if not req.form.has_key('cmd'): |
b6f5a947e62e
Change use of global sys.stdout, sys.stdin os.environ to a hgrequest object.
Vincent Wagelaar <vincent@ricardis.tudelft.nl>
parents:
1143
diff
changeset
|
719 |
req.form['cmd'] = [self.t.cache['default'],] |
937 | 720 |
|
2119
f62195054c5b
Cleaned hgweb.py a little bit
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
2113
diff
changeset
|
721 |
cmd = req.form['cmd'][0] |
575 | 722 |
|
2436
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
723 |
method = getattr(self, 'do_' + cmd, None) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
724 |
if method: |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
725 |
method(req) |
132 | 726 |
else: |
1159
b6f5a947e62e
Change use of global sys.stdout, sys.stdin os.environ to a hgrequest object.
Vincent Wagelaar <vincent@ricardis.tudelft.nl>
parents:
1143
diff
changeset
|
727 |
req.write(self.t("error")) |
2434
a2df85adface
http server: support persistent connections.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2394
diff
changeset
|
728 |
req.done() |
2436
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
729 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
730 |
def do_changelog(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
731 |
hi = self.repo.changelog.count() - 1 |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
732 |
if req.form.has_key('rev'): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
733 |
hi = req.form['rev'][0] |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
734 |
try: |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
735 |
hi = self.repo.changelog.rev(self.repo.lookup(hi)) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
736 |
except hg.RepoError: |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
737 |
req.write(self.search(hi)) # XXX redirect to 404 page? |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
738 |
return |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
739 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
740 |
req.write(self.changelog(hi)) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
741 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
742 |
def do_changeset(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
743 |
req.write(self.changeset(req.form['node'][0])) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
744 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
745 |
def do_manifest(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
746 |
req.write(self.manifest(req.form['manifest'][0], |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
747 |
self.cleanpath(req.form['path'][0]))) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
748 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
749 |
def do_tags(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
750 |
req.write(self.tags()) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
751 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
752 |
def do_summary(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
753 |
req.write(self.summary()) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
754 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
755 |
def do_filediff(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
756 |
req.write(self.filediff(self.cleanpath(req.form['file'][0]), |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
757 |
req.form['node'][0])) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
758 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
759 |
def do_file(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
760 |
req.write(self.filerevision(self.cleanpath(req.form['file'][0]), |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
761 |
req.form['filenode'][0])) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
762 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
763 |
def do_annotate(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
764 |
req.write(self.fileannotate(self.cleanpath(req.form['file'][0]), |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
765 |
req.form['filenode'][0])) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
766 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
767 |
def do_filelog(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
768 |
req.write(self.filelog(self.cleanpath(req.form['file'][0]), |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
769 |
req.form['filenode'][0])) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
770 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
771 |
def do_heads(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
772 |
resp = " ".join(map(hex, self.repo.heads())) + "\n" |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
773 |
req.httphdr("application/mercurial-0.1", length=len(resp)) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
774 |
req.write(resp) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
775 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
776 |
def do_branches(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
777 |
nodes = [] |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
778 |
if req.form.has_key('nodes'): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
779 |
nodes = map(bin, req.form['nodes'][0].split(" ")) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
780 |
resp = cStringIO.StringIO() |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
781 |
for b in self.repo.branches(nodes): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
782 |
resp.write(" ".join(map(hex, b)) + "\n") |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
783 |
resp = resp.getvalue() |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
784 |
req.httphdr("application/mercurial-0.1", length=len(resp)) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
785 |
req.write(resp) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
786 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
787 |
def do_between(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
788 |
nodes = [] |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
789 |
if req.form.has_key('pairs'): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
790 |
pairs = [map(bin, p.split("-")) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
791 |
for p in req.form['pairs'][0].split(" ")] |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
792 |
resp = cStringIO.StringIO() |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
793 |
for b in self.repo.between(pairs): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
794 |
resp.write(" ".join(map(hex, b)) + "\n") |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
795 |
resp = resp.getvalue() |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
796 |
req.httphdr("application/mercurial-0.1", length=len(resp)) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
797 |
req.write(resp) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
798 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
799 |
def do_changegroup(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
800 |
req.httphdr("application/mercurial-0.1") |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
801 |
nodes = [] |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
802 |
if not self.allowpull: |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
803 |
return |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
804 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
805 |
if req.form.has_key('roots'): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
806 |
nodes = map(bin, req.form['roots'][0].split(" ")) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
807 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
808 |
z = zlib.compressobj() |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
809 |
f = self.repo.changegroup(nodes, 'serve') |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
810 |
while 1: |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
811 |
chunk = f.read(4096) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
812 |
if not chunk: |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
813 |
break |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
814 |
req.write(z.compress(chunk)) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
815 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
816 |
req.write(z.flush()) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
817 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
818 |
def do_archive(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
819 |
changeset = self.repo.lookup(req.form['node'][0]) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
820 |
type_ = req.form['type'][0] |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
821 |
allowed = self.repo.ui.config("web", "allow_archive", "").split() |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
822 |
if (type_ in self.archives and (type_ in allowed or |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
823 |
self.repo.ui.configbool("web", "allow" + type_, False))): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
824 |
self.archive(req, changeset, type_) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
825 |
return |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
826 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
827 |
req.write(self.t("error")) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
828 |
|
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
829 |
def do_static(self, req): |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
830 |
fname = req.form['file'][0] |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
831 |
static = self.repo.ui.config("web", "static", |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
832 |
os.path.join(self.templatepath, |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
833 |
"static")) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
834 |
req.write(staticfile(static, fname) |
f910b91dd912
hgweb: split "verbs" into methods.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2434
diff
changeset
|
835 |
or self.t("error", error="%r not found" % fname)) |
2442
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2436
diff
changeset
|
836 |
|
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2436
diff
changeset
|
837 |
def do_capabilities(self, req): |
2464
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
838 |
resp = 'unbundle' |
2442
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2436
diff
changeset
|
839 |
req.httphdr("application/mercurial-0.1", length=len(resp)) |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2436
diff
changeset
|
840 |
req.write(resp) |
c660691fb45d
http: query server for capabilities
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2436
diff
changeset
|
841 |
|
2464
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
842 |
def do_unbundle(self, req): |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
843 |
their_heads = req.form['heads'][0].split(' ') |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
844 |
|
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
845 |
def check_heads(): |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
846 |
heads = map(hex, self.repo.heads()) |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
847 |
return their_heads == [hex('force')] or their_heads == heads |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
848 |
|
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
849 |
req.httphdr("application/mercurial-0.1") |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
850 |
|
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
851 |
# fail early if possible |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
852 |
if not check_heads(): |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
853 |
req.write('0\n') |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
854 |
req.write(_('unsynced changes\n')) |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
855 |
return |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
856 |
|
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
857 |
# do not lock repo until all changegroup data is |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
858 |
# streamed. save to temporary file. |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
859 |
|
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
860 |
fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-') |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
861 |
fp = os.fdopen(fd, 'wb+') |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
862 |
try: |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
863 |
length = int(req.env['CONTENT_LENGTH']) |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
864 |
for s in util.filechunkiter(req, limit=length): |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
865 |
fp.write(s) |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
866 |
|
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
867 |
lock = self.repo.lock() |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
868 |
try: |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
869 |
if not check_heads(): |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
870 |
req.write('0\n') |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
871 |
req.write(_('unsynced changes\n')) |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
872 |
return |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
873 |
|
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
874 |
fp.seek(0) |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
875 |
|
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
876 |
# send addchangegroup output to client |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
877 |
|
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
878 |
old_stdout = sys.stdout |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
879 |
sys.stdout = cStringIO.StringIO() |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
880 |
|
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
881 |
try: |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
882 |
ret = self.repo.addchangegroup(fp, 'serve') |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
883 |
req.write('%d\n' % ret) |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
884 |
req.write(sys.stdout.getvalue()) |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
885 |
finally: |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
886 |
sys.stdout = old_stdout |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
887 |
finally: |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
888 |
lock.release() |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
889 |
finally: |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
890 |
fp.close() |
09b1c9ef317c
push over http: server support.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2442
diff
changeset
|
891 |
os.unlink(tempname) |