Patchwork [6,of,7] show: stringify filtered list of tags before testing emptiness

login
register
mail settings
Submitter Yuya Nishihara
Date June 12, 2018, 2:49 p.m.
Message ID <0bf2bc3ec4f89f4a847b.1528814948@mimosa>
Download mbox | patch
Permalink /patch/32082/
State Accepted
Headers show

Comments

Yuya Nishihara - June 12, 2018, 2:49 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1528813058 -32400
#      Tue Jun 12 23:17:38 2018 +0900
# Node ID 0bf2bc3ec4f89f4a847b68d00011968732aacd7a
# Parent  bc18058428fc50a9da867e9fd8a3c9f15f133851
show: stringify filtered list of tags before testing emptiness

`names % "{ifeq(name, 'tip', '', name)}"}"` may return [''], which shouldn't
be falsy, but it is thanks to a templater bug. This patch converts [''] to ''
before testing truthness.

Patch

diff --git a/mercurial/templates/map-cmdline.show b/mercurial/templates/map-cmdline.show
--- a/mercurial/templates/map-cmdline.show
+++ b/mercurial/templates/map-cmdline.show
@@ -15,7 +15,8 @@  cset_shortnode = '{labelcset(shortest(no
 # Treat branch and tags specially so we don't display "default" or "tip"
 cset_namespace = '{ifeq(namespace, "branches", names_branches, ifeq(namespace, "tags", names_tags, names_others))}'
 names_branches = '{ifeq(branch, "default", "", " ({label('log.{colorname}', branch)})")}'
-names_tags = '{if(names % "{ifeq(name, 'tip', '', name)}", " ({label('log.{colorname}', join(names % "{ifeq(name, 'tip', '', name)}", ' '))})")}'
+names_tags = '{if(stringify(names % "{ifeq(name, 'tip', '', name)}"),
+                  " ({label('log.{colorname}', join(names % "{ifeq(name, 'tip', '', name)}", ' '))})")}'
 names_others = '{if(names, " ({label('log.{colorname}', join(names, ' '))})")}'
 
 cset_shortdesc = '{label("log.description", desc|firstline)}'