Mercurial > hg
comparison mercurial/hgweb.py @ 1324:77cd8068dbf4
hgweb: pass date tuples around rather than whole changesets for dates
author | mpm@selenic.com |
---|---|
date | Thu, 22 Sep 2005 23:38:04 -0700 |
parents | b47f96a178a3 |
children | 901c645c1943 |
comparison
equal
deleted
inserted
replaced
1323:60200b3fc839 | 1324:77cd8068dbf4 |
---|---|
25 return t + "s" | 25 return t + "s" |
26 def fmt(t, c): | 26 def fmt(t, c): |
27 return "%d %s" % (c, plural(t, c)) | 27 return "%d %s" % (c, plural(t, c)) |
28 | 28 |
29 now = time.time() | 29 now = time.time() |
30 then = x[2][0] | 30 then = x[0] |
31 delta = max(1, int(now - then)) | 31 delta = max(1, int(now - then)) |
32 | 32 |
33 scales = [["second", 1], | 33 scales = [["second", 1], |
34 ["minute", 60], | 34 ["minute", 60], |
35 ["hour", 3600], | 35 ["hour", 3600], |
153 return | 153 return |
154 | 154 |
155 common_filters = { | 155 common_filters = { |
156 "escape": cgi.escape, | 156 "escape": cgi.escape, |
157 "age": age, | 157 "age": age, |
158 "date": lambda x: util.datestr(x[2]), | 158 "date": lambda x: util.datestr(x), |
159 "addbreaks": nl2br, | 159 "addbreaks": nl2br, |
160 "obfuscate": obfuscate, | 160 "obfuscate": obfuscate, |
161 "short": (lambda x: x[:12]), | 161 "short": (lambda x: x[:12]), |
162 "firstline": (lambda x: x.splitlines(1)[0]), | 162 "firstline": (lambda x: x.splitlines(1)[0]), |
163 "permissions": (lambda x: x and "-rwxr-xr-x" or "-rw-r--r--"), | 163 "permissions": (lambda x: x and "-rwxr-xr-x" or "-rw-r--r--"), |
164 "rfc822date": lambda x: util.datestr(x[2], "%a, %d %b %Y %H:%M:%S"), | 164 "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), |
165 } | 165 } |
166 | 166 |
167 class hgweb: | 167 class hgweb: |
168 def __init__(self, repo, name=None): | 168 def __init__(self, repo, name=None): |
169 if type(repo) == type(""): | 169 if type(repo) == type(""): |
182 self.repo = hg.repository(self.repo.ui, self.repo.root) | 182 self.repo = hg.repository(self.repo.ui, self.repo.root) |
183 self.maxchanges = int(self.repo.ui.config("web", "maxchanges", 10)) | 183 self.maxchanges = int(self.repo.ui.config("web", "maxchanges", 10)) |
184 self.maxfiles = int(self.repo.ui.config("web", "maxfiles", 10)) | 184 self.maxfiles = int(self.repo.ui.config("web", "maxfiles", 10)) |
185 self.allowpull = self.repo.ui.configbool("web", "allowpull", True) | 185 self.allowpull = self.repo.ui.configbool("web", "allowpull", True) |
186 | 186 |
187 def date(self, cs): | 187 def date(self, t): |
188 return util.datestr(cs[2]) | 188 return util.datestr(t) |
189 | 189 |
190 def listfiles(self, files, mf): | 190 def listfiles(self, files, mf): |
191 for f in files[:self.maxfiles]: | 191 for f in files[:self.maxfiles]: |
192 yield self.t("filenodelink", node=hex(mf[f]), file=f) | 192 yield self.t("filenodelink", node=hex(mf[f]), file=f) |
193 if len(files) > self.maxfiles: | 193 if len(files) > self.maxfiles: |
309 "parent": self.parents("changelogparent", | 309 "parent": self.parents("changelogparent", |
310 cl.parents(n), cl.rev), | 310 cl.parents(n), cl.rev), |
311 "changelogtag": self.showtag("changelogtag",n), | 311 "changelogtag": self.showtag("changelogtag",n), |
312 "manifest": hex(changes[0]), | 312 "manifest": hex(changes[0]), |
313 "desc": changes[4], | 313 "desc": changes[4], |
314 "date": changes, | 314 "date": changes[2], |
315 "files": self.listfilediffs(changes[3], n), | 315 "files": self.listfilediffs(changes[3], n), |
316 "rev": i, | 316 "rev": i, |
317 "node": hn}) | 317 "node": hn}) |
318 parity = 1 - parity | 318 parity = 1 - parity |
319 | 319 |
370 parent=self.parents("changelogparent", | 370 parent=self.parents("changelogparent", |
371 cl.parents(n), cl.rev), | 371 cl.parents(n), cl.rev), |
372 changelogtag=self.showtag("changelogtag",n), | 372 changelogtag=self.showtag("changelogtag",n), |
373 manifest=hex(changes[0]), | 373 manifest=hex(changes[0]), |
374 desc=changes[4], | 374 desc=changes[4], |
375 date=changes, | 375 date=changes[2], |
376 files=self.listfilediffs(changes[3], n), | 376 files=self.listfilediffs(changes[3], n), |
377 rev=i, | 377 rev=i, |
378 node=hn) | 378 node=hn) |
379 | 379 |
380 if count >= self.maxchanges: | 380 if count >= self.maxchanges: |
416 cl.parents(n), cl.rev), | 416 cl.parents(n), cl.rev), |
417 changesettag=self.showtag("changesettag",n), | 417 changesettag=self.showtag("changesettag",n), |
418 manifest=hex(changes[0]), | 418 manifest=hex(changes[0]), |
419 author=changes[1], | 419 author=changes[1], |
420 desc=changes[4], | 420 desc=changes[4], |
421 date=changes, | 421 date=changes[2], |
422 files=files, | 422 files=files, |
423 archives=archivelist()) | 423 archives=archivelist()) |
424 | 424 |
425 def filelog(self, f, filenode): | 425 def filelog(self, f, filenode): |
426 cl = self.repo.changelog | 426 cl = self.repo.changelog |
441 "filenode": hex(n), | 441 "filenode": hex(n), |
442 "filerev": i, | 442 "filerev": i, |
443 "file": f, | 443 "file": f, |
444 "node": hex(cn), | 444 "node": hex(cn), |
445 "author": cs[1], | 445 "author": cs[1], |
446 "date": cs, | 446 "date": cs[2], |
447 "parent": self.parents("filelogparent", | 447 "parent": self.parents("filelogparent", |
448 fl.parents(n), | 448 fl.parents(n), |
449 fl.rev, file=f), | 449 fl.rev, file=f), |
450 "desc": cs[4]}) | 450 "desc": cs[4]}) |
451 parity = 1 - parity | 451 parity = 1 - parity |
478 text=lines(), | 478 text=lines(), |
479 rev=changerev, | 479 rev=changerev, |
480 node=hex(cn), | 480 node=hex(cn), |
481 manifest=hex(mfn), | 481 manifest=hex(mfn), |
482 author=cs[1], | 482 author=cs[1], |
483 date=cs, | 483 date=cs[2], |
484 parent=self.parents("filerevparent", | 484 parent=self.parents("filerevparent", |
485 fl.parents(n), fl.rev, file=f), | 485 fl.parents(n), fl.rev, file=f), |
486 permissions=self.repo.manifest.readflags(mfn)[f]) | 486 permissions=self.repo.manifest.readflags(mfn)[f]) |
487 | 487 |
488 def fileannotate(self, f, node): | 488 def fileannotate(self, f, node): |
530 path=up(f), | 530 path=up(f), |
531 rev=changerev, | 531 rev=changerev, |
532 node=hex(cn), | 532 node=hex(cn), |
533 manifest=hex(mfn), | 533 manifest=hex(mfn), |
534 author=cs[1], | 534 author=cs[1], |
535 date=cs, | 535 date=cs[2], |
536 parent=self.parents("fileannotateparent", | 536 parent=self.parents("fileannotateparent", |
537 fl.parents(n), fl.rev, file=f), | 537 fl.parents(n), fl.rev, file=f), |
538 permissions=self.repo.manifest.readflags(mfn)[f]) | 538 permissions=self.repo.manifest.readflags(mfn)[f]) |
539 | 539 |
540 def manifest(self, mnode, path): | 540 def manifest(self, mnode, path): |