##// END OF EJS Templates
hgweb: use contexts, fix coding style
Benoit Boissinot -
r3973:b485a445 default
parent child Browse files
Show More
@@ -168,14 +168,10 b' class hgweb(object):'
168 yield self.t("diffline", line=l)
168 yield self.t("diffline", line=l)
169
169
170 r = self.repo
170 r = self.repo
171 cl = r.changelog
171 c1 = r.changectx(node1)
172 mf = r.manifest
172 c2 = r.changectx(node2)
173 change1 = cl.read(node1)
173 date1 = util.datestr(c1.date())
174 change2 = cl.read(node2)
174 date2 = util.datestr(c2.date())
175 mmap1 = mf.read(change1[0])
176 mmap2 = mf.read(change2[0])
177 date1 = util.datestr(change1[2])
178 date2 = util.datestr(change2[2])
179
175
180 modified, added, removed, deleted, unknown = r.status(node1, node2)[:5]
176 modified, added, removed, deleted, unknown = r.status(node1, node2)[:5]
181 if files:
177 if files:
@@ -184,17 +180,17 b' class hgweb(object):'
184
180
185 diffopts = patch.diffopts(self.repo.ui, untrusted=True)
181 diffopts = patch.diffopts(self.repo.ui, untrusted=True)
186 for f in modified:
182 for f in modified:
187 to = r.file(f).read(mmap1[f])
183 to = c1.filectx(f).data()
188 tn = r.file(f).read(mmap2[f])
184 tn = c2.filectx(f).data()
189 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
185 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
190 opts=diffopts), f, tn)
186 opts=diffopts), f, tn)
191 for f in added:
187 for f in added:
192 to = None
188 to = None
193 tn = r.file(f).read(mmap2[f])
189 tn = c2.filectx(f).data()
194 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
190 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
195 opts=diffopts), f, tn)
191 opts=diffopts), f, tn)
196 for f in removed:
192 for f in removed:
197 to = r.file(f).read(mmap1[f])
193 to = c1.filectx(f).data()
198 tn = None
194 tn = None
199 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
195 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
200 opts=diffopts), f, tn)
196 opts=diffopts), f, tn)
@@ -493,8 +489,6 b' class hgweb(object):'
493 archives=self.archivelist(hex(node)))
489 archives=self.archivelist(hex(node)))
494
490
495 def tags(self):
491 def tags(self):
496 cl = self.repo.changelog
497
498 i = self.repo.tagslist()
492 i = self.repo.tagslist()
499 i.reverse()
493 i.reverse()
500
494
@@ -505,7 +499,7 b' class hgweb(object):'
505 continue
499 continue
506 yield {"parity": self.stripes(parity),
500 yield {"parity": self.stripes(parity),
507 "tag": k,
501 "tag": k,
508 "date": cl.read(n)[2],
502 "date": self.repo.changectx(n).date(),
509 "node": hex(n)}
503 "node": hex(n)}
510 parity += 1
504 parity += 1
511
505
@@ -515,8 +509,6 b' class hgweb(object):'
515 entriesnotip=lambda **x: entries(True, **x))
509 entriesnotip=lambda **x: entries(True, **x))
516
510
517 def summary(self):
511 def summary(self):
518 cl = self.repo.changelog
519
520 i = self.repo.tagslist()
512 i = self.repo.tagslist()
521 i.reverse()
513 i.reverse()
522
514
@@ -531,14 +523,11 b' class hgweb(object):'
531 if count > 10: # limit to 10 tags
523 if count > 10: # limit to 10 tags
532 break;
524 break;
533
525
534 c = cl.read(n)
535 t = c[2]
536
537 yield self.t("tagentry",
526 yield self.t("tagentry",
538 parity = self.stripes(parity),
527 parity=self.stripes(parity),
539 tag = k,
528 tag=k,
540 node = hex(n),
529 node=hex(n),
541 date = t)
530 date=self.repo.changectx(n).date())
542 parity += 1
531 parity += 1
543
532
544 def heads(**map):
533 def heads(**map):
@@ -560,40 +549,38 b' class hgweb(object):'
560
549
561 def changelist(**map):
550 def changelist(**map):
562 parity = 0
551 parity = 0
563 cl = self.repo.changelog
564 l = [] # build a list in forward order for efficiency
552 l = [] # build a list in forward order for efficiency
565 for i in xrange(start, end):
553 for i in xrange(start, end):
566 n = cl.node(i)
554 ctx = self.repo.changectx(i)
567 changes = cl.read(n)
555 hn = hex(ctx.node())
568 hn = hex(n)
569 t = changes[2]
570
556
571 l.insert(0, self.t(
557 l.insert(0, self.t(
572 'shortlogentry',
558 'shortlogentry',
573 parity = parity,
559 parity=parity,
574 author = changes[1],
560 author=ctx.user(),
575 desc = changes[4],
561 desc=ctx.description(),
576 date = t,
562 date=ctx.date(),
577 rev = i,
563 rev=i,
578 node = hn))
564 node=hn))
579 parity = 1 - parity
565 parity = 1 - parity
580
566
581 yield l
567 yield l
582
568
569 cl = self.repo.changelog
583 count = cl.count()
570 count = cl.count()
584 start = max(0, count - self.maxchanges)
571 start = max(0, count - self.maxchanges)
585 end = min(count, start + self.maxchanges)
572 end = min(count, start + self.maxchanges)
586
573
587 yield self.t("summary",
574 yield self.t("summary",
588 desc = self.config("web", "description", "unknown"),
575 desc=self.config("web", "description", "unknown"),
589 owner = (self.config("ui", "username") or # preferred
576 owner=(self.config("ui", "username") or # preferred
590 self.config("web", "contact") or # deprecated
577 self.config("web", "contact") or # deprecated
591 self.config("web", "author", "unknown")), # also
578 self.config("web", "author", "unknown")), # also
592 lastchange = cl.read(cl.tip())[2],
579 lastchange=cl.read(cl.tip())[2],
593 tags = tagentries,
580 tags=tagentries,
594 heads = heads,
581 heads=heads,
595 shortlog = changelist,
582 shortlog=changelist,
596 node = hex(cl.tip()),
583 node=hex(cl.tip()),
597 archives=self.archivelist("tip"))
584 archives=self.archivelist("tip"))
598
585
599 def filediff(self, fctx):
586 def filediff(self, fctx):
General Comments 0
You need to be logged in to leave comments. Login now