Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/hgweb.py @ 871:c2e77581bc84
Merge with mpm.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Tue, 09 Aug 2005 17:24:38 -0800 |
parents | 9c918287d10b c333dfa8fa1a |
children | d4cb383e7de7 781266a78fe1 bc9ca4d51d23 63ca8a68d59e |
comparison
equal
deleted
inserted
replaced
870:a82eae840447 | 871:c2e77581bc84 |
---|---|
68 while tmpl: | 68 while tmpl: |
69 m = re.search(r"#([a-zA-Z0-9]+)((\|[a-zA-Z0-9]+)*)#", tmpl) | 69 m = re.search(r"#([a-zA-Z0-9]+)((\|[a-zA-Z0-9]+)*)#", tmpl) |
70 if m: | 70 if m: |
71 yield tmpl[:m.start(0)] | 71 yield tmpl[:m.start(0)] |
72 v = map.get(m.group(1), "") | 72 v = map.get(m.group(1), "") |
73 v = callable(v) and v() or v | 73 v = callable(v) and v(**map) or v |
74 | 74 |
75 fl = m.group(2) | 75 fl = m.group(2) |
76 if fl: | 76 if fl: |
77 for f in fl.split("|")[1:]: | 77 for f in fl.split("|")[1:]: |
78 v = filters[f](v) | 78 v = filters[f](v) |
222 for f in d: | 222 for f in d: |
223 to = r.file(f).read(mmap1[f]) | 223 to = r.file(f).read(mmap1[f]) |
224 tn = None | 224 tn = None |
225 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn) | 225 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn) |
226 | 226 |
227 def header(self): | |
228 yield self.t("header") | |
229 | |
230 def footer(self): | |
231 yield self.t("footer") | |
232 | |
233 def changelog(self, pos): | 227 def changelog(self, pos): |
234 def changenav(): | 228 def changenav(**map): |
235 def seq(factor = 1): | 229 def seq(factor = 1): |
236 yield 1 * factor | 230 yield 1 * factor |
237 yield 3 * factor | 231 yield 3 * factor |
238 #yield 5 * factor | 232 #yield 5 * factor |
239 for f in seq(factor * 10): | 233 for f in seq(factor * 10): |
252 for label, rev in l: | 246 for label, rev in l: |
253 yield self.t("naventry", label = label, rev = rev) | 247 yield self.t("naventry", label = label, rev = rev) |
254 | 248 |
255 yield self.t("naventry", label="tip") | 249 yield self.t("naventry", label="tip") |
256 | 250 |
257 def changelist(): | 251 def changelist(**map): |
258 parity = (start - end) & 1 | 252 parity = (start - end) & 1 |
259 cl = self.repo.changelog | 253 cl = self.repo.changelog |
260 l = [] # build a list in forward order for efficiency | 254 l = [] # build a list in forward order for efficiency |
261 for i in range(start, end): | 255 for i in range(start, end): |
262 n = cl.node(i) | 256 n = cl.node(i) |
293 manifest = hex(mf), | 287 manifest = hex(mf), |
294 rev = pos, changesets = count, entries = changelist) | 288 rev = pos, changesets = count, entries = changelist) |
295 | 289 |
296 def search(self, query): | 290 def search(self, query): |
297 | 291 |
298 def changelist(): | 292 def changelist(**map): |
299 cl = self.repo.changelog | 293 cl = self.repo.changelog |
300 count = 0 | 294 count = 0 |
301 qw = query.lower().split() | 295 qw = query.lower().split() |
302 | 296 |
303 def revgen(): | 297 def revgen(): |
359 mf = self.repo.manifest.read(changes[0]) | 353 mf = self.repo.manifest.read(changes[0]) |
360 for f in changes[3]: | 354 for f in changes[3]: |
361 files.append(self.t("filenodelink", | 355 files.append(self.t("filenodelink", |
362 filenode = hex(mf.get(f, nullid)), file = f)) | 356 filenode = hex(mf.get(f, nullid)), file = f)) |
363 | 357 |
364 def diff(): | 358 def diff(**map): |
365 yield self.diff(p1, n, None) | 359 yield self.diff(p1, n, None) |
366 | 360 |
367 yield self.t('changeset', | 361 yield self.t('changeset', |
368 diff = diff, | 362 diff = diff, |
369 rev = cl.rev(n), | 363 rev = cl.rev(n), |
380 def filelog(self, f, filenode): | 374 def filelog(self, f, filenode): |
381 cl = self.repo.changelog | 375 cl = self.repo.changelog |
382 fl = self.repo.file(f) | 376 fl = self.repo.file(f) |
383 count = fl.count() | 377 count = fl.count() |
384 | 378 |
385 def entries(): | 379 def entries(**map): |
386 l = [] | 380 l = [] |
387 parity = (count - 1) & 1 | 381 parity = (count - 1) & 1 |
388 | 382 |
389 for i in range(count): | 383 for i in range(count): |
390 | 384 |
455 cn = cl.node(changerev) | 449 cn = cl.node(changerev) |
456 cs = cl.read(cn) | 450 cs = cl.read(cn) |
457 t = float(cs[2].split(' ')[0]) | 451 t = float(cs[2].split(' ')[0]) |
458 mfn = cs[0] | 452 mfn = cs[0] |
459 | 453 |
460 def annotate(): | 454 def annotate(**map): |
461 parity = 1 | 455 parity = 1 |
462 last = None | 456 last = None |
463 for r, l in fl.annotate(n): | 457 for r, l in fl.annotate(n): |
464 try: | 458 try: |
465 cnode = ncache[r] | 459 cnode = ncache[r] |
525 files[short] = (f, None) | 519 files[short] = (f, None) |
526 else: | 520 else: |
527 short = os.path.basename(remain) | 521 short = os.path.basename(remain) |
528 files[short] = (f, n) | 522 files[short] = (f, n) |
529 | 523 |
530 def filelist(): | 524 def filelist(**map): |
531 parity = 0 | 525 parity = 0 |
532 fl = files.keys() | 526 fl = files.keys() |
533 fl.sort() | 527 fl.sort() |
534 for f in fl: | 528 for f in fl: |
535 full, fnode = files[f] | 529 full, fnode = files[f] |
561 mf = cl.read(cl.tip())[0] | 555 mf = cl.read(cl.tip())[0] |
562 | 556 |
563 i = self.repo.tagslist() | 557 i = self.repo.tagslist() |
564 i.reverse() | 558 i.reverse() |
565 | 559 |
566 def entries(): | 560 def entries(**map): |
567 parity = 0 | 561 parity = 0 |
568 for k,n in i: | 562 for k,n in i: |
569 yield self.t("tagentry", | 563 yield self.t("tagentry", |
570 parity = parity, | 564 parity = parity, |
571 tag = k, | 565 tag = k, |
581 cl = self.repo.changelog | 575 cl = self.repo.changelog |
582 p1 = cl.parents(n)[0] | 576 p1 = cl.parents(n)[0] |
583 cs = cl.read(n) | 577 cs = cl.read(n) |
584 mf = self.repo.manifest.read(cs[0]) | 578 mf = self.repo.manifest.read(cs[0]) |
585 | 579 |
586 def diff(): | 580 def diff(**map): |
587 yield self.diff(p1, n, file) | 581 yield self.diff(p1, n, file) |
588 | 582 |
589 yield self.t("filediff", | 583 yield self.t("filediff", |
590 file = file, | 584 file = file, |
591 filenode = hex(mf.get(file, nullid)), | 585 filenode = hex(mf.get(file, nullid)), |
598 # add tags to things | 592 # add tags to things |
599 # tags -> list of changesets corresponding to tags | 593 # tags -> list of changesets corresponding to tags |
600 # find tag, changeset, file | 594 # find tag, changeset, file |
601 | 595 |
602 def run(self): | 596 def run(self): |
597 def header(**map): | |
598 yield self.t("header", **map) | |
599 | |
600 def footer(**map): | |
601 yield self.t("footer", **map) | |
602 | |
603 self.refresh() | 603 self.refresh() |
604 args = cgi.parse() | 604 args = cgi.parse() |
605 | 605 |
606 m = os.path.join(self.templates, "map") | 606 m = os.path.join(self.templates, "map") |
607 if args.has_key('style'): | 607 if args.has_key('style'): |
616 url = "http://%s%s%s" % (os.environ["SERVER_NAME"], port, uri) | 616 url = "http://%s%s%s" % (os.environ["SERVER_NAME"], port, uri) |
617 | 617 |
618 self.t = templater(m, self.filters, | 618 self.t = templater(m, self.filters, |
619 {"url":url, | 619 {"url":url, |
620 "repo":self.reponame, | 620 "repo":self.reponame, |
621 "header":self.header(), | 621 "header":header, |
622 "footer":self.footer(), | 622 "footer":footer, |
623 }) | 623 }) |
624 | 624 |
625 if not args.has_key('cmd') or args['cmd'][0] == 'changelog': | 625 if not args.has_key('cmd'): |
626 args['cmd'] = [self.t.cache['default'],] | |
627 | |
628 if args['cmd'][0] == 'changelog': | |
626 c = self.repo.changelog.count() - 1 | 629 c = self.repo.changelog.count() - 1 |
627 hi = c | 630 hi = c |
628 if args.has_key('rev'): | 631 if args.has_key('rev'): |
629 hi = args['rev'][0] | 632 hi = args['rev'][0] |
630 try: | 633 try: |