Mercurial > hgbook
changeset 379:beab196f78da
- more hook.tex
- more daily.tex
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 15 Jan 2009 16:34:43 +0900 |
parents | 5530934319b8 |
children | 38f034c1da53 |
files | ja/daily.tex ja/hook.tex |
diffstat | 2 files changed, 229 insertions(+), 112 deletions(-) [+] |
line wrap: on
line diff
--- a/ja/daily.tex Fri Jan 09 23:05:26 2009 +0900 +++ b/ja/daily.tex Thu Jan 15 16:34:43 2009 +0900 @@ -54,58 +54,98 @@ %\subsection{Explicit versus implicit file naming} \subsection{$BL@<(E*$J%U%!%$%kL?L>BP0EL[$N%U%!%$%kL?L>(B} -A useful behaviour that Mercurial has is that if you pass the name of -a directory to a command, every Mercurial command will treat this as -``I want to operate on every file in this directory and its -subdirectories''. +%A useful behaviour that Mercurial has is that if you pass the name of +%a directory to a command, every Mercurial command will treat this as +%``I want to operate on every file in this directory and its +%subdirectories''. +%\interaction{daily.files.add-dir} +%Notice in this example that Mercurial printed the names of the files +%it added, whereas it didn't do so when we added the file named +%\filename{a} in the earlier example. + +Mercurial$B$NA4$F$N%3%^%s%I$O!$0z?t$H$7$F%G%#%l%/%H%jL>$rEO$9$H!$%G%#%l%/%H(B +$B%j$NFb$NA4$F$N%U%!%$%k$H%5%V%G%#%l%/%H%j$KBP$9$kA`:n$G$"$k$H2r<a$9$k$?$a(B +$BJXMx$G$"$k!%(B \interaction{daily.files.add-dir} -Notice in this example that Mercurial printed the names of the files -it added, whereas it didn't do so when we added the file named -\filename{a} in the earlier example. +$B$3$NNc$G$O(BMercurial$B$ODI2C$7$?%U%!%$%kL>$rI=<($7$F$$$k$,!$A0$NNc$G(B +\filename{a}$B$H$$$&L>A0$N%U%!%$%k$rDI2C$7$?:]$K$OI=<($7$F$$$J$+$C$?E@$KCm(B +$B0U$5$l$?$$!%(B -What's going on is that in the former case, we explicitly named the -file to add on the command line, so the assumption that Mercurial -makes in such cases is that you know what you were doing, and it -doesn't print any output. +%What's going on is that in the former case, we explicitly named the +%file to add on the command line, so the assumption that Mercurial +%makes in such cases is that you know what you were doing, and it +%doesn't print any output. + +$BA0$NNc$G$O%3%^%s%I%i%$%s$G$I$N%U%!%$%k$rDI2C$9$k$N$+$rL@<(E*$K;XDj$7$?$?(B +$B$a!$(BMercurial$B$O%f!<%6$,2?$r$7$h$&$H$7$F$$$k$N$+J,$+$C$F$$$k$H?dDj$7$F2?$b(B +$BI=<($7$J$+$C$?!%(B -However, when we \emph{imply} the names of files by giving the name of -a directory, Mercurial takes the extra step of printing the name of -each file that it does something with. This makes it more clear what -is happening, and reduces the likelihood of a silent and nasty -surprise. This behaviour is common to most Mercurial commands. +%However, when we \emph{imply} the names of files by giving the name of +%a directory, Mercurial takes the extra step of printing the name of +%each file that it does something with. This makes it more clear what +%is happening, and reduces the likelihood of a silent and nasty +%surprise. This behaviour is common to most Mercurial commands. + +$B$7$+$7%G%#%l%/%H%jL>$rM?$($k$3$H$G%U%!%$%kL>$r0EL[E*$KM?$($?>l9g!"(B +Mercurial$B$O4XO"$9$k%U%!%$%k$NL>A0$r(B1$B$D$:$DI=<($9$kDI2C$N%9%F%C%W$rF'$`!%(B +$B$3$l$K$h$C$F2?$,5/$3$C$F$$$k$N$+M}2r$7$d$9$/$9$k$H6&$K!$D@L[N"$KLq2p$JLd(B +$BBj$,5/$3$k2DG=@-$r8:$i$7$F$$$k!%$3$N5sF0$O(BMercurial$B$NBgH>$N%3%^%s%I$K6&(B +$BDL$7$F$$$k!%(B %\subsection{Aside: Mercurial tracks files, not directories} -\subsection{$B$3$\$lOC(B: Mercurial$B$O%G%#%l%/%H%j$G$O$J$/%U%!%$%k$rDI@W$9$k(B} +\subsection{$BM>CL(B: Mercurial$B$O%G%#%l%/%H%j$G$O$J$/%U%!%$%k$rDI@W$9$k(B} -Mercurial does not track directory information. Instead, it tracks -the path to a file. Before creating a file, it first creates any -missing directory components of the path. After it deletes a file, it -then deletes any empty directories that were in the deleted file's -path. This sounds like a trivial distinction, but it has one minor -practical consequence: it is not possible to represent a completely -empty directory in Mercurial. +%Mercurial does not track directory information. Instead, it tracks +%the path to a file. Before creating a file, it first creates any +%missing directory components of the path. After it deletes a file, it +%then deletes any empty directories that were in the deleted file's +%path. This sounds like a trivial distinction, but it has one minor +%practical consequence: it is not possible to represent a completely +%empty directory in Mercurial. + +Mercurial$B$O%G%#%l%/%H%j>pJs$rDI@W$7$J$$!%$=$NBe$o$j!$%U%!%$%k$X$N%Q%9$rDI(B +$B@W$7$F$$$k!%%U%!%$%k$r:n@.$9$k:]$K$O!$$^$:%Q%9$N%G%#%l%/%H%jItJ,$rJd40$9(B +$B$k!%%U%!%$%k$r>C5n$7$?8e$O!$%U%!%$%k$N4^$^$l$F$$$?6u$N%G%#%l%/%H%j$rA4$F(B +$B>C5n$9$k!%$3$l$OEvA3$N5sF0$N$h$&$K8+$($k$,!$<B:]>e$O>.$5$JLdBj$r0z$-5/$3(B +$B$9!%$9$J$o$A!$(BMercurial$B$O40A4$K6u$N%G%#%l%/%H%j$rI=8=$9$k$3$H$,$G$-$J$$$N(B +$B$G$"$k!%(B -Empty directories are rarely useful, and there are unintrusive -workarounds that you can use to achieve an appropriate effect. The -developers of Mercurial thus felt that the complexity that would be -required to manage empty directories was not worth the limited benefit -this feature would bring. +%Empty directories are rarely useful, and there are unintrusive +%workarounds that you can use to achieve an appropriate effect. The +%developers of Mercurial thus felt that the complexity that would be +%required to manage empty directories was not worth the limited benefit +%this feature would bring. + +$B6u$N%G%#%l%/%H%j$,M-MQ$G$"$k$3$H$OLGB?$K$J$$$,!$E,Ev$J%o!<%/%"%i%&%s%I$H(B +$B$7$F!$%j%]%8%H%j$NF0$-$rK8$2$J$$J}K!$,B8:_$9$k!%(B +Mercurial$B$N3+H/<T$?$A$O!$6u$N%G%#%l%/%H%j$rI=8=$9$k$?$a$K2C$o$kJ#;($5$O!$$=(B +$B$N5!G=$K8+9g$o$J$$$H9M$($?!%(B -If you need an empty directory in your repository, there are a few -ways to achieve this. One is to create a directory, then \hgcmd{add} a -``hidden'' file to that directory. On Unix-like systems, any file -name that begins with a period (``\texttt{.}'') is treated as hidden -by most commands and GUI tools. This approach is illustrated in -figure~\ref{ex:daily:hidden}. +%If you need an empty directory in your repository, there are a few +%ways to achieve this. One is to create a directory, then \hgcmd{add} a +%``hidden'' file to that directory. On Unix-like systems, any file +%name that begins with a period (``\texttt{.}'') is treated as hidden +%by most commands and GUI tools. This approach is illustrated in +%figure~\ref{ex:daily:hidden}. + +$B%j%]%8%H%j$K6u$N%G%#%l%/%H%j$,I,MW$J>l9g!$$3$l$r<B8=$9$kJ}K!$,$$$/$D$+$"(B +$B$k!%(B1$B$DL\$O!$$^$:%G%#%l%/%H%j$r:n@.$7!$1#$7%U%!%$%k$r$3$N%G%#%l%/%H%jFb$K(B +\hgcmd{add}$B$9$k!%(BUnix$B7O%7%9%F%`$G$O!$%T%j%*%I(B(``\texttt{.}'')$B$G;O$^$k%U%!(B +$B%$%k$OBgH>$N%3%^%s%I$H(BGUI$B%D!<%k$G1#$7%U%!%$%k$H$7$F<h$j07$o$l$k!%(B +$B>\:Y$K$D$$$F$O?^(B~\ref{ex:daily:hidden}$B$r;2>H$5$l$?$$!%(B \begin{figure}[ht] \interaction{daily.files.hidden} - \caption{Simulating an empty directory using a hidden file} +% \caption{Simulating an empty directory using a hidden file} + \caption{$B1#$7%U%!%$%k$r;H$C$F6u$N%G%#%l%/%H%j$r%7%_%e%l!<%H$9$k(B} \label{ex:daily:hidden} \end{figure} -Another way to tackle a need for an empty directory is to simply -create one in your automated build scripts before they will need it. +%Another way to tackle a need for an empty directory is to simply +%create one in your automated build scripts before they will need it. + +$B6u$N%G%#%l%/%H%j$r07$&JL$NJ}K!$K$O!$<+F0%S%k%I%9%/%j%W%H$NCf$G!$I,MW$K$J$k(B +$BA0$K:n@.$9$k$3$H$,$"$k!%(B %\section{How to stop tracking a file} \section{$B%U%!%$%kDI@W$NDd;_(B}
--- a/ja/hook.tex Fri Jan 09 23:05:26 2009 +0900 +++ b/ja/hook.tex Thu Jan 15 16:34:43 2009 +0900 @@ -442,123 +442,200 @@ \section{$B%U%C%/$N;HMQK!(B} \label{sec:hook:simple} -It is easy to write a Mercurial hook. Let's start with a hook that -runs when you finish a \hgcmd{commit}, and simply prints the hash of -the changeset you just created. The hook is called \hook{commit}. +%It is easy to write a Mercurial hook. Let's start with a hook that +%runs when you finish a \hgcmd{commit}, and simply prints the hash of +%the changeset you just created. The hook is called \hook{commit}. + +Mercurial$B%U%C%/$r=q$/$N$OMF0W$$!%$3$3$G$O(B\hgcmd{commit}$B%3%^%s%I$,=*N;$7(B +$B$?:]$K!$:n@.$5$l$?%A%'%s%8%;%C%H$N%O%C%7%eCM$rI=<($9$k$/%U%C%/$r=q$$$F$_(B +$B$h$&!%$3$N%U%C%/$r(B\hook{commit}$B$H8F$V$3$H$K$9$k!%(B \begin{figure}[ht] \interaction{hook.simple.init} - \caption{A simple hook that runs when a changeset is committed} +% \caption{A simple hook that runs when a changeset is committed} + \caption{$B%A%'%s%8%;%C%H$,%3%_%C%H$5$l$?;~$KF0:n$9$kC1=c$J%U%C%/(B} \label{ex:hook:init} \end{figure} -All hooks follow the pattern in example~\ref{ex:hook:init}. You add -an entry to the \rcsection{hooks} section of your \hgrc\. On the left -is the name of the event to trigger on; on the right is the action to -take. As you can see, you can run an arbitrary shell command in a -hook. Mercurial passes extra information to the hook using -environment variables (look for \envar{HG\_NODE} in the example). +%All hooks follow the pattern in example~\ref{ex:hook:init}. You add +%an entry to the \rcsection{hooks} section of your \hgrc\. On the left +%is the name of the event to trigger on; on the right is the action to +%take. As you can see, you can run an arbitrary shell command in a +%hook. Mercurial passes extra information to the hook using +%environment variables (look for \envar{HG\_NODE} in the example). + +$BA4$F$N%U%C%/$ONc(B~\ref{ex:hook:init}$B$HF1$8%Q%?!<%s$K$J$k!%(B \hgrc $B%U%!%$%k$N(B +\rcsection{hooks}$B%;%/%7%g%s$K%(%s%H%j$rDI2C$9$k!%:8JU$K%H%j%,!<$H$J$k%Y%s(B +$B%H$r5-=R$7!$1&JU$KBP1~$9$k%"%/%7%g%s$r5-=R$9$k!%Nc$K<($7$?DL$j!$%U%C%/$K(B +$B$OG$0U$N%7%'%k%3%^%s%I$r=q$/$3$H$,$G$-$k!%4D6-JQ?t$r@_Dj$9$k$3$H$G(B +Mercurial$B$+$i%U%C%/$KDI2C$N>pJs$rEO$9$3$H$,$G$-$k!%!JNc$N(B +\envar{HG\_NODE}$B$r;2>H!%!K(B %\subsection{Performing multiple actions per event} \subsection{1$B$D$N%$%Y%s%H$KJ#?t$N%"%/%7%g%s$r9T$&(B} -Quite often, you will want to define more than one hook for a -particular kind of event, as shown in example~\ref{ex:hook:ext}. -Mercurial lets you do this by adding an \emph{extension} to the end of -a hook's name. You extend a hook's name by giving the name of the -hook, followed by a full stop (the ``\texttt{.}'' character), followed -by some more text of your choosing. For example, Mercurial will run -both \texttt{commit.foo} and \texttt{commit.bar} when the -\texttt{commit} event occurs. +%Quite often, you will want to define more than one hook for a +%particular kind of event, as shown in example~\ref{ex:hook:ext}. +%Mercurial lets you do this by adding an \emph{extension} to the end of +%a hook's name. You extend a hook's name by giving the name of the +%hook, followed by a full stop (the ``\texttt{.}'' character), followed +%by some more text of your choosing. For example, Mercurial will run +%both \texttt{commit.foo} and \texttt{commit.bar} when the +%\texttt{commit} event occurs. + +$BNc(B~\ref{ex:hook:ext}$B$K<($7$?$h$&$K!$FCDj$N%$%Y%s%H$K(B2$B$D0J>e$N%U%C%/$rDj5A(B +$B$9$k$3$H$,I,MW$K$J$k$3$H$,B?$$$@$m$&!%(B Mercurial$B$G$O!$%U%C%/L>$N:G8e$K(B +\emph{$B3HD%;R(B}$B$rDI2C$9$k$3$H$G$3$l$,2DG=$K$J$k!%3HD%;R$rIU$1$k$K(B +$B$O!$(B``\texttt{.}'' $BJ8;z$H!$$3$l$KB3$/2?J8;z$+$+$i$J$kL>A0$r%U%C%/$K$D$1$l(B +$B$P$h$$!%Nc$($P(BMercurial$B$O(B\texttt{commit}$B%$%Y%s%H$,5/$-$?;~$K(B +\texttt{commit.foo}$B$H(B\texttt{commit.bar}$B%U%C%/$NN>J}$r8F$S=P$9!%(B \begin{figure}[ht] \interaction{hook.simple.ext} - \caption{Defining a second \hook{commit} hook} +% \caption{Defining a second \hook{commit} hook} + \caption{2$BHVL\$N(B\hook{commit}$B%U%C%/$rDj5A$9$k(B} \label{ex:hook:ext} \end{figure} -To give a well-defined order of execution when there are multiple -hooks defined for an event, Mercurial sorts hooks by extension, and -executes the hook commands in this sorted order. In the above -example, it will execute \texttt{commit.bar} before -\texttt{commit.foo}, and \texttt{commit} before both. +%To give a well-defined order of execution when there are multiple +%hooks defined for an event, Mercurial sorts hooks by extension, and +%executes the hook commands in this sorted order. In the above +%example, it will execute \texttt{commit.bar} before +%\texttt{commit.foo}, and \texttt{commit} before both. + +1$B$D$N%$%Y%s%H$KJ#?t$N%U%C%/$,Dj5A$5$l$F$$$k;~!$(BMercurial$B$O%U%C%/$r3HD%;R(B +$B$G%=!<%H$7!$%=!<%H$5$l$?=g=x$K=>$C$F%U%C%/$r<B9T$9$k!%>e5-$NNc$G$O(B +\texttt{commit}$B!$(B\texttt{commit.bar}$B!$(B\texttt{commit.foo}$B$N=g$K<B9T$9$k!%(B -It is a good idea to use a somewhat descriptive extension when you -define a new hook. This will help you to remember what the hook was -for. If the hook fails, you'll get an error message that contains the -hook name and extension, so using a descriptive extension could give -you an immediate hint as to why the hook failed (see -section~\ref{sec:hook:perm} for an example). +%It is a good idea to use a somewhat descriptive extension when you +%define a new hook. This will help you to remember what the hook was +%for. If the hook fails, you'll get an error message that contains the +%hook name and extension, so using a descriptive extension could give +%you an immediate hint as to why the hook failed (see +%section~\ref{sec:hook:perm} for an example). + +$B?7$7$$%U%C%/$rDj5A$9$k;~$K!$FbMF$r@bL@$9$k$h$&$J3HD%;R$rIU$1$k$N$O$h$$9M(B +$B$($G$"$k!%$3$&$9$k$3$H$K$h$C$F!$%U%C%/$NL\E*$,2?$J$N$+$r3P$($d$9$/$J$k!%(B +$B%U%C%/$,<:GT$7$?>l9g!$%(%i!<%a%C%;!<%8$K$O%U%C%/L>$H3HD%;R$,4^$^$l$k!%@b(B +$BL@E*$J3HD%;R$O%U%C%/$,<:GT$7$?M}M3$rCN$k$h$$<j$,$+$j$H$J$k!%!JNc(B +$B$O(B~\ref{sec:hook:perm}$B$r;2>H$N$3$H!%!K(B %\subsection{Controlling whether an activity can proceed} \subsection{$BF0:n$,?J9T$G$-$k$+$I$&$+@)8f$9$k(B} \label{sec:hook:perm} -In our earlier examples, we used the \hook{commit} hook, which is -run after a commit has completed. This is one of several Mercurial -hooks that run after an activity finishes. Such hooks have no way of -influencing the activity itself. +%In our earlier examples, we used the \hook{commit} hook, which is +%run after a commit has completed. This is one of several Mercurial +%hooks that run after an activity finishes. Such hooks have no way of +%influencing the activity itself. + +$BA0$NNc$G$O%3%_%C%H$,40N;$7$?8e$K<B9T$5$l$k(B\hook{commit}$B%U%C%/$rMQ$$$?!%$3(B +$B$l$O(BMercurial$B%U%C%/$N$&$A!$F0:n$,=*N;$7$?8e$K<B9T$5$l$k$b$N$N$&$A$N(B1$B$D$G(B +$B$"$k!%$3$N$h$&$J%U%C%/$O!$(BMercurial$B$NF0:n$=$N$b$N$K1F6A$r5Z$\$5$J$$!%(B -Mercurial defines a number of events that occur before an activity -starts; or after it starts, but before it finishes. Hooks that -trigger on these events have the added ability to choose whether the -activity can continue, or will abort. +%Mercurial defines a number of events that occur before an activity +%starts; or after it starts, but before it finishes. Hooks that +%trigger on these events have the added ability to choose whether the +%activity can continue, or will abort. + +Mercurial$B$OF0:n$N3+;OA0$d!$3+;O8e=*N;$9$k$^$G$N4V$KH/@8$9$k%$%Y%s%H$rB??t(B +$BDj5A$7$F$$$k!%$3$l$i$N%$%Y%s%H$G%H%j%,!<$5$l$k%U%C%/$O!$F0:n$rB39T$9$k$+(B +$BCfCG$9$k$+7h$a$k$3$H$,$G$-$k!%(B -The \hook{pretxncommit} hook runs after a commit has all but -completed. In other words, the metadata representing the changeset -has been written out to disk, but the transaction has not yet been -allowed to complete. The \hook{pretxncommit} hook has the ability to -decide whether the transaction can complete, or must be rolled back. +%The \hook{pretxncommit} hook runs after a commit has all but +%completed. In other words, the metadata representing the changeset +%has been written out to disk, but the transaction has not yet been +%allowed to complete. The \hook{pretxncommit} hook has the ability to +%decide whether the transaction can complete, or must be rolled back. + +\hook{pretxncommit}$B%U%C%/$O%3%_%C%H8e!$%3%_%C%H$N40N;A0$K8F$S=P$5$l$k!%(B +$B8@$$BX$($k$H!$%A%'%s%8%;%C%H$r<($9%a%?%G!<%?$,%G%#%9%/$K=q$-9~$^$l$?8e(B +$B$G!$%H%i%s%6%/%7%g%s$,40N;$9$kA0$K8F$S=P$5$l$k!%(B +\hook{pretxncommit}$B%U%C%/$O%H%i%s%6%/%7%g%s$r40N;$9$k$+!$%m!<%k%P%C%/$9(B +$B$k$+$r7hDj$9$k5!G=$,$"$k!%(B -If the \hook{pretxncommit} hook exits with a status code of zero, the -transaction is allowed to complete; the commit finishes; and the -\hook{commit} hook is run. If the \hook{pretxncommit} hook exits with -a non-zero status code, the transaction is rolled back; the metadata -representing the changeset is erased; and the \hook{commit} hook is -not run. +%If the \hook{pretxncommit} hook exits with a status code of zero, the +%transaction is allowed to complete; the commit finishes; and the +%\hook{commit} hook is run. If the \hook{pretxncommit} hook exits with +%a non-zero status code, the transaction is rolled back; the metadata +%representing the changeset is erased; and the \hook{commit} hook is +%not run. + +\hook{pretxncommit}$B%U%C%/$,%9%F!<%?%9%3!<%I(B0$B$G=*N;$9$k$H%H%i%s%6%/%7%g%s(B +$B$O40N;$9$k$3$H$,$G$-!$%3%_%C%H$,=*N;$7!$(B\hook{commit}$B%U%C%/$,8F$S=P$5$l$k!%(B +\hook{pretxncommit}$B%U%C%/$,Hs(B0$B$N%9%F!<%?%9%3!<%I$G=*N;$9$k$H!$%H%i%s%6%/(B +$B%7%g%s$O%m!<%k%P%C%/$5$l!$%A%'%s%8%;%C%H$r<($9%a%?%G!<%?$O>C5n$5$l$k!%$3(B +$B$N>l9g(B\hook{commit}$B%U%C%/$O8F$S=P$5$l$J$$!%(B \begin{figure}[ht] \interaction{hook.simple.pretxncommit} - \caption{Using the \hook{pretxncommit} hook to control commits} +% \caption{Using the \hook{pretxncommit} hook to control commits} + \caption{$B%3%_%C%H$r@)8f$9$k$?$a$K(B\hook{pretxncommit}$B%U%C%/$r;HMQ$9$k(B} \label{ex:hook:pretxncommit} \end{figure} -The hook in example~\ref{ex:hook:pretxncommit} checks that a commit -comment contains a bug ID. If it does, the commit can complete. If -not, the commit is rolled back. +%The hook in example~\ref{ex:hook:pretxncommit} checks that a commit +%comment contains a bug ID. If it does, the commit can complete. If +%not, the commit is rolled back. + +~\ref{ex:hook:pretxncommit}$B$O%3%_%C%H%3%a%s%H$,%P%0(BID$B$r4^$`$+$r%A%'%C%/(B +$B$9$k!%$b$74^$^$l$l$P%3%_%C%H$O40N;$9$k!%4^$^$J$$>l9g$O%3%_%C%H$O%m!<%k%P%C(B +$B%/$5$l$k!%(B %\section{Writing your own hooks} \section{$B%*%j%8%J%k$N%U%C%/$r=q$/(B} -When you are writing a hook, you might find it useful to run Mercurial -either with the \hggopt{-v} option, or the \rcitem{ui}{verbose} config -item set to ``true''. When you do so, Mercurial will print a message -before it calls each hook. +%When you are writing a hook, you might find it useful to run Mercurial +%either with the \hggopt{-v} option, or the \rcitem{ui}{verbose} config +%item set to ``true''. When you do so, Mercurial will print a message +%before it calls each hook. + +$B%U%C%/$r=q$/>l9g!$(BMercurial$B$r(B\hggopt{-v}$B%*%W%7%g%s$rIU$1$?$j(B +\rcitem{ui}{verbose}$B@_Dj9`L\$r(B``true''$B$K@_Dj$9$k$3$H$OLr$KN)$D!%$3$N>l(B +$B9g!$(BMercurial$B$O3F!9$N%U%C%/$r8F$VA0$K%a%C%;!<%8$rI=<($9$k!%(B %\subsection{Choosing how your hook should run} \subsection{$B%U%C%/$,$NF0:nJ}K!$rA*$V(B} \label{sec:hook:lang} -You can write a hook either as a normal program---typically a shell -script---or as a Python function that is executed within the Mercurial -process. +%You can write a hook either as a normal program---typically a shell +%script---or as a Python function that is executed within the Mercurial +%process. + +$B%U%C%/$O%7%'%k%9%/%j%W%H$N$h$&$JDL>o$N%W%m%0%i%`$H$7$F=q$/$3$H$b$G$-$k$7!$(B +Mercurial$B%W%m%;%9$NFbIt$G8F$S=P$5$l$k(BPython$B4X?t$H$7$F=q$/$3$H$b$G$-$k!%(B -Writing a hook as an external program has the advantage that it -requires no knowledge of Mercurial's internals. You can call normal -Mercurial commands to get any added information you need. The -trade-off is that external hooks are slower than in-process hooks. +%Writing a hook as an external program has the advantage that it +%requires no knowledge of Mercurial's internals. You can call normal +%Mercurial commands to get any added information you need. The +%trade-off is that external hooks are slower than in-process hooks. + +$B%U%C%/$r30It%W%m%0%i%`$H$7$F=q$/MxE@$O(BMercurial$B$NFbItF0:n$rCN$i$J$/$F$b%U%C(B +$B%/$,=q$1$k$3$H$G$"$k!%I,MW$JDI2C$N>pJs$rF@$k$?$a$KDL>o$N(BMercurial$B%3%^%s%I(B +$B$r8F$S=P$9$3$H$,$G$-$k!%30It%U%C%/$O%W%m%;%9Fb%U%C%/$h$j$bDcB.$J$N$,%H%l!<(B +$B%I%*%U$G$"$k!%(B -An in-process Python hook has complete access to the Mercurial API, -and does not ``shell out'' to another process, so it is inherently -faster than an external hook. It is also easier to obtain much of the -information that a hook requires by using the Mercurial API than by -running Mercurial commands. +%An in-process Python hook has complete access to the Mercurial API, +%and does not ``shell out'' to another process, so it is inherently +%faster than an external hook. It is also easier to obtain much of the +%information that a hook requires by using the Mercurial API than by +%running Mercurial commands. + +Python$B%W%m%;%9Fb%U%C%/$O(BMercurial API$B$X$N40A4$J%"%/%;%9$,2DG=$G$"$k!%(B +$BB>$N%W%m%;%9$r@8@.$9$k$3$H$,$J$$$?$a!$K\<AE*$K30It%U%C%/$h$j$b9bB.$G$"$k!%(B +$B%U%C%/$,I,MW$H$9$k>pJs$NBgH>$O!$(BMercurial$B%3%^%s%I$r<B9T$9$k$h$j$b(B +Mercurial API$B$r;H$C$F=8$a$kJ}$,MF0W$$!%(B -If you are comfortable with Python, or require high performance, -writing your hooks in Python may be a good choice. However, when you -have a straightforward hook to write and you don't need to care about -performance (probably the majority of hooks), a shell script is -perfectly fine. +%If you are comfortable with Python, or require high performance, +%writing your hooks in Python may be a good choice. However, when you +%have a straightforward hook to write and you don't need to care about +%performance (probably the majority of hooks), a shell script is +%perfectly fine. + +Python$B$r;H$$47$l$F$$$?$j!$9b$$@-G=$,I,MW$J$i$P!$%U%C%/$r(BPython$B$G=q$/$N$,(B +$B$h$$$@$m$&!%$7$+$7=q$3$&$H$9$k$N$,C1=cL@2r$J%U%C%/$G!$!JB?$/$N%U%C%/$,$=(B +$B$&$G$"$k$h$&$K!K@-G=$K$OFC$K4X?4$,$J$$>l9g!$%7%'%k%9%/%j%W%H$H$7$F=q$$$F(B +$B$bA4$/LdBj$J$$!%(B %\subsection{Hook parameters} \subsection{$B%U%C%/%Q%i%a!<%?(B}