json output using mercurial templates

Haszlakiewicz, Eric EHASZLA at transunion.com
Fri Nov 19 16:04:36 CST 2010

It occurs to me that it would be nice to have a way to generate output in a
more structured format, such as json.

I'm guessing this would probably require a new filter to escape things for
json output (e.g. perhaps something like {desc|jsonscape}), but I think the
rest of the json format can be handled within the template file.

I'm imagining something like: hg log -r 123 --template json
	"revisions": [
			"changesetid": "abcdcbabcbasdbadb1231efega231312",
			"rev": 123,
			"files": { "added": [ "file1.txt", "file2.txt" ] },
			"desc": "Change \"x\" to \"y\".\
foo bar baz.",

Has anyone thought about trying to create templates that create output like this?


More information about the Mercurial mailing list