Show More
@@ -0,0 +1,34 b'' | |||
|
1 | echo % setting up repo | |
|
2 | hg init test | |
|
3 | cd test | |
|
4 | echo a > a | |
|
5 | echo b > b | |
|
6 | hg ci -Ama | |
|
7 | ||
|
8 | echo % change permissions for git diffs | |
|
9 | chmod 755 a | |
|
10 | hg ci -Amb | |
|
11 | ||
|
12 | echo % set up hgweb | |
|
13 | hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log | |
|
14 | cat hg.pid >> $DAEMON_PIDS | |
|
15 | ||
|
16 | echo % revision | |
|
17 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/rev/0' | |
|
18 | ||
|
19 | echo % diff removed file | |
|
20 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/a' | |
|
21 | ||
|
22 | echo % set up hgweb with git diffs | |
|
23 | kill `cat hg.pid` | |
|
24 | hg serve --config 'diff.git=1' -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log | |
|
25 | cat hg.pid >> $DAEMON_PIDS | |
|
26 | ||
|
27 | echo % revision | |
|
28 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/rev/0' | |
|
29 | ||
|
30 | echo % diff removed file | |
|
31 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/a' | |
|
32 | ||
|
33 | echo % errors | |
|
34 | cat errors.log |
@@ -0,0 +1,272 b'' | |||
|
1 | % setting up repo | |
|
2 | adding a | |
|
3 | adding b | |
|
4 | % change permissions for git diffs | |
|
5 | % set up hgweb | |
|
6 | % revision | |
|
7 | 200 Script output follows | |
|
8 | ||
|
9 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
|
10 | <html> | |
|
11 | <head> | |
|
12 | <link rel="icon" href="/static/hgicon.png" type="image/png"> | |
|
13 | <meta name="robots" content="index, nofollow" /> | |
|
14 | <link rel="stylesheet" href="/static/style.css" type="text/css" /> | |
|
15 | ||
|
16 | <title>test: changeset 0cd96de13884</title> | |
|
17 | </head> | |
|
18 | <body> | |
|
19 | ||
|
20 | <div class="buttons"> | |
|
21 | <a href="/log/0">changelog</a> | |
|
22 | <a href="/shortlog/0">shortlog</a> | |
|
23 | <a href="/graph">graph</a> | |
|
24 | <a href="/tags">tags</a> | |
|
25 | <a href="/file/0cd96de13884">files</a> | |
|
26 | <a href="/raw-rev/0cd96de13884">raw</a> | |
|
27 | ||
|
28 | </div> | |
|
29 | ||
|
30 | <h2>changeset: a</h2> | |
|
31 | ||
|
32 | <table id="changesetEntry"> | |
|
33 | <tr> | |
|
34 | <th class="changeset">changeset 0:</th> | |
|
35 | <td class="changeset"><a href="/rev/0cd96de13884">0cd96de13884</a></td> | |
|
36 | </tr> | |
|
37 | ||
|
38 | <tr><th class="child">child 1:</th><td class="child"><a href="/rev/78e4ebad7cdf">78e4ebad7cdf</a></td></tr> | |
|
39 | ||
|
40 | <tr> | |
|
41 | <th class="author">author:</th> | |
|
42 | <td class="author">test</td> | |
|
43 | </tr> | |
|
44 | <tr> | |
|
45 | <th class="date">date:</th> | |
|
46 | <td class="date">Thu Jan 01 00:00:00 1970 +0000 (38 years ago)</td> | |
|
47 | </tr> | |
|
48 | <tr> | |
|
49 | <th class="files">files:</th> | |
|
50 | <td class="files"><a href="/file/0cd96de13884/a">a</a> <a href="/file/0cd96de13884/b">b</a> </td> | |
|
51 | </tr> | |
|
52 | <tr> | |
|
53 | <th class="description">description:</th> | |
|
54 | <td class="description">a</td> | |
|
55 | </tr> | |
|
56 | </table> | |
|
57 | ||
|
58 | <div id="changesetDiff"> | |
|
59 | <pre class="parity0"><span class="minusline"><a class="lineno" href="#l1" id="l1"> 1</a>--- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
|
60 | </span><span class="plusline"><a class="lineno" href="#l2" id="l2"> 2</a>+++ b/a Thu Jan 01 00:00:00 1970 +0000 | |
|
61 | </span><span class="atline"><a class="lineno" href="#l3" id="l3"> 3</a>@@ -0,0 +1,1 @@ | |
|
62 | </span><span class="plusline"><a class="lineno" href="#l4" id="l4"> 4</a>+a | |
|
63 | </span></pre><pre class="parity1"><span class="minusline"><a class="lineno" href="#l1.1" id="l1.1"> 1.1</a>--- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
|
64 | </span><span class="plusline"><a class="lineno" href="#l1.2" id="l1.2"> 1.2</a>+++ b/b Thu Jan 01 00:00:00 1970 +0000 | |
|
65 | </span><span class="atline"><a class="lineno" href="#l1.3" id="l1.3"> 1.3</a>@@ -0,0 +1,1 @@ | |
|
66 | </span><span class="plusline"><a class="lineno" href="#l1.4" id="l1.4"> 1.4</a>+b | |
|
67 | </span></pre> | |
|
68 | </div> | |
|
69 | ||
|
70 | ||
|
71 | <div class="logo"> | |
|
72 | <a href="http://www.selenic.com/mercurial/"> | |
|
73 | <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> | |
|
74 | </div> | |
|
75 | ||
|
76 | </body> | |
|
77 | </html> | |
|
78 | ||
|
79 | ||
|
80 | ||
|
81 | % diff removed file | |
|
82 | 200 Script output follows | |
|
83 | ||
|
84 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
|
85 | <html> | |
|
86 | <head> | |
|
87 | <link rel="icon" href="/static/hgicon.png" type="image/png"> | |
|
88 | <meta name="robots" content="index, nofollow" /> | |
|
89 | <link rel="stylesheet" href="/static/style.css" type="text/css" /> | |
|
90 | ||
|
91 | <title>test: a diff</title> | |
|
92 | </head> | |
|
93 | <body> | |
|
94 | ||
|
95 | <div class="buttons"> | |
|
96 | <a href="/log/1">changelog</a> | |
|
97 | <a href="/shortlog/1">shortlog</a> | |
|
98 | <a href="/graph">graph</a> | |
|
99 | <a href="/tags">tags</a> | |
|
100 | <a href="/rev/78e4ebad7cdf">changeset</a> | |
|
101 | <a href="/file/78e4ebad7cdf/a">file</a> | |
|
102 | <a href="/log/78e4ebad7cdf/a">revisions</a> | |
|
103 | <a href="/annotate/78e4ebad7cdf/a">annotate</a> | |
|
104 | <a href="/raw-diff/78e4ebad7cdf/a">raw</a> | |
|
105 | </div> | |
|
106 | ||
|
107 | <h2>a</h2> | |
|
108 | ||
|
109 | <table id="filediffEntry"> | |
|
110 | <tr> | |
|
111 | <th class="revision">revision 1:</th> | |
|
112 | <td class="revision"><a href="/rev/78e4ebad7cdf">78e4ebad7cdf</a></td> | |
|
113 | </tr> | |
|
114 | ||
|
115 | ||
|
116 | </table> | |
|
117 | ||
|
118 | <div id="fileDiff"> | |
|
119 | <pre class="parity0"><span class="minusline"><a class="lineno" href="#l1" id="l1"> 1</a>--- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
|
120 | </span><span class="plusline"><a class="lineno" href="#l2" id="l2"> 2</a>+++ b/a Thu Jan 01 00:00:00 1970 +0000 | |
|
121 | </span><span class="atline"><a class="lineno" href="#l3" id="l3"> 3</a>@@ -0,0 +1,1 @@ | |
|
122 | </span><span class="plusline"><a class="lineno" href="#l4" id="l4"> 4</a>+a | |
|
123 | </span></pre> | |
|
124 | </div> | |
|
125 | ||
|
126 | ||
|
127 | <div class="logo"> | |
|
128 | <a href="http://www.selenic.com/mercurial/"> | |
|
129 | <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> | |
|
130 | </div> | |
|
131 | ||
|
132 | </body> | |
|
133 | </html> | |
|
134 | ||
|
135 | ||
|
136 | ||
|
137 | % set up hgweb with git diffs | |
|
138 | % revision | |
|
139 | 200 Script output follows | |
|
140 | ||
|
141 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
|
142 | <html> | |
|
143 | <head> | |
|
144 | <link rel="icon" href="/static/hgicon.png" type="image/png"> | |
|
145 | <meta name="robots" content="index, nofollow" /> | |
|
146 | <link rel="stylesheet" href="/static/style.css" type="text/css" /> | |
|
147 | ||
|
148 | <title>test: changeset 0cd96de13884</title> | |
|
149 | </head> | |
|
150 | <body> | |
|
151 | ||
|
152 | <div class="buttons"> | |
|
153 | <a href="/log/0">changelog</a> | |
|
154 | <a href="/shortlog/0">shortlog</a> | |
|
155 | <a href="/graph">graph</a> | |
|
156 | <a href="/tags">tags</a> | |
|
157 | <a href="/file/0cd96de13884">files</a> | |
|
158 | <a href="/raw-rev/0cd96de13884">raw</a> | |
|
159 | ||
|
160 | </div> | |
|
161 | ||
|
162 | <h2>changeset: a</h2> | |
|
163 | ||
|
164 | <table id="changesetEntry"> | |
|
165 | <tr> | |
|
166 | <th class="changeset">changeset 0:</th> | |
|
167 | <td class="changeset"><a href="/rev/0cd96de13884">0cd96de13884</a></td> | |
|
168 | </tr> | |
|
169 | ||
|
170 | <tr><th class="child">child 1:</th><td class="child"><a href="/rev/78e4ebad7cdf">78e4ebad7cdf</a></td></tr> | |
|
171 | ||
|
172 | <tr> | |
|
173 | <th class="author">author:</th> | |
|
174 | <td class="author">test</td> | |
|
175 | </tr> | |
|
176 | <tr> | |
|
177 | <th class="date">date:</th> | |
|
178 | <td class="date">Thu Jan 01 00:00:00 1970 +0000 (38 years ago)</td> | |
|
179 | </tr> | |
|
180 | <tr> | |
|
181 | <th class="files">files:</th> | |
|
182 | <td class="files"><a href="/file/0cd96de13884/a">a</a> <a href="/file/0cd96de13884/b">b</a> </td> | |
|
183 | </tr> | |
|
184 | <tr> | |
|
185 | <th class="description">description:</th> | |
|
186 | <td class="description">a</td> | |
|
187 | </tr> | |
|
188 | </table> | |
|
189 | ||
|
190 | <div id="changesetDiff"> | |
|
191 | <pre class="parity0"><a class="lineno" href="#l1" id="l1"> 1</a>new file mode 100644 | |
|
192 | <span class="minusline"><a class="lineno" href="#l2" id="l2"> 2</a>--- /dev/null | |
|
193 | </span><span class="plusline"><a class="lineno" href="#l3" id="l3"> 3</a>+++ b/a | |
|
194 | </span><span class="atline"><a class="lineno" href="#l4" id="l4"> 4</a>@@ -0,0 +1,1 @@ | |
|
195 | </span><span class="plusline"><a class="lineno" href="#l5" id="l5"> 5</a>+a | |
|
196 | </span></pre><pre class="parity1"><a class="lineno" href="#l1.1" id="l1.1"> 1.1</a>new file mode 100644 | |
|
197 | <span class="minusline"><a class="lineno" href="#l1.2" id="l1.2"> 1.2</a>--- /dev/null | |
|
198 | </span><span class="plusline"><a class="lineno" href="#l1.3" id="l1.3"> 1.3</a>+++ b/b | |
|
199 | </span><span class="atline"><a class="lineno" href="#l1.4" id="l1.4"> 1.4</a>@@ -0,0 +1,1 @@ | |
|
200 | </span><span class="plusline"><a class="lineno" href="#l1.5" id="l1.5"> 1.5</a>+b | |
|
201 | </span></pre> | |
|
202 | </div> | |
|
203 | ||
|
204 | ||
|
205 | <div class="logo"> | |
|
206 | <a href="http://www.selenic.com/mercurial/"> | |
|
207 | <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> | |
|
208 | </div> | |
|
209 | ||
|
210 | </body> | |
|
211 | </html> | |
|
212 | ||
|
213 | ||
|
214 | ||
|
215 | % diff removed file | |
|
216 | 200 Script output follows | |
|
217 | ||
|
218 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
|
219 | <html> | |
|
220 | <head> | |
|
221 | <link rel="icon" href="/static/hgicon.png" type="image/png"> | |
|
222 | <meta name="robots" content="index, nofollow" /> | |
|
223 | <link rel="stylesheet" href="/static/style.css" type="text/css" /> | |
|
224 | ||
|
225 | <title>test: a diff</title> | |
|
226 | </head> | |
|
227 | <body> | |
|
228 | ||
|
229 | <div class="buttons"> | |
|
230 | <a href="/log/1">changelog</a> | |
|
231 | <a href="/shortlog/1">shortlog</a> | |
|
232 | <a href="/graph">graph</a> | |
|
233 | <a href="/tags">tags</a> | |
|
234 | <a href="/rev/78e4ebad7cdf">changeset</a> | |
|
235 | <a href="/file/78e4ebad7cdf/a">file</a> | |
|
236 | <a href="/log/78e4ebad7cdf/a">revisions</a> | |
|
237 | <a href="/annotate/78e4ebad7cdf/a">annotate</a> | |
|
238 | <a href="/raw-diff/78e4ebad7cdf/a">raw</a> | |
|
239 | </div> | |
|
240 | ||
|
241 | <h2>a</h2> | |
|
242 | ||
|
243 | <table id="filediffEntry"> | |
|
244 | <tr> | |
|
245 | <th class="revision">revision 1:</th> | |
|
246 | <td class="revision"><a href="/rev/78e4ebad7cdf">78e4ebad7cdf</a></td> | |
|
247 | </tr> | |
|
248 | ||
|
249 | ||
|
250 | </table> | |
|
251 | ||
|
252 | <div id="fileDiff"> | |
|
253 | <pre class="parity0"><a class="lineno" href="#l1" id="l1"> 1</a>new file mode 100755 | |
|
254 | <span class="minusline"><a class="lineno" href="#l2" id="l2"> 2</a>--- /dev/null | |
|
255 | </span><span class="plusline"><a class="lineno" href="#l3" id="l3"> 3</a>+++ b/a | |
|
256 | </span><span class="atline"><a class="lineno" href="#l4" id="l4"> 4</a>@@ -0,0 +1,1 @@ | |
|
257 | </span><span class="plusline"><a class="lineno" href="#l5" id="l5"> 5</a>+a | |
|
258 | </span></pre> | |
|
259 | </div> | |
|
260 | ||
|
261 | ||
|
262 | <div class="logo"> | |
|
263 | <a href="http://www.selenic.com/mercurial/"> | |
|
264 | <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> | |
|
265 | </div> | |
|
266 | ||
|
267 | </body> | |
|
268 | </html> | |
|
269 | ||
|
270 | ||
|
271 | ||
|
272 | % errors |
@@ -9,7 +9,7 b'' | |||
|
9 | 9 | import os, mimetypes |
|
10 | 10 | from mercurial.node import hex, nullid |
|
11 | 11 | from mercurial.repo import RepoError |
|
12 |
from mercurial import |
|
|
12 | from mercurial import ui, hg, util, patch, hook, match | |
|
13 | 13 | from mercurial import revlog, templater, templatefilters |
|
14 | 14 | from common import get_mtime, style_map, paritygen, countgen, ErrorResponse |
|
15 | 15 | from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
@@ -277,27 +277,11 b' class hgweb(object):' | |||
|
277 | 277 | yield tmpl("fileellipses") |
|
278 | 278 | |
|
279 | 279 | def diff(self, tmpl, node1, node2, files): |
|
280 | def filterfiles(filters, files): | |
|
281 | l = [x for x in files if x in filters] | |
|
282 | ||
|
283 | for t in filters: | |
|
284 | if t and t[-1] != os.sep: | |
|
285 | t += os.sep | |
|
286 | l += [x for x in files if x.startswith(t)] | |
|
287 | return l | |
|
288 | ||
|
289 | parity = paritygen(self.stripecount) | |
|
290 | def diffblock(diff, f, fn): | |
|
291 | yield tmpl("diffblock", | |
|
292 | lines=prettyprintlines(diff), | |
|
293 | parity=parity.next(), | |
|
294 | file=f, | |
|
295 | filenode=hex(fn or nullid)) | |
|
296 | 280 | |
|
297 | 281 | blockcount = countgen() |
|
298 | 282 | def prettyprintlines(diff): |
|
299 | 283 | blockno = blockcount.next() |
|
300 |
for lineno, l in enumerate(diff.splitlines( |
|
|
284 | for lineno, l in enumerate(diff.splitlines(True)): | |
|
301 | 285 | if blockno == 0: |
|
302 | 286 | lineno = lineno + 1 |
|
303 | 287 | else: |
@@ -315,33 +299,24 b' class hgweb(object):' | |||
|
315 | 299 | lineid="l%s" % lineno, |
|
316 | 300 | linenumber="% 8s" % lineno) |
|
317 | 301 | |
|
318 | r = self.repo | |
|
319 | c1 = r[node1] | |
|
320 | c2 = r[node2] | |
|
321 | date1 = util.datestr(c1.date()) | |
|
322 | date2 = util.datestr(c2.date()) | |
|
302 | if files: | |
|
303 | m = match.exact(self.repo.root, self.repo.getcwd(), files) | |
|
304 | else: | |
|
305 | m = match.always(self.repo.root, self.repo.getcwd()) | |
|
323 | 306 | |
|
324 | modified, added, removed, deleted, unknown = r.status(node1, node2)[:5] | |
|
325 | if files: | |
|
326 | modified, added, removed = map(lambda x: filterfiles(files, x), | |
|
327 | (modified, added, removed)) | |
|
328 | ||
|
307 | block = [] | |
|
308 | parity = paritygen(self.stripecount) | |
|
329 | 309 | diffopts = patch.diffopts(self.repo.ui, untrusted=True) |
|
330 | for f in modified: | |
|
331 | to = c1.filectx(f).data() | |
|
332 | tn = c2.filectx(f).data() | |
|
333 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, f, | |
|
334 | opts=diffopts), f, tn) | |
|
335 | for f in added: | |
|
336 | to = None | |
|
337 | tn = c2.filectx(f).data() | |
|
338 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, f, | |
|
339 | opts=diffopts), f, tn) | |
|
340 | for f in removed: | |
|
341 | to = c1.filectx(f).data() | |
|
342 | tn = None | |
|
343 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, f, | |
|
344 | opts=diffopts), f, tn) | |
|
310 | for chunk in patch.diff(self.repo, node1, node2, m, opts=diffopts): | |
|
311 | if chunk.startswith('diff') and block: | |
|
312 | yield tmpl('diffblock', parity=parity.next(), | |
|
313 | lines=prettyprintlines(''.join(block))) | |
|
314 | block = [] | |
|
315 | if chunk.startswith('diff'): | |
|
316 | chunk = ''.join(chunk.splitlines(True)[1:]) | |
|
317 | block.append(chunk) | |
|
318 | yield tmpl('diffblock', parity=parity.next(), | |
|
319 | lines=prettyprintlines(''.join(block))) | |
|
345 | 320 | |
|
346 | 321 | archive_specs = { |
|
347 | 322 | 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), |
General Comments 0
You need to be logged in to leave comments.
Login now