Question

Simple scenario: I want to access changesets once before pushed, and send file diff info (in the usual git diff format.. or any other base64-serialisable format) to my own RESTful webservice for checking. I already have a pretxnchangegroup hook setup.. I can access the nodes, but hg export doesn't show any new stuff (as they are probably hidden as decribed here: How do I reject pushes to a Mercurial server based on a script, without risking a bad pull during that time? ), so I guess I'll have to go through the Mercurial API.

The problem: I don't "get" how I can easily access the filechange information in some kind of textual diff format (git diff, whatever..) from the Mercurial API in the hook, there seems to be nothing in the API docs: https://www.mercurial-scm.org/wiki/MercurialApi

Is it just me or is this kind of "dive into the Mercurial codebase" No Man’s Land? Would like to avoid digging so deep, but I will if neccessary.

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top