2

I'm writing an extension for which it would be very convenient to be able to perform some logic after a rollback is made.

I looked through all of the documentation I could find on hooks, but I couldn't find a rollback hook. I also tried the post-* hooks (namely, post-rollback), but that also didn't fire. My next step would be to dive into the source, but I thought I'd ask this question in case someone knows.

Is there a rollback hook? And if so, is it possible to wire it up in a Python extension using uisetup() or reposetup()?

voithos
  • 68,482
  • 12
  • 101
  • 116
  • If it's not in the documentation, then it probably doesn't exist. What are you trying to to? – Richard Cook Aug 05 '13 at 22:52
  • @RichardCook: I've built an extension that keeps metadata on commits as I make them (the extension registers itself as a commit hook). Unfortunately, since there is no rollback hook, there's no explicit way for the extension to clean up after itself. – voithos Aug 05 '13 at 22:59
  • I scoured the documentation and I can't find anything. You'll probably have to write your own custom command and call that instead of `rollback`. – Richard Cook Aug 06 '13 at 14:19
  • @RichardCook: Indeed, it seems like there is no such hook. I ended up writing a custom command, as you said, to clean up incorrect state. – voithos Aug 06 '13 at 16:13

1 Answers1

0

After looking around Mercurial's source code, indeed, the internal rollback function (_rollback) doesn't seem to be calling any hooks, so there doesn't seem to be a way to tie in to this event.

I needed the rollback hook because I was writing an extension which maintained metadata about changesets as they occurred. In lieu of being able to tie-in to the rollback event, I ended up writing a custom command as part of the extension to auto-clean any inconsistent state by itself (e.g. a reference to a commit that no longer exists because it was rollback'd).

voithos
  • 68,482
  • 12
  • 101
  • 116