[PATCH 1 of 2] webcommands: add 'branches' command, similar to 'tags'

Sune Foldager cryo at cyanite.org
Sun May 10 11:34:17 CDT 2009


# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1241973019 -7200
# Node ID 844654f584c8629525a2a7a2d6a0dd6ddb8922d8
# Parent  493d23d923eac33073f8ff2eb93d0d1c78a625d9
webcommands: add 'branches' command, similar to 'tags'

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -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,22 @@
                 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(**map):
+        for r,n,t in sorted(l):
+            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(**x))
+
 def summary(web, req, tmpl):
     i = web.repo.tagslist()
     i.reverse()


More information about the Mercurial-devel mailing list