Mercurial > hgbook
changeset 381:991befd0025c
more hook.tex
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 19 Feb 2009 14:59:58 +0900 |
parents | 38f034c1da53 |
children | d64d38d2a91a |
files | ja/hook.tex ja/todo.txt |
diffstat | 2 files changed, 61 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/ja/hook.tex Thu Feb 19 14:37:50 2009 +0900 +++ b/ja/hook.tex Thu Feb 19 14:59:58 2009 +0900 @@ -641,52 +641,79 @@ \subsection{$B%U%C%/%Q%i%a!<%?(B} \label{sec:hook:param} -Mercurial calls each hook with a set of well-defined parameters. In -Python, a parameter is passed as a keyword argument to your hook -function. For an external program, a parameter is passed as an -environment variable. +%Mercurial calls each hook with a set of well-defined parameters. In +%Python, a parameter is passed as a keyword argument to your hook +%function. For an external program, a parameter is passed as an +%environment variable. + +Mercurial$B$O3F!9$N%U%C%/$N8F=P$7$N:]$K$-$A$s$HDj5A$5$l$?%Q%i%a!<%?$rEO(B +$B$9!%(BPython$B$G$O%Q%i%a!<%?$O%-!<%o!<%I0z?t$H$7$F%U%C%/4X?t$KEO$5$l$k!%30It(B +$B%W%m%0%i%`$K$O!$%Q%i%a!<%?$O4D6-JQ?t$H$7$FEO$5$l$k!%(B -Whether your hook is written in Python or as a shell script, the -hook-specific parameter names and values will be the same. A boolean -parameter will be represented as a boolean value in Python, but as the -number 1 (for ``true'') or 0 (for ``false'') as an environment -variable for an external hook. If a hook parameter is named -\texttt{foo}, the keyword argument for a Python hook will also be -named \texttt{foo}, while the environment variable for an external -hook will be named \texttt{HG\_FOO}. +%Whether your hook is written in Python or as a shell script, the +%hook-specific parameter names and values will be the same. A boolean +%parameter will be represented as a boolean value in Python, but as the +%number 1 (for ``true'') or 0 (for ``false'') as an environment +%variable for an external hook. If a hook parameter is named +%\texttt{foo}, the keyword argument for a Python hook will also be +%named \texttt{foo}, while the environment variable for an external +%hook will be named \texttt{HG\_FOO}. + +$B%U%C%/$,(BPython$B$G=q$+$l$F$$$k$+!$%7%'%k%9%/%j%W%H$7$F=q$+$l$F$$$k$+$K4X$o(B +$B$i$:!$%U%C%/8GM-$N%Q%i%a!<%?L>$HCM$OF1$8$b$N$,MQ$$$i$l$k!%%V!<%k7?%Q%i%a!<(B +$B%?$O(BPython$B$G$O%V!<%kCM$H$7$F07$o$l$k$,!$30It%U%C%/$N$?$a$N4D6-JQ?t$G(B +$B$O!$(B1$B!J(B``$B??(B''$B!K$^$?$O(B0$B!J(B``$B56(B''$B!K$H$$$&?tCM$H$7$F07$o$l$k!%(B +$B%U%C%/%Q%i%a!<%?$K(B\texttt{foo}$B$H$$$&L>A0$,IU$1$i$l$F$$$k$H$-!$(BPython$B%U%C(B +$B%/$X$N%-!<%o!<%I0z?t$bF1$8(B\texttt{foo}$B$H$$$&L>A0$K$J$k!%(B +$B0lJ}!$30It%U%C%/$N$?$a$N4D6-JQ?t$G$O(B\texttt{HG\_FOO}$B$H$$$&L>A0$K$J$k!%(B %\subsection{Hook return values and activity control} \subsection{$B%U%C%/$NLa$jCM$HF0:n$N@)8f(B} -A hook that executes successfully must exit with a status of zero if -external, or return boolean ``false'' if in-process. Failure is -indicated with a non-zero exit status from an external hook, or an -in-process hook returning boolean ``true''. If an in-process hook -raises an exception, the hook is considered to have failed. +%A hook that executes successfully must exit with a status of zero if +%external, or return boolean ``false'' if in-process. Failure is +%indicated with a non-zero exit status from an external hook, or an +%in-process hook returning boolean ``true''. If an in-process hook +%raises an exception, the hook is considered to have failed. -For a hook that controls whether an activity can proceed, zero/false -means ``allow'', while non-zero/true/exception means ``deny''. +%For a hook that controls whether an activity can proceed, zero/false +%means ``allow'', while non-zero/true/exception means ``deny''. %\subsection{Writing an external hook} \subsection{$B30It%U%C%/$r:n@.$9$k(B} -When you define an external hook in your \hgrc\ and the hook is run, -its value is passed to your shell, which interprets it. This means -that you can use normal shell constructs in the body of the hook. +%When you define an external hook in your \hgrc\ and the hook is run, +%its value is passed to your shell, which interprets it. This means +%that you can use normal shell constructs in the body of the hook. + +$B30It%U%C%/$r(B \hgrc\ $B$GDj5A$7!$<B9T$9$k>l9g!$%U%C%/$O%7%'%k$KEO$5$l$kCM$r(B +$BJQ49$9$?$a!$%U%C%/$NK\BNItJ,$G%7%'%k%9%/%j%W%H$r5-=R$9$k$3$H$,$G$-$k!%(B -An executable hook is always run with its current directory set to a -repository's root directory. +%An executable hook is always run with its current directory set to a +%repository's root directory. + +$B30It%U%C%/$O>o$K%j%]%8%H%j$N%k!<%H%G%#%l%/%H%j$r%+%l%s%H%G%#%l%/%H%j$H$7(B +$B$F<B9T$5$l$k!%(B + +%Each hook parameter is passed in as an environment variable; the name +%is upper-cased, and prefixed with the string ``\texttt{HG\_}''. -Each hook parameter is passed in as an environment variable; the name -is upper-cased, and prefixed with the string ``\texttt{HG\_}''. +$B3F!9$N%U%C%/%Q%i%a!<%?$O4D6-JQ?t$H$7$FEO$5$l$k!%$9$J$o$A!$L>A0$OA4$FBgJ8(B +$B;z$K$J$j!$(B``\texttt{HG\_}''$B$H$$$&@\F,<-$,IU$1$i$l$k!%(B -With the exception of hook parameters, Mercurial does not set or -modify any environment variables when running a hook. This is useful -to remember if you are writing a site-wide hook that may be run by a -number of different users with differing environment variables set. -In multi-user situations, you should not rely on environment variables -being set to the values you have in your environment when testing the -hook. +%With the exception of hook parameters, Mercurial does not set or +%modify any environment variables when running a hook. This is useful +%to remember if you are writing a site-wide hook that may be run by a +%number of different users with differing environment variables set. +%In multi-user situations, you should not rely on environment variables +%being set to the values you have in your environment when testing the +%hook. + +$B%U%C%/%Q%i%a!<%?$rNc30$H$7$F!$(BMercurial$B$O%U%C%/$r<B9T$9$k:]$K4D6-JQ?t$NDj(B +$B5A$dJQ99$r9T$o$J$$!%B?$/$N%f!<%6$,<B9T$9$k%5%$%H%o%$%I$N%U%C%/$r:n@.$9$k(B +$B>l9g!$%f!<%6$,@_Dj$7$F$$$k4D6-JQ?t$O0[$J$k$3$H$r5-21$7$F$*$/$Y$-$G$"$k!%(B +$B%^%k%A%f!<%64D6-$N>l9g!$%U%C%/$r;n$9:]$K$"$J$?$,@_Dj$7$F$$$k4D6-JQ?t$K0M(B +$BB8$9$Y$-$G$O$J$$!%(B %\subsection{Telling Mercurial to use an in-process hook} \subsection{Mercurial$B$K%W%m%;%9Fb%U%C%/$r;H$&$h$&$K;X<($9$k(B}