mercurial/hgweb.py
changeset 1579 85803ec2daab
parent 1575 0a1cca912fda
child 1606 ba625c8083d8
equal deleted inserted replaced
1578:4a14edbda3ca 1579:85803ec2daab
   630         def entries(**map):
   630         def entries(**map):
   631             parity = 0
   631             parity = 0
   632             for k,n in i:
   632             for k,n in i:
   633                 yield {"parity": parity,
   633                 yield {"parity": parity,
   634                        "tag": k,
   634                        "tag": k,
   635 		       "tagmanifest": hex(cl.read(n)[0]),
   635                        "tagmanifest": hex(cl.read(n)[0]),
   636 		       "date": cl.read(n)[2],
   636                        "date": cl.read(n)[2],
   637                        "node": hex(n)}
   637                        "node": hex(n)}
   638                 parity = 1 - parity
   638                 parity = 1 - parity
   639 
   639 
   640         yield self.t("tags",
   640         yield self.t("tags",
   641                      manifest=hex(mf),
   641                      manifest=hex(mf),
   648         i = self.repo.tagslist()
   648         i = self.repo.tagslist()
   649         i.reverse()
   649         i.reverse()
   650 
   650 
   651         def tagentries(**map):
   651         def tagentries(**map):
   652             parity = 0
   652             parity = 0
   653 	    count = 0
   653             count = 0
   654             for k,n in i:
   654             for k,n in i:
   655                 if k == "tip":		# skip tip
   655                 if k == "tip": # skip tip
   656                     continue;
   656                     continue;
   657 
   657 
   658                 count += 1
   658                 count += 1
   659                 if count > 10:		# limit to 10 tags
   659                 if count > 10: # limit to 10 tags
   660                     break;
   660                     break;
   661 
   661 
   662                 c = cl.read(n)
   662                 c = cl.read(n)
   663                 m = c[0]
   663                 m = c[0]
   664                 t = c[2]
   664                 t = c[2]
   665                 
   665 
   666                 yield self.t("tagentry",
   666                 yield self.t("tagentry",
   667                              parity = parity,
   667                              parity = parity,
   668                              tag = k,
   668                              tag = k,
   669                              node = hex(n),
   669                              node = hex(n),
   670                              date = t,
   670                              date = t,
   671                              tagmanifest = hex(m))
   671                              tagmanifest = hex(m))
   672                 parity = 1 - parity
   672                 parity = 1 - parity
   673         
   673 
   674         def changelist(**map):
   674         def changelist(**map):
   675             parity = 0
   675             parity = 0
   676             cl = self.repo.changelog
   676             cl = self.repo.changelog
   677             l = [] # build a list in forward order for efficiency
   677             l = [] # build a list in forward order for efficiency
   678             for i in range(start, end):
   678             for i in range(start, end):
   700         start = max(0, count - self.maxchanges)
   700         start = max(0, count - self.maxchanges)
   701         end = min(count, start + self.maxchanges)
   701         end = min(count, start + self.maxchanges)
   702         pos = end - 1
   702         pos = end - 1
   703 
   703 
   704         yield self.t("summary",
   704         yield self.t("summary",
   705 		 desc = self.repo.ui.config("web", "description", "unknown"),
   705                  desc = self.repo.ui.config("web", "description", "unknown"),
   706 		 owner = (self.repo.ui.config("ui", "username") or # preferred
   706                  owner = (self.repo.ui.config("ui", "username") or # preferred
   707                           self.repo.ui.config("web", "contact") or # deprecated
   707                           self.repo.ui.config("web", "contact") or # deprecated
   708                           self.repo.ui.config("web", "author", "unknown")), # also
   708                           self.repo.ui.config("web", "author", "unknown")), # also
   709 		 lastchange = (0, 0), # FIXME
   709                  lastchange = (0, 0), # FIXME
   710                  manifest = hex(mf),
   710                  manifest = hex(mf),
   711                  tags = tagentries,
   711                  tags = tagentries,
   712                  shortlog = changelist)
   712                  shortlog = changelist)
   713  
   713 
   714     def filediff(self, file, changeset):
   714     def filediff(self, file, changeset):
   715         cl = self.repo.changelog
   715         cl = self.repo.changelog
   716         n = self.repo.lookup(changeset)
   716         n = self.repo.lookup(changeset)
   717         changeset = hex(n)
   717         changeset = hex(n)
   718         p1 = cl.parents(n)[0]
   718         p1 = cl.parents(n)[0]
   870         elif req.form['cmd'][0] == 'tags':
   870         elif req.form['cmd'][0] == 'tags':
   871             req.write(self.tags())
   871             req.write(self.tags())
   872 
   872 
   873         elif req.form['cmd'][0] == 'summary':
   873         elif req.form['cmd'][0] == 'summary':
   874             req.write(self.summary())
   874             req.write(self.summary())
   875 	    
   875 
   876         elif req.form['cmd'][0] == 'filediff':
   876         elif req.form['cmd'][0] == 'filediff':
   877             req.write(self.filediff(req.form['file'][0], req.form['node'][0]))
   877             req.write(self.filediff(req.form['file'][0], req.form['node'][0]))
   878 
   878 
   879         elif req.form['cmd'][0] == 'file':
   879         elif req.form['cmd'][0] == 'file':
   880             req.write(self.filerevision(req.form['file'][0], req.form['filenode'][0]))
   880             req.write(self.filerevision(req.form['file'][0], req.form['filenode'][0]))