templates & aligning output text

Giorgos Keramidas keramida at ceid.upatras.gr
Wed Feb 14 12:25:28 UTC 2007


Hi all,

Is there any way too 'align' output of the commands which understand
the --template option?  For example, with a repository like this:

% keramida at kobe:/tmp/hgtest$ hg log
% changeset:   2:41fdbd6ef10f
% tag:         tip
% parent:      0:8dd7aa1bf135
% user:        Giorgos Keramidas <keramida at ceid.upatras.gr>
% date:        Wed Feb 14 14:13:59 2007 +0200
% summary:     commit in default branch
% 
% changeset:   1:4a9fa0dd6df7
% branch:      release-1.0-branch
% user:        Giorgos Keramidas <keramida at ceid.upatras.gr>
% date:        Wed Feb 14 14:12:52 2007 +0200
% summary:     branch alpha
% 
% changeset:   0:8dd7aa1bf135
% user:        test
% date:        Wed Feb 14 14:11:48 2007 +0200
% summary:     add alpha
% 
% keramida at kobe:/tmp/hgtest$

One can use:

% keramida at kobe:/tmp/hgtest$ hg log --template '{rev}:{node|short} {author|email}\n'
% 2:41fdbd6ef10f keramida at ceid.upatras.gr
% 1:4a9fa0dd6df7 keramida at ceid.upatras.gr
% 0:8dd7aa1bf135 test
% keramida at kobe:/tmp/hgtest$

But reverse the order of the template fields, and output is misaligned
in a terminal:

% keramida at kobe:/tmp/hgtest$ hg log --template '{author|email} {rev}:{node|short}\n'
% keramida at ceid.upatras.gr 2:41fdbd6ef10f
% keramida at ceid.upatras.gr 1:4a9fa0dd6df7
% test 0:8dd7aa1bf135
% keramida at kobe:/tmp/hgtest$

Using a TAB in the template isn't always a good enough trick:

% keramida at kobe:/tmp/hgtest$ hg log --template '{author|email}\t{rev}:{node|short}\n'
% keramida at ceid.upatras.gr        2:41fdbd6ef10f
% keramida at ceid.upatras.gr        1:4a9fa0dd6df7
% test    0:8dd7aa1bf135
% keramida at kobe:/tmp/hgtest$ 

Is there some way to specify a width for template fields, and then have
the template code left-align, right-align or center text within that
width?

- Giorgos




More information about the Mercurial mailing list