0

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
hko
  • 923
  • 9
  • 17

1 Answers1

1

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

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • thanks, I will accept this answer soon, I'm just about to test and finish the hook, as there are some key issues I had to solve, so this answer was a mere finger pointing, but still worth the "accepted answer thanks" – hko Nov 05 '13 at 23:36
  • If you post the hook and some info about the issues you had and how you solved them, I'll upvote your answer. – Aaron Digulla Nov 06 '13 at 08:23
  • I'll add my answer soon.. have to finish that project next week and so the hook has to be "finalized" – hko Nov 16 '13 at 01:37