json output using mercurial templates

Matt Mackall mpm at selenic.com
Tue Nov 30 00:24:29 UTC 2010


On Mon, 2010-11-29 at 19:24 +0000, Matt Hawley wrote:
> With the basic conditionals what were you thinking? We'd love to adopt
> this for doing easy paging via the CodePlex web site vs the manual
> manipulation we currently do of hg.exe.

Well the big piece is having some if a = b then template x else template
y.

But paging is probably best done on objects. For instance, rather than
exploding repo objects out to lists of dicts of changeset attributes, we
could simply expose a "repo" object to the templater that acted like a
list of context objects. Python-speak would be something like:

for x in range(pager(position)):
   showtemplate(repo[x], "{x.author}: {x.description|firstline}")

Translating that into template-speak might look like:

apply(x, repo, pager(position), "{x.author}: {x.description|firstline}")

-- 
Mathematics is the supreme nostalgia of our time.





More information about the Mercurial mailing list