Patchwork [6,of,6] hgweb: wrap {branch} and {changesetbranch} by hybridlist()

login
register
mail settings
Submitter Yuya Nishihara
Date May 8, 2018, 1:45 p.m.
Message ID <b8887d7a2962c450cb9d.1525787133@mimosa>
Download mbox | patch
Permalink /patch/31380/
State Accepted
Headers show

Comments

Yuya Nishihara - May 8, 2018, 1:45 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522595199 -32400
#      Mon Apr 02 00:06:39 2018 +0900
# Node ID b8887d7a2962c450cb9d1aa2be447f102ae776ab
# Parent  2fc6f64325ac21c8ed667453c1c62784a082667f
hgweb: wrap {branch} and {changesetbranch} by hybridlist()

This is also a 0/1-length list of a simple value, can be a hybrid list.
Appears that we have many {branch} variants.
Anton Shestakov - May 9, 2018, 5:29 a.m.
On Tue, 08 May 2018 22:45:33 +0900
Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1522595199 -32400
> #      Mon Apr 02 00:06:39 2018 +0900
> # Node ID b8887d7a2962c450cb9d1aa2be447f102ae776ab
> # Parent  2fc6f64325ac21c8ed667453c1c62784a082667f
> hgweb: wrap {branch} and {changesetbranch} by hybridlist()

Queued, thanks.

> Appears that we have many {branch} variants.

Yeah, and json hgweb style has yet another "variant" of:

  if(branch, branch%changesetbranch, "default"|json)

In fact, it looks like a perfect candidate for switching to regular
templater system/keywords.

Just thinking out loud.

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -271,8 +271,8 @@  def nodebranchnodefault(ctx):
     branches = []
     branch = ctx.branch()
     if branch != 'default':
-        branches.append({"name": branch})
-    return branches
+        branches.append(branch)
+    return templateutil.hybridlist(branches, name='name')
 
 def showtag(repo, tmpl, t1, node=nullid, **args):
     args = pycompat.byteskwargs(args)