Show More
@@ -872,14 +872,19 b' def annotate(web, req, tmpl):' | |||
|
872 | 872 | else: |
|
873 | 873 | lines = enumerate(fctx.annotate(follow=True, linenumber=True, |
|
874 | 874 | diffopts=diffopts)) |
|
875 | previousrev = None | |
|
875 | 876 | for lineno, ((f, targetline), l) in lines: |
|
877 | rev = f.rev() | |
|
878 | blockhead = rev != previousrev or None | |
|
879 | previousrev = rev | |
|
876 | 880 | yield {"parity": next(parity), |
|
877 | 881 | "node": f.hex(), |
|
878 |
"rev": |
|
|
882 | "rev": rev, | |
|
879 | 883 | "author": f.user(), |
|
880 | 884 | "desc": f.description(), |
|
881 | 885 | "extra": f.extra(), |
|
882 | 886 | "file": f.path(), |
|
887 | "blockhead": blockhead, | |
|
883 | 888 | "targetline": targetline, |
|
884 | 889 | "line": l, |
|
885 | 890 | "lineno": lineno + 1, |
@@ -97,8 +97,10 b" fileline = '" | |||
|
97 | 97 | annotateline = ' |
|
98 | 98 | <tr id="{lineid}" style="font-family:monospace" class="parity{parity}{ifeq(node, originalnode, ' thisrev')}"> |
|
99 | 99 | <td class="linenr" style="text-align: right;"> |
|
100 | <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}" | |
|
101 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a> | |
|
100 | {if(blockhead, | |
|
101 | '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}" | |
|
102 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>', | |
|
103 | '')} | |
|
102 | 104 | </td> |
|
103 | 105 | <td><pre><a class="linenr" href="#{lineid}">{linenumber}</a></pre></td> |
|
104 | 106 | <td><pre>{line|escape}</pre></td> |
@@ -93,8 +93,10 b" fileline = '" | |||
|
93 | 93 | annotateline = ' |
|
94 | 94 | <tr id="{lineid}" class="parity{parity}{ifeq(node, originalnode, ' thisrev')}"> |
|
95 | 95 | <td class="linenr"> |
|
96 | <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}" | |
|
97 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a> | |
|
96 | {if(blockhead, | |
|
97 | '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}" | |
|
98 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>', | |
|
99 | '')} | |
|
98 | 100 | </td> |
|
99 | 101 | <td class="lineno"> |
|
100 | 102 | <a href="#{lineid}">{linenumber}</a> |
@@ -78,8 +78,10 b' filelogentry = filelogentry.tmpl' | |||
|
78 | 78 | annotateline = ' |
|
79 | 79 | <tr id="{lineid}"{ifeq(node, originalnode, ' class="thisrev"')}> |
|
80 | 80 | <td class="annotate"> |
|
81 | <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}" | |
|
82 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a> | |
|
81 | {if(blockhead, | |
|
82 | '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}" | |
|
83 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>', | |
|
84 | '')} | |
|
83 | 85 | </td> |
|
84 | 86 | <td class="source"><a href="#{lineid}">{linenumber}</a> {line|escape}</td> |
|
85 | 87 | </tr>' |
@@ -56,8 +56,10 b' filelogentry = filelogentry.tmpl' | |||
|
56 | 56 | annotateline = ' |
|
57 | 57 | <tr class="parity{parity}{ifeq(node, originalnode, ' thisrev')}"> |
|
58 | 58 | <td class="annotate"> |
|
59 | <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}" | |
|
60 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a> | |
|
59 | {if(blockhead, | |
|
60 | '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}" | |
|
61 | title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>', | |
|
62 | '')} | |
|
61 | 63 | </td> |
|
62 | 64 | <td> |
|
63 | 65 | <a class="lineno" href="#{lineid}" id="{lineid}">{linenumber}</a> |
@@ -297,225 +297,193 b' hgweb fileannotate, html' | |||
|
297 | 297 | </tr> |
|
298 | 298 | <tr id="l2" class="thisrev"> |
|
299 | 299 | <td class="annotate"> |
|
300 | <a href="/annotate/06824edf55d0/primes.py#l2" | |
|
301 | title="06824edf55d0: a">test@0</a> | |
|
300 | ||
|
302 | 301 | </td> |
|
303 | 302 | <td class="source"><a href="#l2"> 2</a> </td> |
|
304 | 303 | </tr> |
|
305 | 304 | <tr id="l3" class="thisrev"> |
|
306 | 305 | <td class="annotate"> |
|
307 | <a href="/annotate/06824edf55d0/primes.py#l3" | |
|
308 | title="06824edf55d0: a">test@0</a> | |
|
306 | ||
|
309 | 307 | </td> |
|
310 | 308 | <td class="source"><a href="#l3"> 3</a> <span class="sd">"""Fun with generators. Corresponding Haskell implementation:</span></td> |
|
311 | 309 | </tr> |
|
312 | 310 | <tr id="l4" class="thisrev"> |
|
313 | 311 | <td class="annotate"> |
|
314 | <a href="/annotate/06824edf55d0/primes.py#l4" | |
|
315 | title="06824edf55d0: a">test@0</a> | |
|
312 | ||
|
316 | 313 | </td> |
|
317 | 314 | <td class="source"><a href="#l4"> 4</a> </td> |
|
318 | 315 | </tr> |
|
319 | 316 | <tr id="l5" class="thisrev"> |
|
320 | 317 | <td class="annotate"> |
|
321 | <a href="/annotate/06824edf55d0/primes.py#l5" | |
|
322 | title="06824edf55d0: a">test@0</a> | |
|
318 | ||
|
323 | 319 | </td> |
|
324 | 320 | <td class="source"><a href="#l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td> |
|
325 | 321 | </tr> |
|
326 | 322 | <tr id="l6" class="thisrev"> |
|
327 | 323 | <td class="annotate"> |
|
328 | <a href="/annotate/06824edf55d0/primes.py#l6" | |
|
329 | title="06824edf55d0: a">test@0</a> | |
|
324 | ||
|
330 | 325 | </td> |
|
331 | 326 | <td class="source"><a href="#l6"> 6</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]</span></td> |
|
332 | 327 | </tr> |
|
333 | 328 | <tr id="l7" class="thisrev"> |
|
334 | 329 | <td class="annotate"> |
|
335 | <a href="/annotate/06824edf55d0/primes.py#l7" | |
|
336 | title="06824edf55d0: a">test@0</a> | |
|
330 | ||
|
337 | 331 | </td> |
|
338 | 332 | <td class="source"><a href="#l7"> 7</a> <span class="sd">"""</span></td> |
|
339 | 333 | </tr> |
|
340 | 334 | <tr id="l8" class="thisrev"> |
|
341 | 335 | <td class="annotate"> |
|
342 | <a href="/annotate/06824edf55d0/primes.py#l8" | |
|
343 | title="06824edf55d0: a">test@0</a> | |
|
336 | ||
|
344 | 337 | </td> |
|
345 | 338 | <td class="source"><a href="#l8"> 8</a> </td> |
|
346 | 339 | </tr> |
|
347 | 340 | <tr id="l9" class="thisrev"> |
|
348 | 341 | <td class="annotate"> |
|
349 | <a href="/annotate/06824edf55d0/primes.py#l9" | |
|
350 | title="06824edf55d0: a">test@0</a> | |
|
342 | ||
|
351 | 343 | </td> |
|
352 | 344 | <td class="source"><a href="#l9"> 9</a> <span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">dropwhile</span><span class="p">,</span> <span class="n">ifilter</span><span class="p">,</span> <span class="n">islice</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">chain</span></td> |
|
353 | 345 | </tr> |
|
354 | 346 | <tr id="l10" class="thisrev"> |
|
355 | 347 | <td class="annotate"> |
|
356 | <a href="/annotate/06824edf55d0/primes.py#l10" | |
|
357 | title="06824edf55d0: a">test@0</a> | |
|
348 | ||
|
358 | 349 | </td> |
|
359 | 350 | <td class="source"><a href="#l10"> 10</a> </td> |
|
360 | 351 | </tr> |
|
361 | 352 | <tr id="l11" class="thisrev"> |
|
362 | 353 | <td class="annotate"> |
|
363 | <a href="/annotate/06824edf55d0/primes.py#l11" | |
|
364 | title="06824edf55d0: a">test@0</a> | |
|
354 | ||
|
365 | 355 | </td> |
|
366 | 356 | <td class="source"><a href="#l11"> 11</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></td> |
|
367 | 357 | </tr> |
|
368 | 358 | <tr id="l12" class="thisrev"> |
|
369 | 359 | <td class="annotate"> |
|
370 | <a href="/annotate/06824edf55d0/primes.py#l12" | |
|
371 | title="06824edf55d0: a">test@0</a> | |
|
360 | ||
|
372 | 361 | </td> |
|
373 | 362 | <td class="source"><a href="#l12"> 12</a> <span class="sd">"""Generate all primes."""</span></td> |
|
374 | 363 | </tr> |
|
375 | 364 | <tr id="l13" class="thisrev"> |
|
376 | 365 | <td class="annotate"> |
|
377 | <a href="/annotate/06824edf55d0/primes.py#l13" | |
|
378 | title="06824edf55d0: a">test@0</a> | |
|
366 | ||
|
379 | 367 | </td> |
|
380 | 368 | <td class="source"><a href="#l13"> 13</a> <span class="kn">def</span> <span class="nf">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></td> |
|
381 | 369 | </tr> |
|
382 | 370 | <tr id="l14" class="thisrev"> |
|
383 | 371 | <td class="annotate"> |
|
384 | <a href="/annotate/06824edf55d0/primes.py#l14" | |
|
385 | title="06824edf55d0: a">test@0</a> | |
|
372 | ||
|
386 | 373 | </td> |
|
387 | 374 | <td class="source"><a href="#l14"> 14</a> <span class="n">p</span> <span class="o">=</span> <span class="n">ns</span><span class="o">.</span><span class="n">next</span><span class="p">()</span></td> |
|
388 | 375 | </tr> |
|
389 | 376 | <tr id="l15" class="thisrev"> |
|
390 | 377 | <td class="annotate"> |
|
391 | <a href="/annotate/06824edf55d0/primes.py#l15" | |
|
392 | title="06824edf55d0: a">test@0</a> | |
|
378 | ||
|
393 | 379 | </td> |
|
394 | 380 | <td class="source"><a href="#l15"> 15</a> <span class="c"># It is important to yield *here* in order to stop the</span></td> |
|
395 | 381 | </tr> |
|
396 | 382 | <tr id="l16" class="thisrev"> |
|
397 | 383 | <td class="annotate"> |
|
398 | <a href="/annotate/06824edf55d0/primes.py#l16" | |
|
399 | title="06824edf55d0: a">test@0</a> | |
|
384 | ||
|
400 | 385 | </td> |
|
401 | 386 | <td class="source"><a href="#l16"> 16</a> <span class="c"># infinite recursion.</span></td> |
|
402 | 387 | </tr> |
|
403 | 388 | <tr id="l17" class="thisrev"> |
|
404 | 389 | <td class="annotate"> |
|
405 | <a href="/annotate/06824edf55d0/primes.py#l17" | |
|
406 | title="06824edf55d0: a">test@0</a> | |
|
390 | ||
|
407 | 391 | </td> |
|
408 | 392 | <td class="source"><a href="#l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></td> |
|
409 | 393 | </tr> |
|
410 | 394 | <tr id="l18" class="thisrev"> |
|
411 | 395 | <td class="annotate"> |
|
412 | <a href="/annotate/06824edf55d0/primes.py#l18" | |
|
413 | title="06824edf55d0: a">test@0</a> | |
|
396 | ||
|
414 | 397 | </td> |
|
415 | 398 | <td class="source"><a href="#l18"> 18</a> <span class="n">ns</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">%</span> <span class="n">p</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ns</span><span class="p">)</span></td> |
|
416 | 399 | </tr> |
|
417 | 400 | <tr id="l19" class="thisrev"> |
|
418 | 401 | <td class="annotate"> |
|
419 | <a href="/annotate/06824edf55d0/primes.py#l19" | |
|
420 | title="06824edf55d0: a">test@0</a> | |
|
402 | ||
|
421 | 403 | </td> |
|
422 | 404 | <td class="source"><a href="#l19"> 19</a> <span class="kn">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></td> |
|
423 | 405 | </tr> |
|
424 | 406 | <tr id="l20" class="thisrev"> |
|
425 | 407 | <td class="annotate"> |
|
426 | <a href="/annotate/06824edf55d0/primes.py#l20" | |
|
427 | title="06824edf55d0: a">test@0</a> | |
|
408 | ||
|
428 | 409 | </td> |
|
429 | 410 | <td class="source"><a href="#l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></td> |
|
430 | 411 | </tr> |
|
431 | 412 | <tr id="l21" class="thisrev"> |
|
432 | 413 | <td class="annotate"> |
|
433 | <a href="/annotate/06824edf55d0/primes.py#l21" | |
|
434 | title="06824edf55d0: a">test@0</a> | |
|
414 | ||
|
435 | 415 | </td> |
|
436 | 416 | <td class="source"><a href="#l21"> 21</a> </td> |
|
437 | 417 | </tr> |
|
438 | 418 | <tr id="l22" class="thisrev"> |
|
439 | 419 | <td class="annotate"> |
|
440 | <a href="/annotate/06824edf55d0/primes.py#l22" | |
|
441 | title="06824edf55d0: a">test@0</a> | |
|
420 | ||
|
442 | 421 | </td> |
|
443 | 422 | <td class="source"><a href="#l22"> 22</a> <span class="n">odds</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">i</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span><span class="p">,</span> <span class="n">count</span><span class="p">())</span></td> |
|
444 | 423 | </tr> |
|
445 | 424 | <tr id="l23" class="thisrev"> |
|
446 | 425 | <td class="annotate"> |
|
447 | <a href="/annotate/06824edf55d0/primes.py#l23" | |
|
448 | title="06824edf55d0: a">test@0</a> | |
|
426 | ||
|
449 | 427 | </td> |
|
450 | 428 | <td class="source"><a href="#l23"> 23</a> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mi">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o"><</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></td> |
|
451 | 429 | </tr> |
|
452 | 430 | <tr id="l24" class="thisrev"> |
|
453 | 431 | <td class="annotate"> |
|
454 | <a href="/annotate/06824edf55d0/primes.py#l24" | |
|
455 | title="06824edf55d0: a">test@0</a> | |
|
432 | ||
|
456 | 433 | </td> |
|
457 | 434 | <td class="source"><a href="#l24"> 24</a> </td> |
|
458 | 435 | </tr> |
|
459 | 436 | <tr id="l25" class="thisrev"> |
|
460 | 437 | <td class="annotate"> |
|
461 | <a href="/annotate/06824edf55d0/primes.py#l25" | |
|
462 | title="06824edf55d0: a">test@0</a> | |
|
438 | ||
|
463 | 439 | </td> |
|
464 | 440 | <td class="source"><a href="#l25"> 25</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">"__main__"</span><span class="p">:</span></td> |
|
465 | 441 | </tr> |
|
466 | 442 | <tr id="l26" class="thisrev"> |
|
467 | 443 | <td class="annotate"> |
|
468 | <a href="/annotate/06824edf55d0/primes.py#l26" | |
|
469 | title="06824edf55d0: a">test@0</a> | |
|
444 | ||
|
470 | 445 | </td> |
|
471 | 446 | <td class="source"><a href="#l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></td> |
|
472 | 447 | </tr> |
|
473 | 448 | <tr id="l27" class="thisrev"> |
|
474 | 449 | <td class="annotate"> |
|
475 | <a href="/annotate/06824edf55d0/primes.py#l27" | |
|
476 | title="06824edf55d0: a">test@0</a> | |
|
450 | ||
|
477 | 451 | </td> |
|
478 | 452 | <td class="source"><a href="#l27"> 27</a> <span class="kn">try</span><span class="p">:</span></td> |
|
479 | 453 | </tr> |
|
480 | 454 | <tr id="l28" class="thisrev"> |
|
481 | 455 | <td class="annotate"> |
|
482 | <a href="/annotate/06824edf55d0/primes.py#l28" | |
|
483 | title="06824edf55d0: a">test@0</a> | |
|
456 | ||
|
484 | 457 | </td> |
|
485 | 458 | <td class="source"><a href="#l28"> 28</a> <span class="n">n</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span></td> |
|
486 | 459 | </tr> |
|
487 | 460 | <tr id="l29" class="thisrev"> |
|
488 | 461 | <td class="annotate"> |
|
489 | <a href="/annotate/06824edf55d0/primes.py#l29" | |
|
490 | title="06824edf55d0: a">test@0</a> | |
|
462 | ||
|
491 | 463 | </td> |
|
492 | 464 | <td class="source"><a href="#l29"> 29</a> <span class="kn">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">IndexError</span><span class="p">):</span></td> |
|
493 | 465 | </tr> |
|
494 | 466 | <tr id="l30" class="thisrev"> |
|
495 | 467 | <td class="annotate"> |
|
496 | <a href="/annotate/06824edf55d0/primes.py#l30" | |
|
497 | title="06824edf55d0: a">test@0</a> | |
|
468 | ||
|
498 | 469 | </td> |
|
499 | 470 | <td class="source"><a href="#l30"> 30</a> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></td> |
|
500 | 471 | </tr> |
|
501 | 472 | <tr id="l31" class="thisrev"> |
|
502 | 473 | <td class="annotate"> |
|
503 | <a href="/annotate/06824edf55d0/primes.py#l31" | |
|
504 | title="06824edf55d0: a">test@0</a> | |
|
474 | ||
|
505 | 475 | </td> |
|
506 | 476 | <td class="source"><a href="#l31"> 31</a> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></td> |
|
507 | 477 | </tr> |
|
508 | 478 | <tr id="l32" class="thisrev"> |
|
509 | 479 | <td class="annotate"> |
|
510 | <a href="/annotate/06824edf55d0/primes.py#l32" | |
|
511 | title="06824edf55d0: a">test@0</a> | |
|
480 | ||
|
512 | 481 | </td> |
|
513 | 482 | <td class="source"><a href="#l32"> 32</a> <span class="kn">print</span> <span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></td> |
|
514 | 483 | </tr> |
|
515 | 484 | <tr id="l33" class="thisrev"> |
|
516 | 485 | <td class="annotate"> |
|
517 | <a href="/annotate/06824edf55d0/primes.py#l33" | |
|
518 | title="06824edf55d0: a">test@0</a> | |
|
486 | ||
|
519 | 487 | </td> |
|
520 | 488 | <td class="source"><a href="#l33"> 33</a> </td> |
|
521 | 489 | </tr> |
General Comments 0
You need to be logged in to leave comments.
Login now