Show More
@@ -633,10 +633,16 b' def runcommand(lui, repo, cmd, fullargs,' | |||||
633 | # run pre-hook, and abort if it fails |
|
633 | # run pre-hook, and abort if it fails | |
634 | hook.hook(lui, repo, "pre-%s" % cmd, True, args=" ".join(fullargs), |
|
634 | hook.hook(lui, repo, "pre-%s" % cmd, True, args=" ".join(fullargs), | |
635 | pats=cmdpats, opts=cmdoptions) |
|
635 | pats=cmdpats, opts=cmdoptions) | |
636 | ret = _runcommand(ui, options, cmd, d) |
|
636 | try: | |
637 | # run post-hook, passing command result |
|
637 | ret = _runcommand(ui, options, cmd, d) | |
638 | hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs), |
|
638 | # run post-hook, passing command result | |
639 | result=ret, pats=cmdpats, opts=cmdoptions) |
|
639 | hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs), | |
|
640 | result=ret, pats=cmdpats, opts=cmdoptions) | |||
|
641 | except Exception: | |||
|
642 | # run failure hook and re-raise | |||
|
643 | hook.hook(lui, repo, "fail-%s" % cmd, False, args=" ".join(fullargs), | |||
|
644 | pats=cmdpats, opts=cmdoptions) | |||
|
645 | raise | |||
640 | return ret |
|
646 | return ret | |
641 |
|
647 | |||
642 | def _getlocal(ui, rpath, wd=None): |
|
648 | def _getlocal(ui, rpath, wd=None): |
@@ -811,6 +811,15 b' variables it is passed are listed with n' | |||||
811 | dictionary of options (with unspecified options set to their defaults). |
|
811 | dictionary of options (with unspecified options set to their defaults). | |
812 | ``$HG_PATS`` is a list of arguments. Hook failure is ignored. |
|
812 | ``$HG_PATS`` is a list of arguments. Hook failure is ignored. | |
813 |
|
813 | |||
|
814 | ``fail-<command>`` | |||
|
815 | Run after a failed invocation of an associated command. The contents | |||
|
816 | of the command line are passed as ``$HG_ARGS``. Parsed command line | |||
|
817 | arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain | |||
|
818 | string representations of the python data internally passed to | |||
|
819 | <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified | |||
|
820 | options set to their defaults). ``$HG_PATS`` is a list of arguments. | |||
|
821 | Hook failure is ignored. | |||
|
822 | ||||
814 | ``pre-<command>`` |
|
823 | ``pre-<command>`` | |
815 | Run before executing the associated command. The contents of the |
|
824 | Run before executing the associated command. The contents of the | |
816 | command line are passed as ``$HG_ARGS``. Parsed command line arguments |
|
825 | command line are passed as ``$HG_ARGS``. Parsed command line arguments |
@@ -785,4 +785,14 b' outgoing:' | |||||
785 | no changes found |
|
785 | no changes found | |
786 | [1] |
|
786 | [1] | |
787 |
|
787 | |||
|
788 | Test fail hook | |||
|
789 | ||||
|
790 | $ hg push inner --config hooks.fail-push="echo running fail-push hook" | |||
|
791 | pushing to inner | |||
|
792 | searching for changes | |||
|
793 | running fail-push hook | |||
|
794 | abort: push creates new remote head 7d0f4fb6cf04 on branch 'A'! | |||
|
795 | (merge or see "hg help push" for details about pushing new heads) | |||
|
796 | [255] | |||
|
797 | ||||
788 | $ cd .. |
|
798 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now