[PATCH 6 of 6] show: show all namespaces in "work" view

Yuya Nishihara yuya at tcha.org
Sun Jun 25 07:43:16 EDT 2017


On Sat, 24 Jun 2017 15:13:52 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1498342265 25200
> #      Sat Jun 24 15:11:05 2017 -0700
> # Node ID 1992c1fd8f8babe1ea4b91dab7ae7b81977c94c5
> # Parent  fca3aaf4880d79672d6301e3d40a94ec284dc548
> show: show all namespaces in "work" view

> I'm not a big fan of the complexity in the templating layer. There
> is a lot of code to basically filter out the special case of
> branch=='default' and tag=='tip'. Ideally, we would iterate over
> a data structure that had irrelevant/unwanted names pre-filtered.
> However, I wasn't sure how to best implement this. We probably
> want {namespaces} to emit everything (its current behavior). I
> was toying with the following:
> 
> * {namespacesnondefaults} variation that filtered values
> * A filter function that operated on {namespaces} (I wasn't sure
>   how to implement this since the filtering layer would see a
>   "hybrid" instance as opposed to something that was definitely
>   an iterable of namespaces.)
> * A namespaces(...) function where you could specify which values
>   to return. I like this the most. But it really wants named
>   arguments to control filtering and we only support named arguments
>   on revsets, not templates.

It's there. See pad() for example.

> +# 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_others = '{if(names, " ({label('log.{colorname}', join(names, ' '))})")}'

Maybe we'll need a switch expression?

  {case(namespace,
        "branches" => names_branches,
        "tags" => names_tags,
        names_others)}

('=>' instead of '=' because '=' is parsed as (key symbol, value) pair)


More information about the Mercurial-devel mailing list