mercurial/hgweb/webcommands.py
changeset 8352 eefcb59d44d6
parent 8236 9f53e203a09b
child 8354 418ea63f00fb
--- a/mercurial/hgweb/webcommands.py	Tue May 12 11:27:26 2009 +0200
+++ b/mercurial/hgweb/webcommands.py	Tue May 12 09:43:36 2009 +0200
@@ -19,8 +19,8 @@
 
 __all__ = [
    'log', 'rawfile', 'file', 'changelog', 'shortlog', 'changeset', 'rev',
-   'manifest', 'tags', 'summary', 'filediff', 'diff', 'annotate', 'filelog',
-   'archive', 'static', 'graph',
+   'manifest', 'tags', 'branches', 'summary', 'filediff', 'diff', 'annotate',
+   'filelog', 'archive', 'static', 'graph',
 ]
 
 def log(web, req, tmpl):
@@ -358,6 +358,26 @@
                 entriesnotip=lambda **x: entries(True,0, **x),
                 latestentry=lambda **x: entries(True,1, **x))
 
+def branches(web, req, tmpl):
+    b = web.repo.branchtags()
+    l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()]
+    parity = paritygen(web.stripecount)
+
+    def entries(limit, **map):
+        count = 0
+        for r, n, t in sorted(l):
+            if limit > 0 and count >= limit:
+                return
+            count += 1
+            yield {'parity': parity.next(),
+                   'branch': t,
+                   'node': hex(n),
+                   'date': web.repo[n].date()}
+
+    return tmpl('branches', node=hex(web.repo.changelog.tip()),
+                entries=lambda **x: entries(0, **x),
+                latestentry=lambda **x: entries(1, **x))
+
 def summary(web, req, tmpl):
     i = web.repo.tagslist()
     i.reverse()