hgbook.red-bean.com, hook-writing, and documentation

Ben Sizer bens at monumentalgames.com
Fri Apr 23 08:10:00 CDT 2010


-----Original Message-----
> From: gerg.ward at gmail.com [mailto:gerg.ward at gmail.com] On Behalf Of Greg
> Ward
>
> This doesn't really answer your question, but I started a wiki page
> for example hooks a while back:
> http://mercurial.selenic.com/wiki/HookExamples.  Could be useful.

Yes, I mentioned that page in my original post, but maybe it was obscured by the mass of boilerplate our company email system appends at the end of each message. ;)  (Sorry about that.)

I've just about managed to hack through and get my hook working by relying on trial and error, and some introspection such as the following hook:


  def show_me_the_arguments(ui, repo, hooktype, **kwargs):
      for (key, value) in kwargs.items():
          ui.write("%s => %s\n" % (key, value))
      return True


For example, this told me that there is a 'pending' argument passed to the pretxncommit hook... no idea what it is or what it does.

I also found out that "for filename in repo[none]", despite the docs implying that it would iterate over the files you've changed, actually in my case iterates over every single file in the repository. Rather strange. (But no doubt someone who understands Mercurial better than I would disagree.) Iterating over repo[none].files() was what I needed.

-- 
Ben Sizer



More information about the Mercurial mailing list