Template align tags output

Tom Anderson tom.anderson at timgroup.com
Tue Jul 17 12:52:16 UTC 2012


On 17/07/12 08:23, anatoly techtonik wrote:
> I am trying to get what releases contain a specific revision (8bb6).
>
> $ hg log -r "descendants(8bb6) and tag()" --template
> "{tags}\t{rev}:{node|short}\n"
> pyglet-1.0alpha1	936:727c422fcc95
> pyglet-1.0alpha2	1142:f2b5c7e11d7f
> pyglet-1.0beta1	1336:084e5d57609d
> pyglet-1.0beta2	1363:c7eac959dc0c
> pyglet-1.0beta3	1451:b30bbb44efa6
> pyglet-1.0	1543:b5ed21968f06
> pyglet-1.1alpha1	1793:e22423cd9c4a
> pyglet-1.1alpha2	1907:21fb7f6ce977
> pyglet-1.1beta1	1957:ce8a50069a13
> pyglet-1.1beta2	2034:cb3e6f1ed68c
> ...
>
> As you may see the indentation skews and tab doesn't help. Is it
> possible to align the output by columns similar to `hg tags`?

I don't know of a way to do this in Mercurial, but if you're on unix, 
you can pipe the output to column -t to get a nice table.

As long as you don't have any whitespace inside any of your fields. If 
you do, you can bracket the column -t with calls to tr to transpose any 
whitespace you want to preserve into non-whitespace characters and then 
back again. So:

hg log -r "descendants(8bb6) and tag()" --template 
"{tags}\t{rev}:{node|short}\n" | tr ' ' '_' | column -t | tr '_' ' '

It would be useful to have a way to do this within templates, though, so 
you could use it in aliases.

tom

-- 

Tom Anderson | Developer | +44 20 7826 4312 | timgroup.com 
<http://timgroup.com/>

STATEMENT OF CONFIDENTIALITY: The information contained in this 
electronic message and any attachments to this message are intended for 
the exclusive use of the addressee(s) and may contain confidential or 
privileged information. If you are not the intended recipient, please 
notify Tom Anderson at TIM Group at tom.anderson at timgroup.com and 
destroy all copies of this message and any attachments.

TIM Group is the trading name for YouDevise Limited. YouDevise Limited 
is registered in England, No. 3331176. Registered office: 3 Copthall 
Avenue, London, EC2R 7BH.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20120717/07ba4cc8/attachment-0002.html>


More information about the Mercurial mailing list