Edit: this answer here works for any version of hg. for newer versions of hg (3.1+), see another answer which is more efficient and simple.
Here is an example of a solid oneliner.
It uses mercurials hg log and outputs its output to python oneliner. Hg log template configured to output valid python literals. python oneliner converts it to JSON.
hg log --date ">2014-10-01" --no-merges --keyword " mantis@1953 " --keyword " mantis@1955 " --template "[\"{node|short}\",\"{author|user|urlescape}\",\"{date|rfc3339date}\",\"{desc|urlescape}\", [{files % '\"{file}\",'}]]\n" --user marinus --user develop | python -c "import sys,ast,json,urllib; x=[[z[0], urllib.unquote(z[1]).decode('utf8'), z[2], urllib.unquote(z[3]).decode('utf8'), z[4]] for z in [ast.literal_eval(y) for y in sys.stdin.readlines()]]; print(json.dumps(x,indent=2))"
The above example is for unix , but you can just replace \" with "" if you need Windows compatibility. That you want unformatted JSON, set" indent "to None .
The python code is compatible with 2/3 (any modern version) and does not use any external modules.
See below for more information on the hg commands used:
hg help log hg help dates hg help templates
The python code uses the nested list comprehensions , google for more information.
source share