1

I have been looking into writing an extension for Mercurial and have found this documentation.

From what I can see, you can create new commands within the Mercurial environment but what I was hoping to achieve however, was to override an existing command like the commit command. My override would contain logic and if it passes it would then call the original commit super function.

Is it possible to extend the functionality of pre-existing Mercurial commands?

Thanks

Toby Smith
  • 1,505
  • 2
  • 15
  • 24
  • Can you implement your override as a precommit hook instead? – Sigve Kolbeinson Sep 21 '18 at 15:50
  • From what I can tell, hooks are only attached to repositories, rather than computers/accounts/clients. Is this the case? – Toby Smith Sep 21 '18 at 16:03
  • 2
    You can install a hook for the whole system - see the different hgrc locations here: https://www.mercurial-scm.org/repo/hg/help/hgrc . There's a good chapter on hooks here http://hgbook.red-bean.com/read/handling-repository-events-with-hooks.html – Sigve Kolbeinson Sep 22 '18 at 06:51
  • I'd like to emphasize Sigve Kolbeinson's comment: make use of the system-wide hooks. It's common practise to utilize them on servers e.g. for CI purposes. But also on desktops to run certain checkes prior to commit or push – planetmaker Sep 24 '18 at 13:09

0 Answers0