Mercurial > hgbook
changeset 375:24c6081cea2b
more hook.tex
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 09 Jan 2009 17:01:40 +0900 |
parents | 32c932f185ed |
children | 9f7812b79c70 |
files | ja/hook.tex |
diffstat | 1 files changed, 327 insertions(+), 150 deletions(-) [+] |
line wrap: on
line diff
--- a/ja/hook.tex Fri Dec 19 17:43:27 2008 +0900 +++ b/ja/hook.tex Fri Jan 09 17:01:40 2009 +0900 @@ -2,56 +2,112 @@ \chapter{$B%j%]%8%H%j%$%Y%s%H$r%U%C%/$G<h$j07$&(B} \label{chap:hook} -Mercurial offers a powerful mechanism to let you perform automated -actions in response to events that occur in a repository. In some -cases, you can even control Mercurial's response to those events. +%Mercurial offers a powerful mechanism to let you perform automated +%actions in response to events that occur in a repository. In some +%cases, you can even control Mercurial's response to those events. + +Mercurial$B$O!$%j%]%8%H%j$K5/$3$k%$%Y%s%H$KBP$7$F<+F02=$5$l$?%"%/%7%g%s$r9T(B +$B$&6/NO$J%a%+%K%:%`$r;}$C$F$$$k!%$$$/$D$+$N%$%Y%s%H$KBP$7$F$O!$(BMercurial$B$N(B +$BH?1~$r@)8f$9$k$3$H$b$G$-$k!%(B -The name Mercurial uses for one of these actions is a \emph{hook}. -Hooks are called ``triggers'' in some revision control systems, but -the two names refer to the same idea. +%The name Mercurial uses for one of these actions is a \emph{hook}. +%Hooks are called ``triggers'' in some revision control systems, but +%the two names refer to the same idea. + +Mercurial$B$O(B\emph{$B%U%C%/(B}$B$H8F$P$l$k5!9=$r;H$C$F%"%/%7%g%s$r9T$&!%%U%C%/$O(B +$BB>$N%j%S%8%g%s%3%s%H%m!<%k%7%9%F%`$G$O(B``$B%H%j%,(B''$B$H8F$P$l$k$3$H$b$"$k$,!$(B +$B$3$l$i$O<B:]$OF1$8$b$N$G$"$k!%(B %\section{An overview of hooks in Mercurial} \section{Mercurial$B$G$N%U%C%/$N35MW(B} -Here is a brief list of the hooks that Mercurial supports. We will -revisit each of these hooks in more detail later, in -section~\ref{sec:hook:ref}. +%Here is a brief list of the hooks that Mercurial supports. We will +%revisit each of these hooks in more detail later, in +%section~\ref{sec:hook:ref}. + +Mercurial$B$,%5%]!<%H$9$k%U%C%/$N0lIt$rNs5s$9$k!%8D!9$N%U%C%/$K$D$$$F$O(B +$B8e$[$I(Bsection~\ref{sec:hook:ref}$B$G>\:Y$K?($l$k!%(B \begin{itemize} -\item[\small\hook{changegroup}] This is run after a group of - changesets has been brought into the repository from elsewhere. -\item[\small\hook{commit}] This is run after a new changeset has been - created in the local repository. -\item[\small\hook{incoming}] This is run once for each new changeset - that is brought into the repository from elsewhere. Notice the - difference from \hook{changegroup}, which is run once per - \emph{group} of changesets brought in. -\item[\small\hook{outgoing}] This is run after a group of changesets - has been transmitted from this repository. -\item[\small\hook{prechangegroup}] This is run before starting to - bring a group of changesets into the repository. -\item[\small\hook{precommit}] Controlling. This is run before starting - a commit. -\item[\small\hook{preoutgoing}] Controlling. This is run before - starting to transmit a group of changesets from this repository. -\item[\small\hook{pretag}] Controlling. This is run before creating a tag. -\item[\small\hook{pretxnchangegroup}] Controlling. This is run after a - group of changesets has been brought into the local repository from - another, but before the transaction completes that will make the - changes permanent in the repository. -\item[\small\hook{pretxncommit}] Controlling. This is run after a new - changeset has been created in the local repository, but before the - transaction completes that will make it permanent. -\item[\small\hook{preupdate}] Controlling. This is run before starting - an update or merge of the working directory. -\item[\small\hook{tag}] This is run after a tag is created. -\item[\small\hook{update}] This is run after an update or merge of the - working directory has finished. +%\item[\small\hook{changegroup}] This is run after a group of +% changesets has been brought into the repository from elsewhere. +\item[\small\hook{changegroup}] $B%A%'%s%8%;%C%H%0%k!<%W$,30It$+$i%j%]%8%H(B + $B%j$K2C$o$C$?8e$G8F$S=P$5$l$k!%(B + +%\item[\small\hook{commit}] This is run after a new changeset has been +% created in the local repository. +\item[\small\hook{commit}] $B%m!<%+%k%j%]%8%H%j$G?7$7$$%A%'%s%8%;%C%H$,:n(B + $B@.$5$l$?8e$K8F$S=P$5$l$k!%(B + +%\item[\small\hook{incoming}] This is run once for each new changeset +% that is brought into the repository from elsewhere. Notice the +% difference from \hook{changegroup}, which is run once per +% \emph{group} of changesets brought in. + +\item[\small\hook{incoming}] $B?7$7$$%A%'%s%8%;%C%H$,30It$+$i%j%]%8%H%j$K2C(B + $B$o$kKh$K8F$S=P$5$l$k!%(B\emph{group}$B$,2C$o$kKh$K8F$S=P$5$l$k%U%C(B + $B%/$K(B\hook{changegroup}$B%U%C%/$,$"$k!%(B + +%\item[\small\hook{outgoing}] This is run after a group of changesets +% has been transmitted from this repository. +\item[\small\hook{outgoing}] $B%j%]%8%H%j$+$i%A%'%s%8%;%C%H%0%k!<%W$,30It(B + $B$KAw?.$5$l$?8e$K8F$S=P$5$l$k!%(B + +%\item[\small\hook{prechangegroup}] This is run before starting to +% bring a group of changesets into the repository. +\item[\small\hook{prechangegroup}] $B%A%'%s%8%;%C%H%0%k!<%W$r%j%]%8%H%j$+(B + $B$i30It$K;}$A=P$9A0$K8F$S=P$5$l$k!%(B + +%\item[\small\hook{precommit}] Controlling. This is run before starting +% a commit. +\item[\small\hook{precommit}] Controlling. $B%3%_%C%H$,;O$^$kA0$K8F$S=P$5(B + $B$l$k!%(B + +%\item[\small\hook{preoutgoing}] Controlling. This is run before +% starting to transmit a group of changesets from this repository. +\item[\small\hook{preoutgoing}] Controlling. $B%A%'%s%8%;%C%H%0%k!<%W$r%j(B + $B%]%8%H%j$+$i30It$KAw?.$9$kA0$K8F$S=P$5$l$k!%(B + +%\item[\small\hook{pretag}] Controlling. This is run before creating a tag. +\item[\small\hook{pretag}] Controlling. $B%?%0$,:n@.$5$l$kA0$K8F$S=P$5$l$k!%(B + +%\item[\small\hook{pretxnchangegroup}] Controlling. This is run after a +% group of changesets has been brought into the local repository from +% another, but before the transaction completes that will make the +% changes permanent in the repository. +\item[\small\hook{pretxnchangegroup}] Controlling. $B%A%'%s%8%;%C%H%0%k!<%W(B + $B$,30It$+$i%m!<%+%k%j%]%8%H%j$K2C$o$C$?8e!$1JB3E*$K5-O?$9$k$?(B + $B$a$N%H%i%s%6%/%7%g%s$,40N;$9$kA0$K8F$S=P$5$l$k!%(B + +%\item[\small\hook{pretxncommit}] Controlling. This is run after a new +% changeset has been created in the local repository, but before the +% transaction completes that will make it permanent. +\item[\small\hook{pretxncommit}] Controlling. $B?7$7$$%A%'%s%8%;%C%H$,%m!<(B + $B%+%k%j%]%8%H%j$G:n@.$5$l$?8e!$1JB3E*$K5-O?$9$k$?$a$N%H%i%s%6(B + $B%/%7%g%s$,40N;$9$kA0$K8F$S=P$5$l$k!%(B + +%\item[\small\hook{preupdate}] Controlling. This is run before starting +% an update or merge of the working directory. +\item[\small\hook{preupdate}] Controlling. $B%o!<%-%s%0%G%#%l%/%H%j$N99?7(B + $B$^$?$O%^!<%8$,9T$o$l$kA0$K8F$S=P$5$l$k!%(B + +%\item[\small\hook{tag}] This is run after a tag is created. +\item[\small\hook{tag}] $B%?%0$,:n@.$5$l$?8e$G8F$S=P$5$l$k!%(B + +%\item[\small\hook{update}] This is run after an update or merge of the +% working directory has finished. +\item[\small\hook{update}] $B%o!<%-%s%0%G%#%l%/%H%j$N99?7$+%^!<%8$,40N;$7(B + $B$?;~$K8F$S=P$5$l$k!%(B \end{itemize} -Each of the hooks whose description begins with the word -``Controlling'' has the ability to determine whether an activity can -proceed. If the hook succeeds, the activity may proceed; if it fails, -the activity is either not permitted or undone, depending on the hook. +%Each of the hooks whose description begins with the word +%``Controlling'' has the ability to determine whether an activity can +%proceed. If the hook succeeds, the activity may proceed; if it fails, +%the activity is either not permitted or undone, depending on the hook. + +$B%U%C%/$N$&$A!$@bL@$,(B``Controlling''$B$H$$$&8l$G;O$^$k$b$N$O!$%U%C%/$N@.H]$r(B +$BH=Dj$7!$0J8e$NF0:n$r9T$&$+$I$&$+7hDj$9$k5!G=$,$"$k!%%U%C%/$,@.8y$9$k$HF0(B +$B:n$O@h$X?J$`!%%U%C%/$,@.8y$7$J$+$C$?>l9g$O0J8e$NF0:n$O<B9T$,5v2D$5$l$J$$(B +$B$+!$F0:n$,40N;$;$:=*$k!%(B %\section{Hooks and security} \section{$B%U%C%/$H%;%-%e%j%F%#(B} @@ -59,149 +115,270 @@ %\subsection{Hooks are run with your privileges} \subsection{$B%U%C%/$O%f!<%6$N8"8B$GF0:n$9$k(B} -When you run a Mercurial command in a repository, and the command -causes a hook to run, that hook runs on \emph{your} system, under -\emph{your} user account, with \emph{your} privilege level. Since -hooks are arbitrary pieces of executable code, you should treat them -with an appropriate level of suspicion. Do not install a hook unless -you are confident that you know who created it and what it does. +%When you run a Mercurial command in a repository, and the command +%causes a hook to run, that hook runs on \emph{your} system, under +%\emph{your} user account, with \emph{your} privilege level. Since +%hooks are arbitrary pieces of executable code, you should treat them +%with an appropriate level of suspicion. Do not install a hook unless +%you are confident that you know who created it and what it does. -In some cases, you may be exposed to hooks that you did not install -yourself. If you work with Mercurial on an unfamiliar system, -Mercurial will run hooks defined in that system's global \hgrc\ file. +$B%j%]%8%H%jFb$G(BMercurial$B%3%^%s%I$r<B9T$7!$%3%^%s%I$,%U%C%/$r8F$S=P$7$?>l(B +$B9g!$%U%C%/$O(B\emph{$BA`:n<T(B}$B$N%7%9%F%`$G!$(B\emph{$BA`:n<T(B}$B$NFC8"%l%Y%k$GF0:n$9(B +$B$k!%%U%C%/$OG$0U$N<B9T%3!<%I$J$N$G!$Aj1~$NN10U$,I,MW$G$"$k!%%U%C%/$r:n$C(B +$B$?$N$,C/$G!$$=$N%U%C%/$,2?$r$9$k$N$+$-$A$s$HM}2r$9$k$3$H$J$7$K%U%C%/$r%$(B +$B%s%9%H!<%k$7$F$O$J$i$J$$!%(B + +%In some cases, you may be exposed to hooks that you did not install +%yourself. If you work with Mercurial on an unfamiliar system, +%Mercurial will run hooks defined in that system's global \hgrc\ file. + +$B<+J,$G%$%s%9%H!<%k$7$?$N$G$O$J$$%U%C%/$r<B9T$5$;$F$7$^$&$3$H$bM-$jF@$k!%(B +$BB>=j$N%7%9%F%`$N>e$G(BMercurial$B$r;H$&>l9g!$(BMercurial$B$,%7%9%F%`%o%$%I$N(B +\hgrc\ $B%U%!%$%k$GDj5A$5$l$?%U%C%/$r5/F0$9$k2DG=@-$,$"$k!%(B -If you are working with a repository owned by another user, Mercurial -can run hooks defined in that user's repository, but it will still run -them as ``you''. For example, if you \hgcmd{pull} from that -repository, and its \sfilename{.hg/hgrc} defines a local -\hook{outgoing} hook, that hook will run under your user account, even -though you don't own that repository. +%If you are working with a repository owned by another user, Mercurial +%can run hooks defined in that user's repository, but it will still run +%them as ``you''. For example, if you \hgcmd{pull} from that +%repository, and its \sfilename{.hg/hgrc} defines a local +%\hook{outgoing} hook, that hook will run under your user account, even +%though you don't own that repository. +$BB>$N%f!<%6$,=jM-$9$k%j%]%8%H%j$G:n6H$9$k>l9g!$(BMercurial$B$O=jM-<T$N%j%]%8(B +$B%H%jFb$GDj5A$5$l$?%U%C%/$r<B9T$7F@$k$,!$<B9T8"8B$O$"$J$?$N$b$N$G9T$o$l$k!%(B +$BNc$($P$=$N%j%]%8%H%j$+$i(B\hgcmd{pull}$B$r9T$&$H$-!$%j%]%8%H%jFb$N(B +\sfilename{.hg/hgrc}$B%U%!%$%k$G%m!<%+%k$J(B\hook{outgoing}$B%U%C%/$,Dj5A$5$l$F(B +$B$$$k$H!$$"$J$?$O$=$N%j%]%8%H%j$r=jM-$7$F$$$J$$$K$b$+$+$o$i$:$=$N%U%C%/$O(B +$B$"$J$?$N8"8B$G<B9T$5$l$k!%(B + +%\begin{note} +% This only applies if you are pulling from a repository on a local or +% network filesystem. If you're pulling over http or ssh, any +% \hook{outgoing} hook will run under whatever account is executing +% the server process, on the server. +%\end{note} \begin{note} - This only applies if you are pulling from a repository on a local or - network filesystem. If you're pulling over http or ssh, any - \hook{outgoing} hook will run under whatever account is executing - the server process, on the server. +$B$3$l$O%m!<%+%k$J%j%]%8%H%j$d%M%C%H%o!<%/%U%!%$%k%7%9%F%`>e$N%j%]%8%H%j$+(B + $B$i(Bpull$B$7$?>l9g$K$N$_E,MQ$5$l$k!%(Bhttp$B$^$?$O(Bssh$B$r;H$C$F(Bpull$B$7$?>l9g!$$9$Y(B + $B$F$N(B\hook{outgoing}$B%U%C%/$O%5!<%P>e$G%5!<%P%W%m%;%9$r<B9T$7$F$$$k%"%+%&(B + $B%s%H$N8"8B$G<B9T$5$l$k!%(B \end{note} -XXX To see what hooks are defined in a repository, use the -\hgcmdargs{config}{hooks} command. If you are working in one -repository, but talking to another that you do not own (e.g.~using -\hgcmd{pull} or \hgcmd{incoming}), remember that it is the other -repository's hooks you should be checking, not your own. +%XXX To see what hooks are defined in a repository, use the +%\hgcmdargs{config}{hooks} command. If you are working in one +%repository, but talking to another that you do not own (e.g.~using +%\hgcmd{pull} or \hgcmd{incoming}), remember that it is the other +%repository's hooks you should be checking, not your own. + +XXX $B%j%]%8%H%jFb$GDj5A$5$l$F$$$k%U%C%/$r8+$k$K$O(B +\hgcmdargs{config}{hooks}$B%3%^%s%I$r;H$&!%$"$k%j%]%8%H%j$G:n6H$7$F$$$F!$?7(B +$B$7$$%3!<%I$rB>$N%j%]%8%H%j$+$iF~<j$9$k$?$a$KDL?.$r9T$&>l9g!JNc$($P(B +\hgcmd{pull}$B$+(B\hgcmd{incoming}$B$r<B9T$9$k!K(B $B!$%A%'%C%/$9$Y$-%U%C%/$O<j85$N(B +$B%j%]%8%H%j$N$b$N$G$O$J$/!$%j%b!<%H$N%j%]%8%H%j$N%U%C%/$G$"$k!%(B %\subsection{Hooks do not propagate} -\subsection{$B%U%C%/$OGH5Z$7$J$$(B} +\subsection{$B%U%C%/$OEAGE$7$J$$(B} + +%In Mercurial, hooks are not revision controlled, and do not propagate +%when you clone, or pull from, a repository. The reason for this is +%simple: a hook is a completely arbitrary piece of executable code. It +%runs under your user identity, with your privilege level, on your +%machine. -In Mercurial, hooks are not revision controlled, and do not propagate -when you clone, or pull from, a repository. The reason for this is -simple: a hook is a completely arbitrary piece of executable code. It -runs under your user identity, with your privilege level, on your -machine. +Mercurial$B$G$O!$%U%C%/$O%j%S%8%g%s4IM}$5$l$:!$%j%]%8%H%j$+$i%/%m!<%s$7$?$j(B +pull$B$7$F$bEAGE$7$J$$!%$3$&$J$C$F$$$kM}M3$OC1=c$G!$%U%C%/$OG$0U$N<B9T2DG=(B +$B%3!<%I$G$"$k$+$i$G$"$k!%%U%C%/$O$"$J$?$N%^%7%s$N>e$G$"$J$?$N%f!<%6!<(BID$B$H(B +$BFC8"%l%Y%k$GF0:n$GF0$/!%(B + +%It would be extremely reckless for any distributed revision control +%system to implement revision-controlled hooks, as this would offer an +%easily exploitable way to subvert the accounts of users of the +%revision control system. + +$BJ,;6%j%S%8%g%s%3%s%H%m!<%k%7%9%F%`$K%j%S%8%g%s4IM}$5$l$?%U%C%/$r<BAu$9$k(B +$B$N$O$H$F$bL5KE$G$"$k!%$3$N$h$&$J5!9=$,$"$k$H%j%S%8%g%s%3%s%H%m!<%k%7%9%F(B +$B%`$N%f!<%6%"%+%&%s%H$r56Au$9$k$h$&$J;E3]$1$r4JC1$K<B8=$G$-$F$7$^$&!%(B -It would be extremely reckless for any distributed revision control -system to implement revision-controlled hooks, as this would offer an -easily exploitable way to subvert the accounts of users of the -revision control system. +%Since Mercurial does not propagate hooks, if you are collaborating +%with other people on a common project, you should not assume that they +%are using the same Mercurial hooks as you are, or that theirs are +%correctly configured. You should document the hooks you expect people +%to use. -Since Mercurial does not propagate hooks, if you are collaborating -with other people on a common project, you should not assume that they -are using the same Mercurial hooks as you are, or that theirs are -correctly configured. You should document the hooks you expect people -to use. +Mercurial$B$O%U%C%/$rEAGE$5$;$J$$$N$G!$6&DL$N%W%m%8%'%/%H$GB>$N3+H/<T$H6(NO(B +$B$7$F$$$k>l9g!$H`$i$O$"$J$?$,;H$C$F$k$N$HF1$8(BMercurial$B%U%C%/$r;H$C$F$$$k$H(B +$B2>Dj$7$?$j!$H`$i$N%j%]%8%H%j$G$b%U%C%/$,F1MM$K@5$7$/@_Dj$5$l$F$$$k$H2>Dj(B +$B$9$Y$-$G$O$J$$!%H`$i$,%U%C%/$r;H$&$h$&$KK>$`$N$G$"$l$P!$;HMQK!$K$D$$$F%I(B +$B%-%e%a%s%H$r:n@.$9$Y$-$G$"$k!%(B -In a corporate intranet, this is somewhat easier to control, as you -can for example provide a ``standard'' installation of Mercurial on an -NFS filesystem, and use a site-wide \hgrc\ file to define hooks that -all users will see. However, this too has its limits; see below. +%In a corporate intranet, this is somewhat easier to control, as you +%can for example provide a ``standard'' installation of Mercurial on an +%NFS filesystem, and use a site-wide \hgrc\ file to define hooks that +%all users will see. However, this too has its limits; see below. + +$B4k6HFb$N%$%s%H%i%M%C%H$G$O%3%s%H%m!<%k$O4vJ,4JC1$G$"$k!%(B NFS$B%U%!%$%k%7%9(B +$B%F%`>e$G(BMercurial$B$N(B``$BI8=`(B''$B%$%s%9%H%l!<%7%g%sNc$rDs6!$7!$$9$Y$F$N%f!<%6$,(B +$B;2>H$9$k%5%$%H%o%$%I$N(B\hgrc\ $B%U%!%$%k$rMQ0U$7!$$=$NCf$G%U%C%/$rDj5A$9$k$3(B +$B$H$,$G$-$k!%$7$+$7$3$NJ}K!$K$b2<5-$N$h$&$J7gE@$,$"$k!%(B %\subsection{Hooks can be overridden} \subsection{$B%U%C%/$O%*!<%P%i%$%I2DG=$G$"$k(B} -Mercurial allows you to override a hook definition by redefining the -hook. You can disable it by setting its value to the empty string, or -change its behaviour as you wish. +%Mercurial allows you to override a hook definition by redefining the +%hook. You can disable it by setting its value to the empty string, or +%change its behaviour as you wish. + +Mercurial$B$G$O!$%U%C%/$r:FDj5A$9$k$3$H$K$h$C$F!$4{B8$N%U%C%/Dj5A$r%*!<%P%i(B +$B%$%I$9$k$3$H$,$G$-$k!%$3$l$OJQ?t$r6u$NJ8;zNs$K$7$?$j!$5sF0$rJQ99$9$k$3$H(B +$B$G6X;_$9$k$3$H$,$G$-$k!%(B -If you deploy a system-~or site-wide \hgrc\ file that defines some -hooks, you should thus understand that your users can disable or -override those hooks. +%If you deploy a system-~or site-wide \hgrc\ file that defines some +%hooks, you should thus understand that your users can disable or +%override those hooks. + +$B%U%C%/$rDj5A$7$?%7%9%F%`%o%$%I$^$?$O%5%$%H%o%$%I$N(B\hgrc\ $B%U%!%$%k$r;HMQ$7(B +$B$F$b!$%j%]%8%H%j$N%f!<%6$,%U%C%/$r6X;_$7$?$j%*!<%P%i%$%I$G$-$F$7$^$&$N$K(B +$B5$IU$/$@$m$&!%(B %\subsection{Ensuring that critical hooks are run} \subsection{$B%/%j%F%#%+%k$J%U%C%/$,3N<B$K<B9T$5$l$k$h$&$K$9$k(B} -Sometimes you may want to enforce a policy that you do not want others -to be able to work around. For example, you may have a requirement -that every changeset must pass a rigorous set of tests. Defining this -requirement via a hook in a site-wide \hgrc\ won't work for remote -users on laptops, and of course local users can subvert it at will by -overriding the hook. +%Sometimes you may want to enforce a policy that you do not want others +%to be able to work around. For example, you may have a requirement +%that every changeset must pass a rigorous set of tests. Defining this +%requirement via a hook in a site-wide \hgrc\ won't work for remote +%users on laptops, and of course local users can subvert it at will by +%overriding the hook. -Instead, you can set up your policies for use of Mercurial so that -people are expected to propagate changes through a well-known -``canonical'' server that you have locked down and configured -appropriately. +$B;~$K$OB>$N3+H/<T$,2sHr:v$r$H$l$J$$$h$&$J%]%j%7!<$rMW@A$7$?$$>l9g$,$"$k$@(B +$B$m$&!%Nc$($P$9$Y$F$N%A%'%s%8%;%C%H$,873J$J%F%9%H%;%C%H$K%Q%9$9$k$3$H$rI,(B +$BMW$H$9$k>l9g$,9M$($i$l$k!%$3$l$r%5%$%H%o%$%I$N(B\hgrc\ $B$G%U%C%/$H$7$FDj5A(B +$B$7$?>l9g!$$3$l$O%i%C%W%H%C%W$r;H$C$F$$$k%j%b!<%H%f!<%6$K$O5!G=$7$J$$$7!$(B +$B%U%C%/$r%*!<%P%i%$%I$G$-$k$?$a!$%m!<%+%k%f!<%6$K$H$C$F$bL5;k$G$-$F$7$^$&!%(B + +%Instead, you can set up your policies for use of Mercurial so that +%people are expected to propagate changes through a well-known +%``canonical'' server that you have locked down and configured +%appropriately. + +$B$=$NBe$o$j!$(BMercurial$B$N;HMQ$K4X$9$k%]%j%7!<$r@_Dj$7!$E,@Z$K@_Dj$5$l!$87=E(B +$B$K4IM}$5$l$?4{CN$N(B``$B%+%N%K%+%k(B''$B%5!<%P$rDL$8$FJQ99$,GH5Z$9$k$h$&$K$9$k$3(B +$B$H$,$G$-$k!%(B -One way to do this is via a combination of social engineering and -technology. Set up a restricted-access account; users can push -changes over the network to repositories managed by this account, but -they cannot log into the account and run normal shell commands. In -this scenario, a user can commit a changeset that contains any old -garbage they want. +%One way to do this is via a combination of social engineering and +%technology. Set up a restricted-access account; users can push +%changes over the network to repositories managed by this account, but +%they cannot log into the account and run normal shell commands. In +%this scenario, a user can commit a changeset that contains any old +%garbage they want. -When someone pushes a changeset to the server that everyone pulls -from, the server will test the changeset before it accepts it as -permanent, and reject it if it fails to pass the test suite. If -people only pull changes from this filtering server, it will serve to -ensure that all changes that people pull have been automatically -vetted. +$B$3$l$r<B8=$9$k0lK!$O%=!<%7%c%k%(%s%8%K%"%j%s%0$H5;=Q$NAH$_9g$o$;$G9T$&J}(B +$BK!$G$"$k!%8BDj%"%/%;%9%"%+%&%s%H$r@_Dj$7!$$3$N%"%+%&%s%H$G4IM}$5$l$F$$$k(B +$B%j%]%8%H%j$KBP$7$F%f!<%6$OJQ99$r%M%C%H%o!<%/$r2p$7$F(Bpush$B$G$-$k!%$7$+$7%f!<(B +$B%6$O$3$N%"%+%&%s%H$G%m%0%$%s$7$?$j!$DL>o$N%7%'%k%3%^%s%I$r<B9T$9$k$3$H$O(B +$B$G$-$J$$!%$3$N%7%J%j%*$G$O!$%f!<%6$O$I$s$J8E$$%4%_$r4^$s$@%A%'%s%8%;%C%H(B +$B$G$b%3%_%C%H$9$k$3$H$,$G$-$k!%(B + +%When someone pushes a changeset to the server that everyone pulls +%from, the server will test the changeset before it accepts it as +%permanent, and reject it if it fails to pass the test suite. If +%people only pull changes from this filtering server, it will serve to +%ensure that all changes that people pull have been automatically +%vetted. + +$BB?$/$N%f!<%6$,(Bpull$B$9$k%5!<%P$KC/$+$,%A%'%s%8%;%C%H$r(Bpush$B$7$?>l9g!$%5!<%P(B +$B$O%A%'%s%8%;%C%H$r915WE*$K<u$1F~$l$kA0$K%A%'%C%/$r9T$$!$0lO"$N%F%9%H$r%Q(B +$B%9$G$-$J$1$l$P%j%8%'%/%H$r9T$&!%%f!<%6$,$3$N%U%#%k%?%5!<%P$+$i$N$_(Bpull$B$r(B +$B9T$&$N$G$"$l$P!$A4$F$NJQ99$O<+F0E*$KA4$F8!::$5$l$F$$$k$3$H$K$J$k!%(B %\section{Care with \texttt{pretxn} hooks in a shared-access repository} \section{$B6&M-%"%/%;%9%j%]%8%H%j$G(B\texttt{pretxn}$B%U%C%/$r;H$&(B} -If you want to use hooks to do some automated work in a repository -that a number of people have shared access to, you need to be careful -in how you do this. +%If you want to use hooks to do some automated work in a repository +%that a number of people have shared access to, you need to be careful +%in how you do this. + +$BJ#?t$N%f!<%6$,6&M-%"%/%;%9$r9T$&%j%]%8%H%j$G!$<+F02=$5$l$?:n6H$r9T$&$?$a(B +$B$K%U%C%/$r;HMQ$7$?$$$J$i!$$I$N$h$&$K9T$&$+Cm0U?<$/9M$($kI,MW$,$"$k!%(B -Mercurial only locks a repository when it is writing to the -repository, and only the parts of Mercurial that write to the -repository pay attention to locks. Write locks are necessary to -prevent multiple simultaneous writers from scribbling on each other's -work, corrupting the repository. +%Mercurial only locks a repository when it is writing to the +%repository, and only the parts of Mercurial that write to the +%repository pay attention to locks. Write locks are necessary to +%prevent multiple simultaneous writers from scribbling on each other's +%work, corrupting the repository. + +Mercurial$B$O%j%]%8%H%j$K=q$-9~$_$r9T$&$H$-$K$@$1%j%]%8%H%j$r%m%C%/$9$k!%(B +$B$^$?(BMercurial$B$N=q$-9~$_$r9T$&ItJ,$N$_$,%m%C%/$r9MN8$9$k!%=q$-9~$_%m%C%/(B +$B$O!$J#?t$NF1;~=q$-9~$_$,B>$NJQ99$r>e=q$-$7!$%j%]%8%H%j$rGKB;$9$k$N$rKI$0!%(B -Because Mercurial is careful with the order in which it reads and -writes data, it does not need to acquire a lock when it wants to read -data from the repository. The parts of Mercurial that read from the -repository never pay attention to locks. This lockless reading scheme -greatly increases performance and concurrency. +%Because Mercurial is careful with the order in which it reads and +%writes data, it does not need to acquire a lock when it wants to read +%data from the repository. The parts of Mercurial that read from the +%repository never pay attention to locks. This lockless reading scheme +%greatly increases performance and concurrency. -With great performance comes a trade-off, though, one which has the -potential to cause you trouble unless you're aware of it. To describe -this requires a little detail about how Mercurial adds changesets to a -repository and reads those changes. +Mercurial$B$O%G!<%?$NFI$_=q$-$N=g=x$rCm0U?<$/9T$&$?$a!$%j%]%8%H%j$+$i$N%G!<(B +$B%?FI$_=P$7$N:]$K%m%C%/$r<hF@$9$kI,MW$,$J$$!%(B Mercurial$B$N%j%]%8%H%j$+$iFI(B +$B$_=P$7$r9T$&ItJ,$O!$%m%C%/$rA4$/5$$K$9$kI,MW$,$J$$!%$3$NL5%m%C%/FI$_=P$7(B +$B$K$h$C$F!$F1;~<B9T@-$H@-G=$rBgI}$K9b$a$F$$$k!%(B + +%With great performance comes a trade-off, though, one which has the +%potential to cause you trouble unless you're aware of it. To describe +%this requires a little detail about how Mercurial adds changesets to a +%repository and reads those changes. + +$B$7$+$7$J$,$i$3$N9b@-G=$O$=$l$rCN$i$J$1$l$PLdBj$r0z$-5/$3$9$"$k%H%l!<%I%*(B +$B%U$r$b$b$?$i$9!%$3$l$r@bL@$9$k$?$a$K!$(BMercurial$B$,$I$N$h$&$K%A%'%s%8%;%C%H(B +$B$r%j%]%8%H%j$KDI2C$7!$$=$l$i$rFI$_=P$9$+$N>\:Y$K?($l$J$1$l$P$J$i$J$$!%(B -When Mercurial \emph{writes} metadata, it writes it straight into the -destination file. It writes file data first, then manifest data -(which contains pointers to the new file data), then changelog data -(which contains pointers to the new manifest data). Before the first -write to each file, it stores a record of where the end of the file -was in its transaction log. If the transaction must be rolled back, -Mercurial simply truncates each file back to the size it was before the -transaction began. +%When Mercurial \emph{writes} metadata, it writes it straight into the +%destination file. It writes file data first, then manifest data +%(which contains pointers to the new file data), then changelog data +%(which contains pointers to the new manifest data). Before the first +%write to each file, it stores a record of where the end of the file +%was in its transaction log. If the transaction must be rolled back, +%Mercurial simply truncates each file back to the size it was before the +%transaction began. + +Mercurial$B$O%a%?%G!<%?$r(B\emph{$B=q$-9~$`(B}$B$H$-!$D>@\L\E*$N%U%!%$%k$K=q$-9~$_(B +$B$9$k!%(BMercurial$B$O$^$:%U%!%$%k%G!<%?$r=q$-9~$_!$<!$$$G!J?7$7$$%U%!%$%k%G!<(B +$B%?$N>l=j$r<($9%]%$%s%?$r4^$`!K%^%K%U%'%9%H%G!<%?$r=q$-9~$`!%$=$7$F!J?7$7(B +$B$$%^%K%U%'%9%H%G!<%?$N>l=j$r<($9%]%$%s%?$r4^$`!K%A%'%s%8%m%0%G!<%?$r=q$-(B +$B9~$`!%3F!9$N%U%!%$%k$X$N:G=i$N=q$-9~$_$NA0$K!$%U%!%$%k$NKvHx$N%l%3!<%I$r(B +$B%H%i%s%6%/%7%g%s%m%0$KJ]B8$9$k!%%H%i%s%6%/%7%g%s$,%m!<%k%P%C%/$5$l$k>l9g(B +$B$O!$(BMercurial$B$O3F!9$N%U%!%$%k$r%H%i%s%6%/%7%g%s$,;O$^$kA0$N%5%$%:$K@Z$j5M(B +$B$a$k!%(B + +%When Mercurial \emph{reads} metadata, it reads the changelog first, +%then everything else. Since a reader will only access parts of the +%manifest or file metadata that it can see in the changelog, it can +%never see partially written data. -When Mercurial \emph{reads} metadata, it reads the changelog first, -then everything else. Since a reader will only access parts of the -manifest or file metadata that it can see in the changelog, it can -never see partially written data. +Mercurial$B$O%a%?%G!<%?$r(B\emph{$BFI$`(B}$B;~$K$^$:%A%'%s%8%m%0$rFI$_!$<!$$$G;D$j(B +$B$NItJ,$rFI$`!%%j!<%@$O%A%'%s%8%m%0$K8=$l$k%^%K%U%'%9%H$N0lIt$^$?$O%U%!%$(B +$B%k%a%?%G!<%?$N0lIt$K$N$_%"%/%;%9$9$k$?$a!$ItJ,E*$K=q$+$l$?%G!<%?$r8+$k$3(B +$B$H$O$G$-$J$$!%(B + +%Some controlling hooks (\hook{pretxncommit} and +%\hook{pretxnchangegroup}) run when a transaction is almost complete. +%All of the metadata has been written, but Mercurial can still roll the +%transaction back and cause the newly-written data to disappear. -Some controlling hooks (\hook{pretxncommit} and -\hook{pretxnchangegroup}) run when a transaction is almost complete. -All of the metadata has been written, but Mercurial can still roll the -transaction back and cause the newly-written data to disappear. +$B$$$/$D$+$N@)8f%U%C%/!J(B\hook{pretxncommit}$B$H(B\hook{pretxnchangegroup}$B!K$O%H(B +$B%i%s%6%/%7%g%s$,$[$\40N;$7$?;~$K<B9T$5$l$k!%$9$Y$F$N%a%?%G!<%?$,=q$-9~$^(B +$B$l$k$,!$$3$N;~E@$G$b(BMercurial$B$O%H%i%s%6%/%7%g%s$r85$KLa$9$3$H$,$G$-!$$=$N(B +$B>l9g$O?7$7$/=q$+$l$?%G!<%?$O>C<:$9$k!%(B -If one of these hooks runs for long, it opens a window of time during -which a reader can see the metadata for changesets that are not yet -permanent, and should not be thought of as ``really there''. The -longer the hook runs, the longer that window is open. +%If one of these hooks runs for long, it opens a window of time during +%which a reader can see the metadata for changesets that are not yet +%permanent, and should not be thought of as ``really there''. The +%longer the hook runs, the longer that window is open. + +$B$3$l$i$N%U%C%/$N$&$A(B1$B$D$,D9;~4V$K$o$?$C$F<B9T$5$l$F$$$k$H!$%j!<%@$,%A%'%s(B +$B%8%;%C%H$N%a%?%G!<%?$rFI$`$3$H$N$G$-$k%?%$%`%&%#%s%I%&$,3+$/!%$3$N%A%'%s(B +$B%8%;%C%H$O$^$@1JB3E*$J$b$N$K$J$C$F$*$i$:!$=>$C$F<B:_$9$k$H9M$($k$Y$-$G$O(B +$B$J$$$b$N$G$"$k!%%U%C%/$,<B9T$5$l$F$$$k;~4V$,D9$/$J$l$P$J$k$[$I!$%?%$%`%&%#(B +$B%s%I%&$,3+$/;~4V$bD9$/$J$k!%(B + %\subsection{The problem illustrated} \subsection{$BLdBj$N>\:Y(B}