mercurial/templates/map-cmdline.show
author Gregory Szorc <gregory.szorc@gmail.com>
Sat, 24 Jun 2017 15:11:05 -0700
changeset 33050 0a507da7d8ea
parent 33046 11f768258dcc
child 33197 c5a07a3abe7d
permissions -rw-r--r--
show: show all namespaces in "work" view This commit addresses a number of deficiencies in `hg show work`'s output: * Failure to render tags (it just wasn't implemented) * Failure to render names associated with non-built-in namespaces (e.g. remotenames) * Color names were hardcoded instead of coming from the canonical source in the namespace This change has the intended effect of rendering tags and extra namespaces. It solves an immediate need at Mozilla of having names from a custom namespace printed, which is blocking us from switching from a custom `hg wip` revset/template combo to `hg show work`. Note that the order of branches and bookmarks changes. This is because bookmarks are registered before branches in namespaces.py. We may want to register them last, after tags and branches. Or we may want to added a weighted field to the namespace to control display order. Something to think about. 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. I figure perfect is the enemy of good and we can refine templating support for namespaces in the future. At least now we have a concrete example of a use case.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32059
0ea1d9a750da show: add basic labels to work template
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32058
diff changeset
     1
# TODO there are a few deficiencies in this file:
0ea1d9a750da show: add basic labels to work template
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32058
diff changeset
     2
# * The "namespace" of the labels needs to be worked out. We currently
0ea1d9a750da show: add basic labels to work template
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32058
diff changeset
     3
#   piggyback on existing values so color works.
0ea1d9a750da show: add basic labels to work template
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32058
diff changeset
     4
# * Obsolescence isn't considered for node labels. See _cset_labels in
0ea1d9a750da show: add basic labels to work template
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32058
diff changeset
     5
#   map-cmdline.default.
31765
264baeef3588 show: new extension for displaying various repository data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, 5)}\n'
33046
11f768258dcc show: construct changeset templater during dispatch
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32059
diff changeset
     7
33050
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
     8
showwork = '{cset_shortnode}{namespaces % cset_namespace} {cset_shortdesc}'
33046
11f768258dcc show: construct changeset templater during dispatch
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32059
diff changeset
     9
11f768258dcc show: construct changeset templater during dispatch
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32059
diff changeset
    10
cset_shortnode = '{label("log.changeset changeset.{phase}", shortest(node, 5))}'
33050
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    11
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    12
# Treat branch and tags specially so we don't display "default" or "tip"
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    13
cset_namespace = '{ifeq(namespace, "branches", names_branches, ifeq(namespace, "tags", names_tags, names_others))}'
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    14
names_branches = '{ifeq(branch, "default", "", " ({label('log.{colorname}', branch)})")}'
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    15
names_tags = '{if(names % "{ifeq(name, 'tip', '', name)}", " ({label('log.{colorname}', join(names % "{ifeq(name, 'tip', '', name)}", ' '))})")}'
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    16
names_others = '{if(names, " ({label('log.{colorname}', join(names, ' '))})")}'
0a507da7d8ea show: show all namespaces in "work" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33046
diff changeset
    17
33046
11f768258dcc show: construct changeset templater during dispatch
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32059
diff changeset
    18
cset_shortdesc = '{label("log.description", desc|firstline)}'