Bug 4842 - allow template aliases to be defined in config
Summary: allow template aliases to be defined in config
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: templater (show other bugs)
Version: earlier
Hardware: PC Windows
: wish feature
Assignee: Yuya Nishihara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-24 16:45 UTC by Ryan McElroy
Modified: 2016-04-24 00:00 UTC (History)
6 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan McElroy 2015-09-24 16:45 UTC
We have command aliases and revset aliases. We should have template aliases as well.

Proposal:

  [templates]
  mydata = '{branches} {bookmarks}'
  mylog = '{desc|firstline} {mydata}'

  [ui]
  logtemplate='{mylog}\n'

This would make composing log templates much better.
Comment 1 Matt Mackall 2015-09-24 17:28 UTC
Your proposal is that this would then be the default log output? This falls afoul of the same reasoning that leads us to discourage using [defaults].

Users who want to personalize their interface should use personal aliases. Otherwise, people and tools who are supporting those people are going to need a --turn-off-this-users-idiocyncratic-weirdness-but-not-our-site-config flag.
Comment 2 Pierre-Yves David 2015-09-24 18:59 UTC
The 'ui.logtemplate' is not the point of the report above. Especially because 'ui.logtemplare' -is-already-something-we-have-. It was included as an exemple of usage The point here is the [templates] section that allow definition of subtemplate.
Comment 3 Augie Fackler 2015-09-24 22:20 UTC
Yeah, I'd be a big fan of this kind of shorthand being possible. revset aliases cleaned up my revsets a lot, this would let me clean up my templates a good bit too.
Comment 4 HG Bot 2016-04-16 17:45 UTC
Fixed by https://selenic.com/repo/hg/rev/d813132ea361
Yuya Nishihara <yuya@tcha.org>
templater: load and expand aliases by template engine (API) (issue4842)

Now template aliases are fully supported in log and formatter templates.

As I said before, aliases are not expanded in map files. This avoids possible
corruption of our stock styles and web templates. This behavior is undocumented
since no map file nor [templates] section are documented at all. Later on,
we might want to add [aliases] section to map files if it appears to be useful.

(please test the fix)
Comment 5 Bugzilla 2016-04-24 00:00 UTC
Bug was set to TESTING for 7 days, resolving