equal
deleted
inserted
replaced
8 |
8 |
9 import os, cgi, sys |
9 import os, cgi, sys |
10 from demandload import demandload |
10 from demandload import demandload |
11 demandload(globals(), "mdiff time re socket zlib errno ui hg ConfigParser") |
11 demandload(globals(), "mdiff time re socket zlib errno ui hg ConfigParser") |
12 demandload(globals(), "zipfile tempfile StringIO tarfile BaseHTTPServer util") |
12 demandload(globals(), "zipfile tempfile StringIO tarfile BaseHTTPServer util") |
|
13 demandload(globals(), "mimetypes") |
13 from node import * |
14 from node import * |
14 from i18n import gettext as _ |
15 from i18n import gettext as _ |
15 |
16 |
16 def templatepath(): |
17 def templatepath(): |
17 for f in "templates", "../templates": |
18 for f in "templates", "../templates": |
464 cl = self.repo.changelog |
465 cl = self.repo.changelog |
465 cn = cl.node(changerev) |
466 cn = cl.node(changerev) |
466 cs = cl.read(cn) |
467 cs = cl.read(cn) |
467 mfn = cs[0] |
468 mfn = cs[0] |
468 |
469 |
|
470 mt = mimetypes.guess_type(f)[0] |
|
471 rawtext = text |
|
472 if util.binary(text): |
|
473 text = "(binary:%s)" % mt |
|
474 |
469 def lines(): |
475 def lines(): |
470 for l, t in enumerate(text.splitlines(1)): |
476 for l, t in enumerate(text.splitlines(1)): |
471 yield {"line": t, |
477 yield {"line": t, |
472 "linenumber": "% 6d" % (l + 1), |
478 "linenumber": "% 6d" % (l + 1), |
473 "parity": l & 1} |
479 "parity": l & 1} |
475 yield self.t("filerevision", |
481 yield self.t("filerevision", |
476 file=f, |
482 file=f, |
477 filenode=node, |
483 filenode=node, |
478 path=up(f), |
484 path=up(f), |
479 text=lines(), |
485 text=lines(), |
|
486 raw=rawtext, |
|
487 mimetype=mt, |
480 rev=changerev, |
488 rev=changerev, |
481 node=hex(cn), |
489 node=hex(cn), |
482 manifest=hex(mfn), |
490 manifest=hex(mfn), |
483 author=cs[1], |
491 author=cs[1], |
484 date=cs[2], |
492 date=cs[2], |