This is an archive of the discontinued Mercurial Phabricator instance.

templatefuncs: add truncate parameter to pad
ClosedPublic

Authored by mbthomas on Oct 12 2018, 11:52 AM.

Details

Summary

Add a truncate option to pad that additionally truncates the text to the pad
width if it is wider.

Since color codes can cause a problem with this, when the text is truncated,
the color codes are also stripped. Users of the truncate option should label
the text outside the pad.

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

mbthomas created this revision.Oct 12 2018, 11:52 AM

This is necessary to recreate something like the original output for hg absorb using the template language. It also allows inclusion of the commit message in the rows of the absorb output, using a template spec like:

hg absorb -pn -T '{ifeq(linetype,"summary","\n{count} changesets affected",ifeq(linetype,"path","showing changes for {label("absorb.path",path)}","{label("absorb.node", pad(node, 7, truncate=true))} {label("yellow", pad(desc, 30, truncate=true))} {label("diff.{linetype}", "{diffchar}{inserted}{deleted}{hunk}")}"))}\n'
This revision was automatically updated to reflect the committed changes.