diff mercurial/hgweb.py @ 1572:385b8872b8e3

[hgweb] Initial import of the "gitweb" style
author Josef "Jeff" Sipek <jeffpc@optonline.net>
date Mon, 05 Dec 2005 04:30:47 -0500
parents 59b3639df0a9
children 32b091ce4026
line wrap: on
line diff
--- a/mercurial/hgweb.py	Thu Dec 01 10:51:45 2005 -0600
+++ b/mercurial/hgweb.py	Mon Dec 05 04:30:47 2005 -0500
@@ -632,6 +632,7 @@
             for k,n in i:
                 yield {"parity": parity,
                        "tag": k,
+		       "date": cl.read(n)[2],
                        "node": hex(n)}
                 parity = 1 - parity
 
@@ -639,6 +640,76 @@
                      manifest=hex(mf),
                      entries=entries)
 
+    def summary(self):
+        cl = self.repo.changelog
+        mf = cl.read(cl.tip())[0]
+
+        i = self.repo.tagslist()
+        i.reverse()
+
+        def tagentries(**map):
+            parity = 0
+	    count = 0
+            for k,n in i:
+                if k == "tip":		# skip tip
+                    continue;
+
+                count += 1
+                if count > 10:		# limit to 10 tags
+                    break;
+
+                c = cl.read(n)
+                m = c[0]
+                t = c[2]
+                
+                yield self.t("tagentry",
+                             parity = parity,
+                             tag = k,
+                             node = hex(n),
+                             date = t,
+                             manifest = hex(m))
+                parity = 1 - parity
+        
+        def changelist(**map):
+            parity = 0
+            cl = self.repo.changelog
+            l = [] # build a list in forward order for efficiency
+            for i in range(start, end):
+                n = cl.node(i)
+                changes = cl.read(n)
+                hn = hex(n)
+                t = changes[2]
+
+                l.insert(0, self.t(
+                    'shortlogentry',
+                    parity = parity,
+                    author = changes[1],
+                    manifest = hex(changes[0]),
+                    desc = changes[4],
+                    date = t,
+                    rev = i,
+                    node = hn))
+                parity = 1 - parity
+
+            yield l
+
+        cl = self.repo.changelog
+        mf = cl.read(cl.tip())[0]
+        count = cl.count()
+        start = max(0, count - self.maxchanges)
+        end = min(count, start + self.maxchanges)
+        pos = end - 1
+
+        yield self.t("summary",
+		 desc = self.repo.ui.config("web", "description", "unknown"),
+		 owner = (self.repo.ui.config("ui", "username") or # preferred
+                          self.repo.ui.config("web", "contact") or # deprecated
+                          self.repo.ui.config("web", "author", "unknown")), # also
+		 lastchange = (0, 0), # FIXME
+                 manifest = hex(mf),
+                 tags = tagentries,
+                 shortlog = changelist)
+ 
     def filediff(self, file, changeset):
         cl = self.repo.changelog
         n = self.repo.lookup(changeset)
@@ -798,6 +869,9 @@
         elif req.form['cmd'][0] == 'tags':
             req.write(self.tags())
 
+        elif req.form['cmd'][0] == 'summary':
+            req.write(self.summary())
+	    
         elif req.form['cmd'][0] == 'filediff':
             req.write(self.filediff(req.form['file'][0], req.form['node'][0]))