[PATCH 1 of 1] hgweb: added possibility to toggle between displaying closed branches

Erik Zielke ez at aragost.com
Wed Jan 26 14:06:05 UTC 2011


# HG changeset patch
# User Erik Zielke <ez at aragost.com>
# Date 1296050652 -3600
# Node ID e8dfebe6e3ced2aca02636a17260e4b8fbd950cf
# Parent  4b07578967e63df462e6bb683d9d9281d049da9f
hgweb: added possibility to toggle between displaying closed branches

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -389,6 +389,7 @@
     heads = web.repo.heads()
     parity = paritygen(web.stripecount)
     sortkey = lambda ctx: ('close' not in ctx.extra(), ctx.rev())
+    showclosed = req.form.get('node', [None])[0] == 'closed'
 
     def entries(limit, **map):
         count = 0
@@ -402,13 +403,23 @@
                 status = 'closed'
             else:
                 status = 'open'
-            yield {'parity': parity.next(),
-                   'branch': ctx.branch(),
-                   'status': status,
-                   'node': ctx.hex(),
-                   'date': ctx.date()}
+            if status != 'closed' or showclosed:
+                yield {'parity': parity.next(),
+                       'branch': ctx.branch(),
+                       'status': status,
+                       'node': ctx.hex(),
+                       'date': ctx.date()}
+    if showclosed:
+        showhidetext = 'Hide closed'
+        showhideurl = 'branches/'
+    else:
+        showhidetext = 'Show closed'
+        showhideurl = 'branches/closed'
 
-    return tmpl('branches', node=hex(web.repo.changelog.tip()),
+    return tmpl('branches',
+                showhidetext=showhidetext,
+                showhideurl=showhideurl,
+                node=hex(web.repo.changelog.tip()),
                 entries=lambda **x: entries(0, **x),
                 latestentry=lambda **x: entries(1, **x))
 
diff --git a/mercurial/templates/gitweb/branches.tmpl b/mercurial/templates/gitweb/branches.tmpl
--- a/mercurial/templates/gitweb/branches.tmpl
+++ b/mercurial/templates/gitweb/branches.tmpl
@@ -21,6 +21,7 @@
 <a href="{url}file/{node|short}{sessionvars%urlparameter}">files</a> |
 <a href="{url}help{sessionvars%urlparameter}">help</a>
 <br/>
+<a href="{url}{showhideurl}{sessionvars%urlparameter}">{showhidetext}</a><br/>
 </div>
 
 <div class="title"> </div>
diff --git a/mercurial/templates/monoblue/branches.tmpl b/mercurial/templates/monoblue/branches.tmpl
--- a/mercurial/templates/monoblue/branches.tmpl
+++ b/mercurial/templates/monoblue/branches.tmpl
@@ -34,4 +34,8 @@
 {entries%branchentry}
     </table>
 
+    <div class="page-path">
+		<a href="{url}{showhideurl}{sessionvars%urlparameter}">{showhidetext}</a><br/>
+    </div>
+
 {footer}
diff --git a/mercurial/templates/paper/branches.tmpl b/mercurial/templates/paper/branches.tmpl
--- a/mercurial/templates/paper/branches.tmpl
+++ b/mercurial/templates/paper/branches.tmpl
@@ -35,6 +35,10 @@
 files, or words in the commit message</div>
 </form>
 
+<div class="navigate">
+<a href="{url}{showhideurl}{sessionvars%urlparameter}">{showhidetext}</a>
+</div>
+
 <table class="bigtable">
 <tr>
  <th>branch</th>
diff --git a/mercurial/templates/spartan/branches.tmpl b/mercurial/templates/spartan/branches.tmpl
--- a/mercurial/templates/spartan/branches.tmpl
+++ b/mercurial/templates/spartan/branches.tmpl
@@ -20,6 +20,10 @@
 
 <h2>branches:</h2>
 
+<p>
+  <a href="{url}{showhideurl}{sessionvars%urlparameter}">{showhidetext}</a><br/>
+</p>
+
 <ul id="tagEntries">
 {entries%branchentry}
 </ul>



More information about the Mercurial-devel mailing list