[PATCH 1 of 2] templater: allow filters to take arguments

Patrick Mézard pmezard at gmail.com
Sat Jan 3 08:40:22 CST 2009

Brendan Cully a écrit :
> # HG changeset patch
> # User Brendan Cully <brendan at kublai.com>
> # Date 1227136848 28800
> # Node ID 14ccbb1141d7d5a05642d0813e49733798ac3a5e
> # Parent  92c952c4470c41647a30184b21466554021d580e
> templater: allow filters to take arguments

+1 for the feature, the implementation looks correct.

Apart from the "any sufficiently complicated Python program..." feeling, I am a bit worried about the performance hit of:
- Having so much char level parsing in python (especially the escape sequences handling routine)
- Defining so many local parsing functions in templater._process()

For instance, best of 4 runs of 'time hg log --style changelog >/dev/null' on Mercurial repo is:

* Before the patch:

real    0m6.624s
user    0m6.274s
sys     0m0.339s

* After the patch

real    0m8.567s
user    0m8.224s
sys     0m0.332s

This is not a minor hit, I have not doubt it can be addressed, and it should before going live.

Finally, it would be great to have a better documentation about what the templater do. templater docstring is really too short. It's hard to tell what is the general syntax understood, examples about how all these filters/formats/functions interact would be great.

Again, this could be addressed in future patches.

As a side note, I would have preferred this patch to be split in [1] templater rewriting more recursively, [2] functions arguments support, but it might not have made sense when writing it.

Patrick Mézard

More information about the Mercurial-devel mailing list