You need to import the module patch
. It has a method diff(repo, prev, node, opts=opts)
that gives you a list of chunks back.
Look for the file cmdutil.py
for examples how to use the function; this file contains the code for hg export
(search for def export
).