This is an archive of the discontinued Mercurial Phabricator instance.

templates: adding a config() function for template customization
ClosedPublic

Authored by rdamazio on Feb 13 2019, 9:34 PM.

Details

Summary

This allows templates to be written such that users can customize them easily,
or that they can be customized based on other configuration of the system. For
enterprise deployments, we often have complex template aliases, and right now
the only way individual users can customize those is by replacing the whole
template alias (which means they won't get company-wide updates to it anymore,
plus most users don't want to have to get a complex template right).
With this change, they can just set a config option which feeds into our
templates for common changes (e.g. whether to limit commit descriptions to the
width of their terminal or not).

To work around the issue of having to register the config options, I declared
a dedicated section [templateconfig] for these options to be dynamically
declared. They can still reference any other config option that's registered
elsewhere.

I only did string, bool and int at this time - list and date would add other
complications with parsing the default so I'll leave that as an exercise to
the reader :)

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

rdamazio created this revision.Feb 13 2019, 9:34 PM
rdamazio retitled this revision from templates: adding a config() function for template customization. to templates: adding a config() function for template customization.Feb 13 2019, 9:36 PM
durin42 accepted this revision as: durin42.Feb 15 2019, 11:03 PM
durin42 added a subscriber: durin42.

I like this, but can see it being vaguely controversial so I'll only give it a +1 here for now - if I don't see objections in a few days I'll go ahead and land it.

This revision was automatically updated to reflect the committed changes.