Mercurial > hgbook
annotate ja/hook.tex @ 800:1a30d2627512
Propagate 2ff0a43f1152
Update ch03
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 18 Jun 2009 20:04:44 +0900 |
parents | 2a93b1d35990 |
children | 8a3041e6f3cb |
rev | line source |
---|---|
374 | 1 %\chapter{Handling repository events with hooks} |
2 \chapter{$B%j%]%8%H%j%$%Y%s%H$r%U%C%/$G<h$j07$&(B} | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
3 \label{chap:hook} |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
4 |
375 | 5 %Mercurial offers a powerful mechanism to let you perform automated |
6 %actions in response to events that occur in a repository. In some | |
7 %cases, you can even control Mercurial's response to those events. | |
8 | |
9 Mercurial$B$O!$%j%]%8%H%j$K5/$3$k%$%Y%s%H$KBP$7$F<+F02=$5$l$?%"%/%7%g%s$r9T(B | |
10 $B$&6/NO$J%a%+%K%:%`$r;}$C$F$$$k!%$$$/$D$+$N%$%Y%s%H$KBP$7$F$O!$(BMercurial$B$N(B | |
11 $BH?1~$r@)8f$9$k$3$H$b$G$-$k!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
12 |
375 | 13 %The name Mercurial uses for one of these actions is a \emph{hook}. |
14 %Hooks are called ``triggers'' in some revision control systems, but | |
15 %the two names refer to the same idea. | |
16 | |
17 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 | |
18 $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 | |
19 $B$3$l$i$O<B:]$OF1$8$b$N$G$"$k!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
20 |
374 | 21 %\section{An overview of hooks in Mercurial} |
22 \section{Mercurial$B$G$N%U%C%/$N35MW(B} | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
23 |
375 | 24 %Here is a brief list of the hooks that Mercurial supports. We will |
25 %revisit each of these hooks in more detail later, in | |
26 %section~\ref{sec:hook:ref}. | |
27 | |
28 Mercurial$B$,%5%]!<%H$9$k%U%C%/$N0lIt$rNs5s$9$k!%8D!9$N%U%C%/$K$D$$$F$O(B | |
29 $B8e$[$I(Bsection~\ref{sec:hook:ref}$B$G>\:Y$K?($l$k!%(B | |
41 | 30 |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
31 \begin{itemize} |
375 | 32 %\item[\small\hook{changegroup}] This is run after a group of |
33 % changesets has been brought into the repository from elsewhere. | |
34 \item[\small\hook{changegroup}] $B%A%'%s%8%;%C%H%0%k!<%W$,30It$+$i%j%]%8%H(B | |
35 $B%j$K2C$o$C$?8e$G8F$S=P$5$l$k!%(B | |
36 | |
37 %\item[\small\hook{commit}] This is run after a new changeset has been | |
38 % created in the local repository. | |
39 \item[\small\hook{commit}] $B%m!<%+%k%j%]%8%H%j$G?7$7$$%A%'%s%8%;%C%H$,:n(B | |
40 $B@.$5$l$?8e$K8F$S=P$5$l$k!%(B | |
41 | |
42 %\item[\small\hook{incoming}] This is run once for each new changeset | |
43 % that is brought into the repository from elsewhere. Notice the | |
44 % difference from \hook{changegroup}, which is run once per | |
45 % \emph{group} of changesets brought in. | |
46 | |
47 \item[\small\hook{incoming}] $B?7$7$$%A%'%s%8%;%C%H$,30It$+$i%j%]%8%H%j$K2C(B | |
48 $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 | |
49 $B%/$K(B\hook{changegroup}$B%U%C%/$,$"$k!%(B | |
50 | |
51 %\item[\small\hook{outgoing}] This is run after a group of changesets | |
52 % has been transmitted from this repository. | |
53 \item[\small\hook{outgoing}] $B%j%]%8%H%j$+$i%A%'%s%8%;%C%H%0%k!<%W$,30It(B | |
54 $B$KAw?.$5$l$?8e$K8F$S=P$5$l$k!%(B | |
55 | |
56 %\item[\small\hook{prechangegroup}] This is run before starting to | |
57 % bring a group of changesets into the repository. | |
58 \item[\small\hook{prechangegroup}] $B%A%'%s%8%;%C%H%0%k!<%W$r%j%]%8%H%j$+(B | |
59 $B$i30It$K;}$A=P$9A0$K8F$S=P$5$l$k!%(B | |
60 | |
61 %\item[\small\hook{precommit}] Controlling. This is run before starting | |
62 % a commit. | |
63 \item[\small\hook{precommit}] Controlling. $B%3%_%C%H$,;O$^$kA0$K8F$S=P$5(B | |
64 $B$l$k!%(B | |
65 | |
66 %\item[\small\hook{preoutgoing}] Controlling. This is run before | |
67 % starting to transmit a group of changesets from this repository. | |
68 \item[\small\hook{preoutgoing}] Controlling. $B%A%'%s%8%;%C%H%0%k!<%W$r%j(B | |
69 $B%]%8%H%j$+$i30It$KAw?.$9$kA0$K8F$S=P$5$l$k!%(B | |
70 | |
71 %\item[\small\hook{pretag}] Controlling. This is run before creating a tag. | |
72 \item[\small\hook{pretag}] Controlling. $B%?%0$,:n@.$5$l$kA0$K8F$S=P$5$l$k!%(B | |
73 | |
74 %\item[\small\hook{pretxnchangegroup}] Controlling. This is run after a | |
75 % group of changesets has been brought into the local repository from | |
76 % another, but before the transaction completes that will make the | |
77 % changes permanent in the repository. | |
78 \item[\small\hook{pretxnchangegroup}] Controlling. $B%A%'%s%8%;%C%H%0%k!<%W(B | |
79 $B$,30It$+$i%m!<%+%k%j%]%8%H%j$K2C$o$C$?8e!$1JB3E*$K5-O?$9$k$?(B | |
80 $B$a$N%H%i%s%6%/%7%g%s$,40N;$9$kA0$K8F$S=P$5$l$k!%(B | |
81 | |
82 %\item[\small\hook{pretxncommit}] Controlling. This is run after a new | |
83 % changeset has been created in the local repository, but before the | |
84 % transaction completes that will make it permanent. | |
85 \item[\small\hook{pretxncommit}] Controlling. $B?7$7$$%A%'%s%8%;%C%H$,%m!<(B | |
86 $B%+%k%j%]%8%H%j$G:n@.$5$l$?8e!$1JB3E*$K5-O?$9$k$?$a$N%H%i%s%6(B | |
87 $B%/%7%g%s$,40N;$9$kA0$K8F$S=P$5$l$k!%(B | |
88 | |
89 %\item[\small\hook{preupdate}] Controlling. This is run before starting | |
90 % an update or merge of the working directory. | |
91 \item[\small\hook{preupdate}] Controlling. $B%o!<%-%s%0%G%#%l%/%H%j$N99?7(B | |
92 $B$^$?$O%^!<%8$,9T$o$l$kA0$K8F$S=P$5$l$k!%(B | |
93 | |
94 %\item[\small\hook{tag}] This is run after a tag is created. | |
95 \item[\small\hook{tag}] $B%?%0$,:n@.$5$l$?8e$G8F$S=P$5$l$k!%(B | |
96 | |
97 %\item[\small\hook{update}] This is run after an update or merge of the | |
98 % working directory has finished. | |
99 \item[\small\hook{update}] $B%o!<%-%s%0%G%#%l%/%H%j$N99?7$+%^!<%8$,40N;$7(B | |
100 $B$?;~$K8F$S=P$5$l$k!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
101 \end{itemize} |
375 | 102 %Each of the hooks whose description begins with the word |
103 %``Controlling'' has the ability to determine whether an activity can | |
104 %proceed. If the hook succeeds, the activity may proceed; if it fails, | |
105 %the activity is either not permitted or undone, depending on the hook. | |
106 | |
107 $B%U%C%/$N$&$A!$@bL@$,(B``Controlling''$B$H$$$&8l$G;O$^$k$b$N$O!$%U%C%/$N@.H]$r(B | |
108 $BH=Dj$7!$0J8e$NF0:n$r9T$&$+$I$&$+7hDj$9$k5!G=$,$"$k!%%U%C%/$,@.8y$9$k$HF0(B | |
109 $B:n$O@h$X?J$`!%%U%C%/$,@.8y$7$J$+$C$?>l9g$O0J8e$NF0:n$O<B9T$,5v2D$5$l$J$$(B | |
110 $B$+!$F0:n$,40N;$;$:=*$k!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
111 |
374 | 112 %\section{Hooks and security} |
113 \section{$B%U%C%/$H%;%-%e%j%F%#(B} | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
114 |
374 | 115 %\subsection{Hooks are run with your privileges} |
116 \subsection{$B%U%C%/$O%f!<%6$N8"8B$GF0:n$9$k(B} | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
117 |
375 | 118 %When you run a Mercurial command in a repository, and the command |
119 %causes a hook to run, that hook runs on \emph{your} system, under | |
120 %\emph{your} user account, with \emph{your} privilege level. Since | |
121 %hooks are arbitrary pieces of executable code, you should treat them | |
122 %with an appropriate level of suspicion. Do not install a hook unless | |
123 %you are confident that you know who created it and what it does. | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
124 |
375 | 125 $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 |
126 $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 | |
127 $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 | |
128 $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 | |
129 $B%s%9%H!<%k$7$F$O$J$i$J$$!%(B | |
130 | |
131 %In some cases, you may be exposed to hooks that you did not install | |
132 %yourself. If you work with Mercurial on an unfamiliar system, | |
133 %Mercurial will run hooks defined in that system's global \hgrc\ file. | |
134 | |
135 $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 | |
136 $BB>=j$N%7%9%F%`$N>e$G(BMercurial$B$r;H$&>l9g!$(BMercurial$B$,%7%9%F%`%o%$%I$N(B | |
137 \hgrc\ $B%U%!%$%k$GDj5A$5$l$?%U%C%/$r5/F0$9$k2DG=@-$,$"$k!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
138 |
375 | 139 %If you are working with a repository owned by another user, Mercurial |
140 %can run hooks defined in that user's repository, but it will still run | |
141 %them as ``you''. For example, if you \hgcmd{pull} from that | |
142 %repository, and its \sfilename{.hg/hgrc} defines a local | |
143 %\hook{outgoing} hook, that hook will run under your user account, even | |
144 %though you don't own that repository. | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
145 |
375 | 146 $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 |
147 $B%H%jFb$GDj5A$5$l$?%U%C%/$r<B9T$7F@$k$,!$<B9T8"8B$O$"$J$?$N$b$N$G9T$o$l$k!%(B | |
148 $BNc$($P$=$N%j%]%8%H%j$+$i(B\hgcmd{pull}$B$r9T$&$H$-!$%j%]%8%H%jFb$N(B | |
149 \sfilename{.hg/hgrc}$B%U%!%$%k$G%m!<%+%k$J(B\hook{outgoing}$B%U%C%/$,Dj5A$5$l$F(B | |
150 $B$$$k$H!$$"$J$?$O$=$N%j%]%8%H%j$r=jM-$7$F$$$J$$$K$b$+$+$o$i$:$=$N%U%C%/$O(B | |
151 $B$"$J$?$N8"8B$G<B9T$5$l$k!%(B | |
152 | |
153 %\begin{note} | |
154 % This only applies if you are pulling from a repository on a local or | |
155 % network filesystem. If you're pulling over http or ssh, any | |
156 % \hook{outgoing} hook will run under whatever account is executing | |
157 % the server process, on the server. | |
158 %\end{note} | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
159 \begin{note} |
375 | 160 $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 |
161 $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 | |
162 $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 | |
163 $B%s%H$N8"8B$G<B9T$5$l$k!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
164 \end{note} |
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
165 |
375 | 166 %XXX To see what hooks are defined in a repository, use the |
167 %\hgcmdargs{config}{hooks} command. If you are working in one | |
168 %repository, but talking to another that you do not own (e.g.~using | |
169 %\hgcmd{pull} or \hgcmd{incoming}), remember that it is the other | |
170 %repository's hooks you should be checking, not your own. | |
171 | |
172 XXX $B%j%]%8%H%jFb$GDj5A$5$l$F$$$k%U%C%/$r8+$k$K$O(B | |
173 \hgcmdargs{config}{hooks}$B%3%^%s%I$r;H$&!%$"$k%j%]%8%H%j$G:n6H$7$F$$$F!$?7(B | |
174 $B$7$$%3!<%I$rB>$N%j%]%8%H%j$+$iF~<j$9$k$?$a$KDL?.$r9T$&>l9g!JNc$($P(B | |
175 \hgcmd{pull}$B$+(B\hgcmd{incoming}$B$r<B9T$9$k!K(B $B!$%A%'%C%/$9$Y$-%U%C%/$O<j85$N(B | |
176 $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 | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
177 |
374 | 178 %\subsection{Hooks do not propagate} |
375 | 179 \subsection{$B%U%C%/$OEAGE$7$J$$(B} |
180 | |
181 %In Mercurial, hooks are not revision controlled, and do not propagate | |
182 %when you clone, or pull from, a repository. The reason for this is | |
183 %simple: a hook is a completely arbitrary piece of executable code. It | |
184 %runs under your user identity, with your privilege level, on your | |
185 %machine. | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
186 |
375 | 187 Mercurial$B$G$O!$%U%C%/$O%j%S%8%g%s4IM}$5$l$:!$%j%]%8%H%j$+$i%/%m!<%s$7$?$j(B |
188 pull$B$7$F$bEAGE$7$J$$!%$3$&$J$C$F$$$kM}M3$OC1=c$G!$%U%C%/$OG$0U$N<B9T2DG=(B | |
189 $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 | |
190 $BFC8"%l%Y%k$GF0:n$GF0$/!%(B | |
191 | |
192 %It would be extremely reckless for any distributed revision control | |
193 %system to implement revision-controlled hooks, as this would offer an | |
194 %easily exploitable way to subvert the accounts of users of the | |
195 %revision control system. | |
196 | |
197 $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 | |
198 $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 | |
199 $B%`$N%f!<%6%"%+%&%s%H$r56Au$9$k$h$&$J;E3]$1$r4JC1$K<B8=$G$-$F$7$^$&!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
200 |
375 | 201 %Since Mercurial does not propagate hooks, if you are collaborating |
202 %with other people on a common project, you should not assume that they | |
203 %are using the same Mercurial hooks as you are, or that theirs are | |
204 %correctly configured. You should document the hooks you expect people | |
205 %to use. | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
206 |
375 | 207 Mercurial$B$O%U%C%/$rEAGE$5$;$J$$$N$G!$6&DL$N%W%m%8%'%/%H$GB>$N3+H/<T$H6(NO(B |
208 $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 | |
209 $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 | |
210 $B$9$Y$-$G$O$J$$!%H`$i$,%U%C%/$r;H$&$h$&$KK>$`$N$G$"$l$P!$;HMQK!$K$D$$$F%I(B | |
211 $B%-%e%a%s%H$r:n@.$9$Y$-$G$"$k!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
212 |
375 | 213 %In a corporate intranet, this is somewhat easier to control, as you |
214 %can for example provide a ``standard'' installation of Mercurial on an | |
215 %NFS filesystem, and use a site-wide \hgrc\ file to define hooks that | |
216 %all users will see. However, this too has its limits; see below. | |
217 | |
218 $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 | |
219 $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 | |
220 $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 | |
221 $B$H$,$G$-$k!%$7$+$7$3$NJ}K!$K$b2<5-$N$h$&$J7gE@$,$"$k!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
222 |
374 | 223 %\subsection{Hooks can be overridden} |
224 \subsection{$B%U%C%/$O%*!<%P%i%$%I2DG=$G$"$k(B} | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
225 |
375 | 226 %Mercurial allows you to override a hook definition by redefining the |
227 %hook. You can disable it by setting its value to the empty string, or | |
228 %change its behaviour as you wish. | |
229 | |
230 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 | |
231 $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 | |
232 $B$G6X;_$9$k$3$H$,$G$-$k!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
233 |
375 | 234 %If you deploy a system-~or site-wide \hgrc\ file that defines some |
235 %hooks, you should thus understand that your users can disable or | |
236 %override those hooks. | |
237 | |
238 $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 | |
239 $B$F$b!$%j%]%8%H%j$N%f!<%6$,%U%C%/$r6X;_$7$?$j%*!<%P%i%$%I$G$-$F$7$^$&$N$K(B | |
240 $B5$IU$/$@$m$&!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
241 |
374 | 242 %\subsection{Ensuring that critical hooks are run} |
243 \subsection{$B%/%j%F%#%+%k$J%U%C%/$,3N<B$K<B9T$5$l$k$h$&$K$9$k(B} | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
244 |
375 | 245 %Sometimes you may want to enforce a policy that you do not want others |
246 %to be able to work around. For example, you may have a requirement | |
247 %that every changeset must pass a rigorous set of tests. Defining this | |
248 %requirement via a hook in a site-wide \hgrc\ won't work for remote | |
249 %users on laptops, and of course local users can subvert it at will by | |
250 %overriding the hook. | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
251 |
375 | 252 $B;~$K$OB>$N3+H/<T$,2sHr:v$r$H$l$J$$$h$&$J%]%j%7!<$rMW@A$7$?$$>l9g$,$"$k$@(B |
253 $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 | |
254 $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 | |
255 $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 | |
256 $B%U%C%/$r%*!<%P%i%$%I$G$-$k$?$a!$%m!<%+%k%f!<%6$K$H$C$F$bL5;k$G$-$F$7$^$&!%(B | |
257 | |
258 %Instead, you can set up your policies for use of Mercurial so that | |
259 %people are expected to propagate changes through a well-known | |
260 %``canonical'' server that you have locked down and configured | |
261 %appropriately. | |
262 | |
263 $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 | |
264 $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 | |
265 $B$H$,$G$-$k!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
266 |
375 | 267 %One way to do this is via a combination of social engineering and |
268 %technology. Set up a restricted-access account; users can push | |
269 %changes over the network to repositories managed by this account, but | |
270 %they cannot log into the account and run normal shell commands. In | |
271 %this scenario, a user can commit a changeset that contains any old | |
272 %garbage they want. | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
273 |
375 | 274 $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 |
275 $BK!$G$"$k!%8BDj%"%/%;%9%"%+%&%s%H$r@_Dj$7!$$3$N%"%+%&%s%H$G4IM}$5$l$F$$$k(B | |
276 $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 | |
277 $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 | |
278 $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 | |
279 $B$G$b%3%_%C%H$9$k$3$H$,$G$-$k!%(B | |
280 | |
281 %When someone pushes a changeset to the server that everyone pulls | |
282 %from, the server will test the changeset before it accepts it as | |
283 %permanent, and reject it if it fails to pass the test suite. If | |
284 %people only pull changes from this filtering server, it will serve to | |
285 %ensure that all changes that people pull have been automatically | |
286 %vetted. | |
287 | |
288 $BB?$/$N%f!<%6$,(Bpull$B$9$k%5!<%P$KC/$+$,%A%'%s%8%;%C%H$r(Bpush$B$7$?>l9g!$%5!<%P(B | |
289 $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 | |
290 $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 | |
291 $B9T$&$N$G$"$l$P!$A4$F$NJQ99$O<+F0E*$KA4$F8!::$5$l$F$$$k$3$H$K$J$k!%(B | |
38
b49a7dd4e564
More content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
37
diff
changeset
|
292 |
374 | 293 %\section{Care with \texttt{pretxn} hooks in a shared-access repository} |
294 \section{$B6&M-%"%/%;%9%j%]%8%H%j$G(B\texttt{pretxn}$B%U%C%/$r;H$&(B} | |
41 | 295 |
375 | 296 %If you want to use hooks to do some automated work in a repository |
297 %that a number of people have shared access to, you need to be careful | |
298 %in how you do this. | |
299 | |
300 $BJ#?t$N%f!<%6$,6&M-%"%/%;%9$r9T$&%j%]%8%H%j$G!$<+F02=$5$l$?:n6H$r9T$&$?$a(B | |
301 $B$K%U%C%/$r;HMQ$7$?$$$J$i!$$I$N$h$&$K9T$&$+Cm0U?<$/9M$($kI,MW$,$"$k!%(B | |
41 | 302 |
375 | 303 %Mercurial only locks a repository when it is writing to the |
304 %repository, and only the parts of Mercurial that write to the | |
305 %repository pay attention to locks. Write locks are necessary to | |
306 %prevent multiple simultaneous writers from scribbling on each other's | |
307 %work, corrupting the repository. | |
308 | |
309 Mercurial$B$O%j%]%8%H%j$K=q$-9~$_$r9T$&$H$-$K$@$1%j%]%8%H%j$r%m%C%/$9$k!%(B | |
310 $B$^$?(BMercurial$B$N=q$-9~$_$r9T$&ItJ,$N$_$,%m%C%/$r9MN8$9$k!%=q$-9~$_%m%C%/(B | |
311 $B$O!$J#?t$NF1;~=q$-9~$_$,B>$NJQ99$r>e=q$-$7!$%j%]%8%H%j$rGKB;$9$k$N$rKI$0!%(B | |
41 | 312 |
375 | 313 %Because Mercurial is careful with the order in which it reads and |
314 %writes data, it does not need to acquire a lock when it wants to read | |
315 %data from the repository. The parts of Mercurial that read from the | |
316 %repository never pay attention to locks. This lockless reading scheme | |
317 %greatly increases performance and concurrency. | |
41 | 318 |
375 | 319 Mercurial$B$O%G!<%?$NFI$_=q$-$N=g=x$rCm0U?<$/9T$&$?$a!$%j%]%8%H%j$+$i$N%G!<(B |
320 $B%?FI$_=P$7$N:]$K%m%C%/$r<hF@$9$kI,MW$,$J$$!%(B Mercurial$B$N%j%]%8%H%j$+$iFI(B | |
321 $B$_=P$7$r9T$&ItJ,$O!$%m%C%/$rA4$/5$$K$9$kI,MW$,$J$$!%$3$NL5%m%C%/FI$_=P$7(B | |
322 $B$K$h$C$F!$F1;~<B9T@-$H@-G=$rBgI}$K9b$a$F$$$k!%(B | |
323 | |
324 %With great performance comes a trade-off, though, one which has the | |
325 %potential to cause you trouble unless you're aware of it. To describe | |
326 %this requires a little detail about how Mercurial adds changesets to a | |
327 %repository and reads those changes. | |
328 | |
329 $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 | |
330 $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 | |
331 $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 | |
41 | 332 |
375 | 333 %When Mercurial \emph{writes} metadata, it writes it straight into the |
334 %destination file. It writes file data first, then manifest data | |
335 %(which contains pointers to the new file data), then changelog data | |
336 %(which contains pointers to the new manifest data). Before the first | |
337 %write to each file, it stores a record of where the end of the file | |
338 %was in its transaction log. If the transaction must be rolled back, | |
339 %Mercurial simply truncates each file back to the size it was before the | |
340 %transaction began. | |
341 | |
342 Mercurial$B$O%a%?%G!<%?$r(B\emph{$B=q$-9~$`(B}$B$H$-!$D>@\L\E*$N%U%!%$%k$K=q$-9~$_(B | |
343 $B$9$k!%(BMercurial$B$O$^$:%U%!%$%k%G!<%?$r=q$-9~$_!$<!$$$G!J?7$7$$%U%!%$%k%G!<(B | |
344 $B%?$N>l=j$r<($9%]%$%s%?$r4^$`!K%^%K%U%'%9%H%G!<%?$r=q$-9~$`!%$=$7$F!J?7$7(B | |
345 $B$$%^%K%U%'%9%H%G!<%?$N>l=j$r<($9%]%$%s%?$r4^$`!K%A%'%s%8%m%0%G!<%?$r=q$-(B | |
346 $B9~$`!%3F!9$N%U%!%$%k$X$N:G=i$N=q$-9~$_$NA0$K!$%U%!%$%k$NKvHx$N%l%3!<%I$r(B | |
347 $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 | |
348 $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 | |
349 $B$a$k!%(B | |
350 | |
351 %When Mercurial \emph{reads} metadata, it reads the changelog first, | |
352 %then everything else. Since a reader will only access parts of the | |
353 %manifest or file metadata that it can see in the changelog, it can | |
354 %never see partially written data. | |
41 | 355 |
375 | 356 Mercurial$B$O%a%?%G!<%?$r(B\emph{$BFI$`(B}$B;~$K$^$:%A%'%s%8%m%0$rFI$_!$<!$$$G;D$j(B |
357 $B$NItJ,$rFI$`!%%j!<%@$O%A%'%s%8%m%0$K8=$l$k%^%K%U%'%9%H$N0lIt$^$?$O%U%!%$(B | |
358 $B%k%a%?%G!<%?$N0lIt$K$N$_%"%/%;%9$9$k$?$a!$ItJ,E*$K=q$+$l$?%G!<%?$r8+$k$3(B | |
359 $B$H$O$G$-$J$$!%(B | |
360 | |
361 %Some controlling hooks (\hook{pretxncommit} and | |
362 %\hook{pretxnchangegroup}) run when a transaction is almost complete. | |
363 %All of the metadata has been written, but Mercurial can still roll the | |
364 %transaction back and cause the newly-written data to disappear. | |
41 | 365 |
375 | 366 $B$$$/$D$+$N@)8f%U%C%/!J(B\hook{pretxncommit}$B$H(B\hook{pretxnchangegroup}$B!K$O%H(B |
367 $B%i%s%6%/%7%g%s$,$[$\40N;$7$?;~$K<B9T$5$l$k!%$9$Y$F$N%a%?%G!<%?$,=q$-9~$^(B | |
368 $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 | |
369 $B>l9g$O?7$7$/=q$+$l$?%G!<%?$O>C<:$9$k!%(B | |
41 | 370 |
375 | 371 %If one of these hooks runs for long, it opens a window of time during |
372 %which a reader can see the metadata for changesets that are not yet | |
373 %permanent, and should not be thought of as ``really there''. The | |
374 %longer the hook runs, the longer that window is open. | |
375 | |
376 $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 | |
377 $B%8%;%C%H$N%a%?%G!<%?$rFI$`$3$H$N$G$-$k%?%$%`%&%#%s%I%&$,3+$/!%$3$N%A%'%s(B | |
378 $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 | |
379 $B$J$$$b$N$G$"$k!%%U%C%/$,<B9T$5$l$F$$$k;~4V$,D9$/$J$l$P$J$k$[$I!$%?%$%`%&%#(B | |
380 $B%s%I%&$,3+$/;~4V$bD9$/$J$k!%(B | |
381 | |
374 | 382 %\subsection{The problem illustrated} |
383 \subsection{$BLdBj$N>\:Y(B} | |
134
b727a63518d4
Minor updates to race description.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
384 |
377 | 385 %In principle, a good use for the \hook{pretxnchangegroup} hook would |
386 %be to automatically build and test incoming changes before they are | |
387 %accepted into a central repository. This could let you guarantee that | |
388 %nobody can push changes to this repository that ``break the build''. | |
389 %But if a client can pull changes while they're being tested, the | |
390 %usefulness of the test is zero; an unsuspecting someone can pull | |
391 %untested changes, potentially breaking their build. | |
392 | |
393 $B<BMQ$K$*$1$k(B\hook{pretxnchangegroup}$B%U%C%/$NNI$$;HMQK!$H$7$F$O!$E~Ce$7$?(B | |
394 $BJQ99$,Cf1{$N%j%]%8%H%j$K<h$j9~$^$l$kA0$K<+F0$G%S%k%I$H%F%9%H$r9T$&$3$H$,(B | |
395 $B9M$($i$l$k!%$3$l$K$h$j!$%S%k%I$rK8$2$kJQ99$OC/$b%j%]%8%H%j$K(Bpush$B$G$-$J$$(B | |
396 $B$3$H$,3N<B$K$J$k!%%/%i%$%"%s%H$,%F%9%HCf$KJQ99$r(Bpull$B$9$k$3$H$,$G$-$l$P!$(B | |
397 $B$3$N%F%9%H$NM-MQ@-$O%<%m$K$J$C$F$7$^$&!%5?$$$r;}$?$:$KC/$+$,%F%9%H$5$l$F(B | |
398 $B$$$J$$JQ99$r(Bpull$B$G$-$k$N$G$"$l$P!$H`$i$N%S%k%I$O<:GT$9$k2DG=@-$,$"$k!%(B | |
399 | |
400 %The safest technological answer to this challenge is to set up such a | |
401 %``gatekeeper'' repository as \emph{unidirectional}. Let it take | |
402 %changes pushed in from the outside, but do not allow anyone to pull | |
403 %changes from it (use the \hook{preoutgoing} hook to lock it down). | |
404 %Configure a \hook{changegroup} hook so that if a build or test | |
405 %succeeds, the hook will push the new changes out to another repository | |
406 %that people \emph{can} pull from. | |
41 | 407 |
377 | 408 $B$3$NLdBj$X$N5;=QE*$K:G$b0BA4$J2sEz$O!$(B``$BLgHV(B''$B%j%]%8%H%j$r(B\emph{$B0lJ}8~(B}$B$K(B |
409 $B@_Dj$9$k$3$H$G$"$k!%%j%]%8%H%j$r30It$+$i(Bpush$B$5$l$?JQ99$r<u$1<h$k$,!$C/$b(B | |
410 pull$B$G$-$J$$$h$&$K@_Dj$9$k!J(B\hook{preoutgoing}$B%U%C%/$r;H$C$F%j%]%8%H%j$r(B | |
411 $B%m%C%/$9$k!K!%(B\hook{changegroup}$B%U%C%/$r@_Dj$7!$%S%k%I$d%F%9%H$,@.8y$7$?(B | |
378 | 412 $B$H$-$K8B$C$F!$%U%C%/$,?7$?$JJQ99$r%f!<%6$N(Bpull\emph{$B$G$-$k(B}$BJL$N%j%]%8%H(B |
377 | 413 $B%j$K(Bpush$B$9$k$h$&$K$9$k!%(B |
414 | |
415 %In practice, putting a centralised bottleneck like this in place is | |
416 %not often a good idea, and transaction visibility has nothing to do | |
417 %with the problem. As the size of a project---and the time it takes to | |
418 %build and test---grows, you rapidly run into a wall with this ``try | |
419 %before you buy'' approach, where you have more changesets to test than | |
420 %time in which to deal with them. The inevitable result is frustration | |
421 %on the part of all involved. | |
41 | 422 |
377 | 423 $B<B:]>e$O!$$3$N$h$&$K=8Cf$7$?%\%H%k%M%C%/$rCV$/$3$H$ONI$$9M$($H$O8@$($:!$(B |
424 $B%H%i%s%6%/%7%g%s$N2D;k@-$OA4$/$J$$!%%W%m%8%'%/%H$N%5%$%:$*$h$S%S%k%I$H%F(B | |
425 $B%9%H$KMW$9$k;~4V$,A}2C$9$k$K=>$C$F!$$3$N$h$&$J(B``$B;vA0$K;n$9(B''$B<jK!$OJI$KFM(B | |
426 $B$-Ev$?$k!%%F%9%H$K;H$($k;~4V$G;+$-@Z$l$J$$$[$I$N%A%'%s%8%;%C%H$r;n$5$J$1(B | |
427 $B$l$P$J$i$J$/$J$k$+$i$G$"$k!%%U%i%9%H%l!<%7%g%s$,Cy$k$N$OHr$1$i$l$J$$$@$m(B | |
428 $B$&!%(B | |
134
b727a63518d4
Minor updates to race description.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
429 |
377 | 430 %An approach that scales better is to get people to build and test |
431 %before they push, then run automated builds and tests centrally | |
432 %\emph{after} a push, to be sure all is well. The advantage of this | |
433 %approach is that it does not impose a limit on the rate at which the | |
434 %repository can accept changes. | |
435 | |
436 $B$h$j%9%1!<%k$9$k<jK!$O!$3+H/<T$K(Bpush$BA0$N%S%k%I$H%F%9%H$r$5$;$k$3$H$G$"(B | |
437 $B$k!%Cf1{$G<+F0$K$h$k%S%k%I$H%F%9%H$r9T$&$N$O!$(Bpush\emph{$B8e(B}$B$K!$A4$F$KLdBj(B | |
438 $B$,$J$$$3$H$r3NG'$9$k$?$a$K9T$&!%$3$N%"%W%m!<%A$NMxE@$O%j%]%8%H%j$,JQ99$r(B | |
439 $B<u$1F~$l$k%Z!<%9$K2?$b@)8B$r2]$5$J$$$3$H$G$"$k!%(B | |
41 | 440 |
374 | 441 %\section{A short tutorial on using hooks} |
442 \section{$B%U%C%/$N;HMQK!(B} | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
443 \label{sec:hook:simple} |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
444 |
379 | 445 %It is easy to write a Mercurial hook. Let's start with a hook that |
446 %runs when you finish a \hgcmd{commit}, and simply prints the hash of | |
447 %the changeset you just created. The hook is called \hook{commit}. | |
448 | |
449 Mercurial$B%U%C%/$r=q$/$N$OMF0W$$!%$3$3$G$O(B\hgcmd{commit}$B%3%^%s%I$,=*N;$7(B | |
450 $B$?:]$K!$:n@.$5$l$?%A%'%s%8%;%C%H$N%O%C%7%eCM$rI=<($9$k$/%U%C%/$r=q$$$F$_(B | |
451 $B$h$&!%$3$N%U%C%/$r(B\hook{commit}$B$H8F$V$3$H$K$9$k!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
452 |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
453 \begin{figure}[ht] |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
454 \interaction{hook.simple.init} |
379 | 455 % \caption{A simple hook that runs when a changeset is committed} |
456 \caption{$B%A%'%s%8%;%C%H$,%3%_%C%H$5$l$?;~$KF0:n$9$kC1=c$J%U%C%/(B} | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
457 \label{ex:hook:init} |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
458 \end{figure} |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
459 |
379 | 460 %All hooks follow the pattern in example~\ref{ex:hook:init}. You add |
461 %an entry to the \rcsection{hooks} section of your \hgrc\. On the left | |
462 %is the name of the event to trigger on; on the right is the action to | |
463 %take. As you can see, you can run an arbitrary shell command in a | |
464 %hook. Mercurial passes extra information to the hook using | |
465 %environment variables (look for \envar{HG\_NODE} in the example). | |
466 | |
467 $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 | |
468 \rcsection{hooks}$B%;%/%7%g%s$K%(%s%H%j$rDI2C$9$k!%:8JU$K%H%j%,!<$H$J$k%Y%s(B | |
469 $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 | |
470 $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 | |
471 Mercurial$B$+$i%U%C%/$KDI2C$N>pJs$rEO$9$3$H$,$G$-$k!%!JNc$N(B | |
472 \envar{HG\_NODE}$B$r;2>H!%!K(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
473 |
374 | 474 %\subsection{Performing multiple actions per event} |
475 \subsection{1$B$D$N%$%Y%s%H$KJ#?t$N%"%/%7%g%s$r9T$&(B} | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
476 |
379 | 477 %Quite often, you will want to define more than one hook for a |
478 %particular kind of event, as shown in example~\ref{ex:hook:ext}. | |
479 %Mercurial lets you do this by adding an \emph{extension} to the end of | |
480 %a hook's name. You extend a hook's name by giving the name of the | |
481 %hook, followed by a full stop (the ``\texttt{.}'' character), followed | |
482 %by some more text of your choosing. For example, Mercurial will run | |
483 %both \texttt{commit.foo} and \texttt{commit.bar} when the | |
484 %\texttt{commit} event occurs. | |
485 | |
486 $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 | |
487 $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 | |
488 \emph{$B3HD%;R(B}$B$rDI2C$9$k$3$H$G$3$l$,2DG=$K$J$k!%3HD%;R$rIU$1$k$K(B | |
489 $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 | |
490 $B$P$h$$!%Nc$($P(BMercurial$B$O(B\texttt{commit}$B%$%Y%s%H$,5/$-$?;~$K(B | |
491 \texttt{commit.foo}$B$H(B\texttt{commit.bar}$B%U%C%/$NN>J}$r8F$S=P$9!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
492 |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
493 \begin{figure}[ht] |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
494 \interaction{hook.simple.ext} |
379 | 495 % \caption{Defining a second \hook{commit} hook} |
496 \caption{2$BHVL\$N(B\hook{commit}$B%U%C%/$rDj5A$9$k(B} | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
497 \label{ex:hook:ext} |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
498 \end{figure} |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
499 |
379 | 500 %To give a well-defined order of execution when there are multiple |
501 %hooks defined for an event, Mercurial sorts hooks by extension, and | |
502 %executes the hook commands in this sorted order. In the above | |
503 %example, it will execute \texttt{commit.bar} before | |
504 %\texttt{commit.foo}, and \texttt{commit} before both. | |
505 | |
506 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 | |
507 $B$G%=!<%H$7!$%=!<%H$5$l$?=g=x$K=>$C$F%U%C%/$r<B9T$9$k!%>e5-$NNc$G$O(B | |
508 \texttt{commit}$B!$(B\texttt{commit.bar}$B!$(B\texttt{commit.foo}$B$N=g$K<B9T$9$k!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
509 |
379 | 510 %It is a good idea to use a somewhat descriptive extension when you |
511 %define a new hook. This will help you to remember what the hook was | |
512 %for. If the hook fails, you'll get an error message that contains the | |
513 %hook name and extension, so using a descriptive extension could give | |
514 %you an immediate hint as to why the hook failed (see | |
515 %section~\ref{sec:hook:perm} for an example). | |
516 | |
517 $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 | |
518 $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 | |
519 $B%U%C%/$,<:GT$7$?>l9g!$%(%i!<%a%C%;!<%8$K$O%U%C%/L>$H3HD%;R$,4^$^$l$k!%@b(B | |
520 $BL@E*$J3HD%;R$O%U%C%/$,<:GT$7$?M}M3$rCN$k$h$$<j$,$+$j$H$J$k!%!JNc(B | |
521 $B$O(B~\ref{sec:hook:perm}$B$r;2>H$N$3$H!%!K(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
522 |
374 | 523 %\subsection{Controlling whether an activity can proceed} |
524 \subsection{$BF0:n$,?J9T$G$-$k$+$I$&$+@)8f$9$k(B} | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
525 \label{sec:hook:perm} |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
526 |
379 | 527 %In our earlier examples, we used the \hook{commit} hook, which is |
528 %run after a commit has completed. This is one of several Mercurial | |
529 %hooks that run after an activity finishes. Such hooks have no way of | |
530 %influencing the activity itself. | |
531 | |
532 $BA0$NNc$G$O%3%_%C%H$,40N;$7$?8e$K<B9T$5$l$k(B\hook{commit}$B%U%C%/$rMQ$$$?!%$3(B | |
533 $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 | |
534 $B$"$k!%$3$N$h$&$J%U%C%/$O!$(BMercurial$B$NF0:n$=$N$b$N$K1F6A$r5Z$\$5$J$$!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
535 |
379 | 536 %Mercurial defines a number of events that occur before an activity |
537 %starts; or after it starts, but before it finishes. Hooks that | |
538 %trigger on these events have the added ability to choose whether the | |
539 %activity can continue, or will abort. | |
540 | |
541 Mercurial$B$OF0:n$N3+;OA0$d!$3+;O8e=*N;$9$k$^$G$N4V$KH/@8$9$k%$%Y%s%H$rB??t(B | |
542 $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 | |
543 $BCfCG$9$k$+7h$a$k$3$H$,$G$-$k!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
544 |
379 | 545 %The \hook{pretxncommit} hook runs after a commit has all but |
546 %completed. In other words, the metadata representing the changeset | |
547 %has been written out to disk, but the transaction has not yet been | |
548 %allowed to complete. The \hook{pretxncommit} hook has the ability to | |
549 %decide whether the transaction can complete, or must be rolled back. | |
550 | |
551 \hook{pretxncommit}$B%U%C%/$O%3%_%C%H8e!$%3%_%C%H$N40N;A0$K8F$S=P$5$l$k!%(B | |
552 $B8@$$BX$($k$H!$%A%'%s%8%;%C%H$r<($9%a%?%G!<%?$,%G%#%9%/$K=q$-9~$^$l$?8e(B | |
553 $B$G!$%H%i%s%6%/%7%g%s$,40N;$9$kA0$K8F$S=P$5$l$k!%(B | |
554 \hook{pretxncommit}$B%U%C%/$O%H%i%s%6%/%7%g%s$r40N;$9$k$+!$%m!<%k%P%C%/$9(B | |
555 $B$k$+$r7hDj$9$k5!G=$,$"$k!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
556 |
379 | 557 %If the \hook{pretxncommit} hook exits with a status code of zero, the |
558 %transaction is allowed to complete; the commit finishes; and the | |
559 %\hook{commit} hook is run. If the \hook{pretxncommit} hook exits with | |
560 %a non-zero status code, the transaction is rolled back; the metadata | |
561 %representing the changeset is erased; and the \hook{commit} hook is | |
562 %not run. | |
563 | |
564 \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 | |
565 $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 | |
566 \hook{pretxncommit}$B%U%C%/$,Hs(B0$B$N%9%F!<%?%9%3!<%I$G=*N;$9$k$H!$%H%i%s%6%/(B | |
567 $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 | |
568 $B$N>l9g(B\hook{commit}$B%U%C%/$O8F$S=P$5$l$J$$!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
569 |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
570 \begin{figure}[ht] |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
571 \interaction{hook.simple.pretxncommit} |
379 | 572 % \caption{Using the \hook{pretxncommit} hook to control commits} |
573 \caption{$B%3%_%C%H$r@)8f$9$k$?$a$K(B\hook{pretxncommit}$B%U%C%/$r;HMQ$9$k(B} | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
574 \label{ex:hook:pretxncommit} |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
575 \end{figure} |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
576 |
379 | 577 %The hook in example~\ref{ex:hook:pretxncommit} checks that a commit |
578 %comment contains a bug ID. If it does, the commit can complete. If | |
579 %not, the commit is rolled back. | |
580 | |
581 ~\ref{ex:hook:pretxncommit}$B$O%3%_%C%H%3%a%s%H$,%P%0(BID$B$r4^$`$+$r%A%'%C%/(B | |
582 $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 | |
583 $B%/$5$l$k!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
584 |
374 | 585 %\section{Writing your own hooks} |
586 \section{$B%*%j%8%J%k$N%U%C%/$r=q$/(B} | |
37 | 587 |
379 | 588 %When you are writing a hook, you might find it useful to run Mercurial |
589 %either with the \hggopt{-v} option, or the \rcitem{ui}{verbose} config | |
590 %item set to ``true''. When you do so, Mercurial will print a message | |
591 %before it calls each hook. | |
592 | |
593 $B%U%C%/$r=q$/>l9g!$(BMercurial$B$r(B\hggopt{-v}$B%*%W%7%g%s$rIU$1$?$j(B | |
594 \rcitem{ui}{verbose}$B@_Dj9`L\$r(B``true''$B$K@_Dj$9$k$3$H$OLr$KN)$D!%$3$N>l(B | |
595 $B9g!$(BMercurial$B$O3F!9$N%U%C%/$r8F$VA0$K%a%C%;!<%8$rI=<($9$k!%(B | |
37 | 596 |
374 | 597 %\subsection{Choosing how your hook should run} |
598 \subsection{$B%U%C%/$,$NF0:nJ}K!$rA*$V(B} | |
37 | 599 \label{sec:hook:lang} |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
600 |
379 | 601 %You can write a hook either as a normal program---typically a shell |
602 %script---or as a Python function that is executed within the Mercurial | |
603 %process. | |
604 | |
605 $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 | |
606 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 | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
607 |
379 | 608 %Writing a hook as an external program has the advantage that it |
609 %requires no knowledge of Mercurial's internals. You can call normal | |
610 %Mercurial commands to get any added information you need. The | |
611 %trade-off is that external hooks are slower than in-process hooks. | |
612 | |
613 $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 | |
614 $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 | |
615 $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 | |
616 $B%I%*%U$G$"$k!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
617 |
379 | 618 %An in-process Python hook has complete access to the Mercurial API, |
619 %and does not ``shell out'' to another process, so it is inherently | |
620 %faster than an external hook. It is also easier to obtain much of the | |
621 %information that a hook requires by using the Mercurial API than by | |
622 %running Mercurial commands. | |
623 | |
624 Python$B%W%m%;%9Fb%U%C%/$O(BMercurial API$B$X$N40A4$J%"%/%;%9$,2DG=$G$"$k!%(B | |
625 $BB>$N%W%m%;%9$r@8@.$9$k$3$H$,$J$$$?$a!$K\<AE*$K30It%U%C%/$h$j$b9bB.$G$"$k!%(B | |
626 $B%U%C%/$,I,MW$H$9$k>pJs$NBgH>$O!$(BMercurial$B%3%^%s%I$r<B9T$9$k$h$j$b(B | |
627 Mercurial API$B$r;H$C$F=8$a$kJ}$,MF0W$$!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
628 |
379 | 629 %If you are comfortable with Python, or require high performance, |
630 %writing your hooks in Python may be a good choice. However, when you | |
631 %have a straightforward hook to write and you don't need to care about | |
632 %performance (probably the majority of hooks), a shell script is | |
633 %perfectly fine. | |
634 | |
635 Python$B$r;H$$47$l$F$$$?$j!$9b$$@-G=$,I,MW$J$i$P!$%U%C%/$r(BPython$B$G=q$/$N$,(B | |
636 $B$h$$$@$m$&!%$7$+$7=q$3$&$H$9$k$N$,C1=cL@2r$J%U%C%/$G!$!JB?$/$N%U%C%/$,$=(B | |
637 $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 | |
638 $B$bA4$/LdBj$J$$!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
639 |
374 | 640 %\subsection{Hook parameters} |
641 \subsection{$B%U%C%/%Q%i%a!<%?(B} | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
642 \label{sec:hook:param} |
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
643 |
381 | 644 %Mercurial calls each hook with a set of well-defined parameters. In |
645 %Python, a parameter is passed as a keyword argument to your hook | |
646 %function. For an external program, a parameter is passed as an | |
647 %environment variable. | |
648 | |
649 Mercurial$B$O3F!9$N%U%C%/$N8F=P$7$N:]$K$-$A$s$HDj5A$5$l$?%Q%i%a!<%?$rEO(B | |
650 $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 | |
651 $B%W%m%0%i%`$K$O!$%Q%i%a!<%?$O4D6-JQ?t$H$7$FEO$5$l$k!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
652 |
381 | 653 %Whether your hook is written in Python or as a shell script, the |
654 %hook-specific parameter names and values will be the same. A boolean | |
655 %parameter will be represented as a boolean value in Python, but as the | |
656 %number 1 (for ``true'') or 0 (for ``false'') as an environment | |
657 %variable for an external hook. If a hook parameter is named | |
658 %\texttt{foo}, the keyword argument for a Python hook will also be | |
659 %named \texttt{foo}, while the environment variable for an external | |
660 %hook will be named \texttt{HG\_FOO}. | |
661 | |
662 $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 | |
663 $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 | |
664 $B%?$O(BPython$B$G$O%V!<%kCM$H$7$F07$o$l$k$,!$30It%U%C%/$N$?$a$N4D6-JQ?t$G(B | |
665 $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 | |
666 $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 | |
667 $B%/$X$N%-!<%o!<%I0z?t$bF1$8(B\texttt{foo}$B$H$$$&L>A0$K$J$k!%(B | |
668 $B0lJ}!$30It%U%C%/$N$?$a$N4D6-JQ?t$G$O(B\texttt{HG\_FOO}$B$H$$$&L>A0$K$J$k!%(B | |
37 | 669 |
374 | 670 %\subsection{Hook return values and activity control} |
671 \subsection{$B%U%C%/$NLa$jCM$HF0:n$N@)8f(B} | |
37 | 672 |
381 | 673 %A hook that executes successfully must exit with a status of zero if |
674 %external, or return boolean ``false'' if in-process. Failure is | |
675 %indicated with a non-zero exit status from an external hook, or an | |
676 %in-process hook returning boolean ``true''. If an in-process hook | |
677 %raises an exception, the hook is considered to have failed. | |
37 | 678 |
779 | 679 $B@5$7$/F0:n$7$?30It%U%C%/$O%9%F!<%?%9$H$7$F%<%m$r!$%W%m%;%9Fb%U%C%/$N>l9g(B |
680 $B$O%V!<%kCM(B``false''$B$rJV$5$J$1$l$P$J$i$J$$!%$J$s$i$+$N<:GT$,$"$C$?>l9g$O!$(B | |
681 $B30It%U%C%/$OHs%<%m$N=*N;%9%F!<%?%9$r!$%W%m%;%9Fb%U%C%/$O%V!<%kCM(B``true'' | |
682 $B$rJV$9!%$b$7%W%m%;%9Fb%U%C%/$,Nc30$rH/@8$7$?>l9g$O!$%U%C%/$O<:GT$7$?$H8+(B | |
683 $B$J$5$l$k!%(B | |
684 | |
381 | 685 %For a hook that controls whether an activity can proceed, zero/false |
686 %means ``allow'', while non-zero/true/exception means ``deny''. | |
37 | 687 |
779 | 688 $BF0:n$N7QB3$r@)8f$9$k%U%C%/$N>l9g$O!$%<%m!?(Bfalse$B$O7QB3$N5v2D$r!$Hs%<(B |
689 $B%m!?(Btrue$B!?Nc30$N>l9g$O6X;_$r0UL#$9$k!%(B | |
690 | |
374 | 691 %\subsection{Writing an external hook} |
692 \subsection{$B30It%U%C%/$r:n@.$9$k(B} | |
37 | 693 |
381 | 694 %When you define an external hook in your \hgrc\ and the hook is run, |
695 %its value is passed to your shell, which interprets it. This means | |
696 %that you can use normal shell constructs in the body of the hook. | |
697 | |
698 $B30It%U%C%/$r(B \hgrc\ $B$GDj5A$7!$<B9T$9$k>l9g!$%U%C%/$O%7%'%k$KEO$5$l$kCM$r(B | |
699 $BJQ49$9$?$a!$%U%C%/$NK\BNItJ,$G%7%'%k%9%/%j%W%H$r5-=R$9$k$3$H$,$G$-$k!%(B | |
37 | 700 |
381 | 701 %An executable hook is always run with its current directory set to a |
702 %repository's root directory. | |
703 | |
704 $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 | |
705 $B$F<B9T$5$l$k!%(B | |
706 | |
707 %Each hook parameter is passed in as an environment variable; the name | |
708 %is upper-cased, and prefixed with the string ``\texttt{HG\_}''. | |
37 | 709 |
381 | 710 $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 |
711 $B;z$K$J$j!$(B``\texttt{HG\_}''$B$H$$$&@\F,<-$,IU$1$i$l$k!%(B | |
37 | 712 |
381 | 713 %With the exception of hook parameters, Mercurial does not set or |
714 %modify any environment variables when running a hook. This is useful | |
715 %to remember if you are writing a site-wide hook that may be run by a | |
716 %number of different users with differing environment variables set. | |
717 %In multi-user situations, you should not rely on environment variables | |
718 %being set to the values you have in your environment when testing the | |
719 %hook. | |
720 | |
721 $B%U%C%/%Q%i%a!<%?$rNc30$H$7$F!$(BMercurial$B$O%U%C%/$r<B9T$9$k:]$K4D6-JQ?t$NDj(B | |
722 $B5A$dJQ99$r9T$o$J$$!%B?$/$N%f!<%6$,<B9T$9$k%5%$%H%o%$%I$N%U%C%/$r:n@.$9$k(B | |
723 $B>l9g!$%f!<%6$,@_Dj$7$F$$$k4D6-JQ?t$O0[$J$k$3$H$r5-21$7$F$*$/$Y$-$G$"$k!%(B | |
724 $B%^%k%A%f!<%64D6-$N>l9g!$%U%C%/$r;n$9:]$K$"$J$?$,@_Dj$7$F$$$k4D6-JQ?t$K0M(B | |
725 $BB8$9$Y$-$G$O$J$$!%(B | |
37 | 726 |
374 | 727 %\subsection{Telling Mercurial to use an in-process hook} |
728 \subsection{Mercurial$B$K%W%m%;%9Fb%U%C%/$r;H$&$h$&$K;X<($9$k(B} | |
37 | 729 |
382 | 730 %The \hgrc\ syntax for defining an in-process hook is slightly |
731 %different than for an executable hook. The value of the hook must | |
732 %start with the text ``\texttt{python:}'', and continue with the | |
733 %fully-qualified name of a callable object to use as the hook's value. | |
734 | |
735 $B%W%m%;%9$J$$%U%C%/$rDj5A$9$k(B \hgrc\ $B9=J8$O<B9T2DG=%U%C%/$H$O6O$+$K0[$J$C(B | |
736 $B$F$$$k!%%U%C%/$NCM$OI,$:(B``\texttt{python:}''$B$G;O$^$j!$8e$K%U%C%/CM$H$7$F(B | |
737 $BMQ$$$i$l$k8F=P$72DG=%*%V%8%'%/%H$N40A4$JL>A0$,B3$+$J$1$l$P$J$i$J$$!%(B | |
738 | |
739 %The module in which a hook lives is automatically imported when a hook | |
740 %is run. So long as you have the module name and \envar{PYTHONPATH} | |
741 %right, it should ``just work''. | |
37 | 742 |
382 | 743 $B%U%C%/$,4^$^$l$k%b%8%e!<%k$O%U%C%/$,<B9T$5$l$k;~$K<+F0E*$KFI$_9~$^$l$k!%(B |
744 $B%b%8%e!<%kL>$*$h$S(B\envar{PYTHONPATH}$B$,@5$7$$$+$.$jI,$:F0:n$9$k$O$:$G$"$k!%(B | |
37 | 745 |
382 | 746 %The following \hgrc\ example snippet illustrates the syntax and |
747 %meaning of the notions we just described. | |
748 %\begin{codesample2} | |
749 % [hooks] | |
750 % commit.example = python:mymodule.submodule.myhook | |
751 %\end{codesample2} | |
752 %When Mercurial runs the \texttt{commit.example} hook, it imports | |
753 %\texttt{mymodule.submodule}, looks for the callable object named | |
754 %\texttt{myhook}, and calls it. | |
755 | |
756 $B:#@bL@$7$?9=J8$H35G0$r@bL@$9$kCGJRE*$JNc$r0J2<$N(B\hgrc\ $B$K<($9!%(B | |
37 | 757 \begin{codesample2} |
758 [hooks] | |
759 commit.example = python:mymodule.submodule.myhook | |
760 \end{codesample2} | |
382 | 761 Mercurial$B$,(B\texttt{commit.example}$B%U%C%/$r<B9T$9$k;~!$(B |
762 \texttt{mymodule.submodule}$B$rFI$_9~$_!$8F=P$72DG=%*%V%8%'%/%H(B | |
763 \texttt{myhook}$B$rC5$7!$<B9T$9$k!%(B | |
37 | 764 |
374 | 765 %\subsection{Writing an in-process hook} |
766 \subsection{$B%W%m%;%9Fb%U%C%/$r:n@.$9$k(B} | |
37 | 767 |
382 | 768 %The simplest in-process hook does nothing, but illustrates the basic |
769 %shape of the hook API: | |
770 %\begin{codesample2} | |
771 % def myhook(ui, repo, **kwargs): | |
772 % pass | |
773 %\end{codesample2} | |
774 %The first argument to a Python hook is always a | |
775 %\pymodclass{mercurial.ui}{ui} object. The second is a repository object; | |
776 %at the moment, it is always an instance of | |
777 %\pymodclass{mercurial.localrepo}{localrepository}. Following these two | |
778 %arguments are other keyword arguments. Which ones are passed in | |
779 %depends on the hook being called, but a hook can ignore arguments it | |
780 %doesn't care about by dropping them into a keyword argument dict, as | |
781 %with \texttt{**kwargs} above. | |
782 | |
783 $B<B:]$K$O2?$b9T$o$J$$:G$bC1=c$J%W%m%;%9Fb%U%C%/$r%U%C%/(BAPI$B$N4pK\E*$J;H$$J}(B | |
784 $B$r@bL@$9$k$?$a$K<($9!%(B | |
37 | 785 \begin{codesample2} |
786 def myhook(ui, repo, **kwargs): | |
787 pass | |
788 \end{codesample2} | |
382 | 789 Python$B%U%C%/$X$N:G=i$N0z?t$O>o$K(B\pymodclass{mercurial.ui}{ui}$B%*%V%8%'%/%H(B |
790 $B$G$"$k!%(B2$BHVL\$N0z?t$O%j%]%8%H%j%*%V%8%'%/%H$G!$8=:_$N$H$3$m>o$K(B | |
791 \pymodclass{mercurial.localrepo}{localrepository}$B$N%$%s%9%?%s%9$G$"$k!%B>(B | |
792 $B$N%-!<%o!<%I0z?t$O$3$l$i$N(B2$B$D$N0z?t$KB3$/!%$3$l$i$O8F$S=P$5$l$F$$$k%U%C%/(B | |
793 $B$K0MB8$9$k$,!$%U%C%/$O%-!<%o!<%I$N<-=q$K(B\texttt{**kwargs}$B$H5-=R$9$k$3$H(B | |
794 $B$G!$I,MW$N$J$$0z?t$rL5;k$9$k$3$H$b$G$-$k!%(B | |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
795 |
374 | 796 %\section{Some hook examples} |
797 \section{$B%U%C%/$NNc(B} | |
44
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
798 |
374 | 799 %\subsection{Writing meaningful commit messages} |
800 \subsection{$B0UL#$N$"$k%3%_%C%H%a%C%;!<%8$r=PNO$9$k(B} | |
49 | 801 |
382 | 802 %It's hard to imagine a useful commit message being very short. The |
803 %simple \hook{pretxncommit} hook of figure~\ref{ex:hook:msglen.go} | |
804 %will prevent you from committing a changeset with a message that is | |
805 %less than ten bytes long. | |
806 | |
807 $BHs>o$KC;$$%3%_%C%H%a%C%;!<%8$,M-MQ$G$"$k$3$H$O$^$:$J$$!%(B | |
808 $B?^(B~\ref{ex:hook:msglen.go}$B$K<($9(B\hook{pretxncommit}$B$H$$$&C1=c$J%U%C%/$O(B10 | |
809 $B%P%$%H0J2<$ND9$5$N%3%_%C%H%a%C%;!<%8$G%3%_%C%H$r9T$&$3$H$r6X;_$9$k!%(B | |
49 | 810 |
811 \begin{figure}[ht] | |
155
914babdc99c8
run-example: better error if bogus section name found.
Bryan O'Sullivan <bos@serpentine.com>
parents:
135
diff
changeset
|
812 \interaction{hook.msglen.go} |
382 | 813 % \caption{A hook that forbids overly short commit messages} |
814 \caption{$B6KC<$KC;$$%3%_%C%H%a%C%;!<%8$r6X;_$9$k%U%C%/(B} | |
155
914babdc99c8
run-example: better error if bogus section name found.
Bryan O'Sullivan <bos@serpentine.com>
parents:
135
diff
changeset
|
815 \label{ex:hook:msglen.go} |
49 | 816 \end{figure} |
817 | |
374 | 818 %\subsection{Checking for trailing whitespace} |
819 \subsection{$B$V$i2<$,$C$?6uGr$r%A%'%C%/$9$k(B} | |
44
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
820 |
382 | 821 %An interesting use of a commit-related hook is to help you to write |
822 %cleaner code. A simple example of ``cleaner code'' is the dictum that | |
823 %a change should not add any new lines of text that contain ``trailing | |
824 %whitespace''. Trailing whitespace is a series of space and tab | |
825 %characters at the end of a line of text. In most cases, trailing | |
826 %whitespace is unnecessary, invisible noise, but it is occasionally | |
827 %problematic, and people often prefer to get rid of it. | |
828 | |
829 $B%3%_%C%H$K4XO"$7$?%U%C%/$N6=L#?<$$;HMQK!$N0l$D$K$h$j4qNo$J%3!<%I$r=q$/<j(B | |
830 $B=u$1$,$"$k!%(B ``$B4qNo$J%3!<%I(B''$B$N$4$/C1=c$JNc$O!$Nc$($P!$?7$?$J$V$i2<$,$C$?(B | |
831 $B6uGr$r4^$`9T$r4^$^$J$$$b$N$G$"$k!%$V$i2<$,$C$?6uGr$H$O!$9TKv$N0lO"$N%9%Z!<(B | |
832 $B%9$d%?%V$G$"$k!%$[$H$s$I$N>l9g!$$V$i2<$,$C$?6uGr$OITI,MW$J8+$($J$$%N%$%:(B | |
833 $B$G$"$k$,!$LdBj$r0z$-5/$3$9>l9g$b$"$j!$=|5n$7$?$,$k?M$,B?$$!%(B | |
834 | |
835 %You can use either the \hook{precommit} or \hook{pretxncommit} hook to | |
836 %tell whether you have a trailing whitespace problem. If you use the | |
837 %\hook{precommit} hook, the hook will not know which files you are | |
838 %committing, so it will have to check every modified file in the | |
839 %repository for trailing white space. If you want to commit a change | |
840 %to just the file \filename{foo}, but the file \filename{bar} contains | |
841 %trailing whitespace, doing a check in the \hook{precommit} hook will | |
842 %prevent you from committing \filename{foo} due to the problem with | |
843 %\filename{bar}. This doesn't seem right. | |
44
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
844 |
382 | 845 $B$V$i2<$,$j6uGr$NLdBj$rD>$9$?$a$K(B\hook{precommit}$B%U%C%/$d(B |
846 \hook{pretxncommit}$B%U%C%/$rMQ$$$k$3$H$,$G$-$k!%(B\hook{precommit}$B%U%C%/$r;H(B | |
847 $B$&>l9g!$$I$N%U%!%$%k$r%3%_%C%H$9$k$N$+%U%C%/$OCN$k$3$H$,$J$$!%$=$N$?$a!$(B | |
848 $B%j%]%8%H%j$GJQ99$5$l$?%U%!%$%k$9$Y$F$K$D$$$F$V$i2<$,$j6uGr$r%A%'%C%/$9$k(B | |
849 $BI,MW$,$"$k!%(B \filename{foo}$B$H$$$&%U%!%$%k$r%3%_%C%H$7$?$$(B | |
850 $B$,!$(B\filename{bar}$B%U%!%$%k$,$V$i2<$,$j6uGr$r4^$s$G$$$k>l(B | |
851 $B9g!$(B\hook{precommit}$B%U%C%/$G%A%'%C%/$r9T$&$H!$%U%!%$%k(B\filename{bar}$B$NLd(B | |
852 $BBj$N$?$a$K(B\filename{foo}$B$N%3%_%C%H$,$G$-$J$/$J$k!%$3$l$O@5$7$$5sF0$H$O8@(B | |
853 $B$($J$$!%(B | |
44
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
854 |
382 | 855 %Should you choose the \hook{pretxncommit} hook, the check won't occur |
856 %until just before the transaction for the commit completes. This will | |
857 %allow you to check for problems only the exact files that are being | |
858 %committed. However, if you entered the commit message interactively | |
859 %and the hook fails, the transaction will roll back; you'll have to | |
860 %re-enter the commit message after you fix the trailing whitespace and | |
861 %run \hgcmd{commit} again. | |
862 | |
863 \hook{pretxncommit}$B%U%C%/$rA*$S!$%A%'%C%/$,%3%_%C%H40N;%H%i%s%6%/%7%g%s$N(B | |
864 $BD>A0$^$G5/$-$J$$$h$&$K$9$Y$-$G$"$k!%$3$l$K$h$j!$%3%_%C%H$5$l$h$&$H$9$k%U%!(B | |
865 $B%$%k$@$1$r%A%'%C%/$9$k$3$H$,$G$-$k$h$&$K$J$k!%$7$+$7$J$,$i!$%3%_%C%H%a%C(B | |
866 $B%;!<%8$rBPOCE*$KF~NO$7!$%3%_%C%H$,<:GT$9$k$H%H%i%s%6%/%7%g%s$O%m!<%k%P%C(B | |
867 $B%/$9$k$?$a!$$V$i2<$,$j6uGr$r=$@5$7!$(B\hgcmd{commit}$B$r:F$S<B9T$7!$%3%_%C%H(B | |
868 $B$9$k:]$K%3%_%C%H%a%C%;!<%8$r:FF~NO$7$J$1$l$P$J$i$J$$!%(B | |
44
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
869 |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
870 \begin{figure}[ht] |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
871 \interaction{hook.ws.simple} |
382 | 872 % \caption{A simple hook that checks for trailing whitespace} |
873 \caption{$B$V$i2<$,$C$?6uGr$r%A%'%C%/$9$kC1=c$J%U%C%/(B} | |
44
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
874 \label{ex:hook:ws.simple} |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
875 \end{figure} |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
876 |
382 | 877 %Figure~\ref{ex:hook:ws.simple} introduces a simple \hook{pretxncommit} |
878 %hook that checks for trailing whitespace. This hook is short, but not | |
879 %very helpful. It exits with an error status if a change adds a line | |
880 %with trailing whitespace to any file, but does not print any | |
881 %information that might help us to identify the offending file or | |
882 %line. It also has the nice property of not paying attention to | |
883 %unmodified lines; only lines that introduce new trailing whitespace | |
884 %cause problems. | |
885 | |
886 $B?^(B~\ref{ex:hook:ws.simple}$B$O(B\hook{pretxncommit}$B$H$$$&$V$i2<$,$j6uGr$r%A%'%C(B | |
887 $B%/$9$kC1=c$J%U%C%/$rF3F~$7$F$$$k!%$3$N%U%C%/$OC;$$$,!$$=$l$[$IM-MQ$G$O$J(B | |
888 $B$$!%99?7$,$V$i2<$,$j6uGr$r4^$`9T$r$I$N%U%!%$%k$KDI2C$7$F$b!$$3$N%U%C%/$O(B | |
889 $B%(%i!<%9%F!<%?%9$H6&$K=*N;$9$k$,!$LdBj$N$"$k%U%!%$%k$d9T$rFCDj$9$k$?$a$N(B | |
890 $B>pJs$O0l@ZI=<($7$J$$!%$3$N%U%C%/$OJQ99$N$J$$9T$K$OA4$/4X?4$r;}$?$J$$$H$$(B | |
891 $B$&NI$$@-<A$b;}$C$F$$$k!%?75,$K$V$i2<$,$j6uGr$r2C$($kLdBj$N$"$k9T$N$_$r8!(B | |
892 $B::$9$k!%(B | |
49 | 893 |
894 \begin{figure}[ht] | |
895 \interaction{hook.ws.better} | |
382 | 896 % \caption{A better trailing whitespace hook} |
897 \caption{$B$V$i2<$,$j6uGr$r%A%'%C%/$9$k%U%C%/$N2~NIHG(B} | |
49 | 898 \label{ex:hook:ws.better} |
899 \end{figure} | |
900 | |
382 | 901 %The example of figure~\ref{ex:hook:ws.better} is much more complex, |
902 %but also more useful. It parses a unified diff to see if any lines | |
903 %add trailing whitespace, and prints the name of the file and the line | |
904 %number of each such occurrence. Even better, if the change adds | |
905 %trailing whitespace, this hook saves the commit comment and prints the | |
906 %name of the save file before exiting and telling Mercurial to roll the | |
907 %transaction back, so you can use | |
908 %\hgcmdargs{commit}{\hgopt{commit}{-l}~\emph{filename}} to reuse the | |
909 %saved commit message once you've corrected the problem. | |
49 | 910 |
382 | 911 $B?^(B~\ref{ex:hook:ws.better}$B$O$+$J$jJ#;($@$,!$$h$jM-MQ$G$"$k!%$3$N%U%C%/$OE}(B |
912 $B9g7A<0$N(Bdiff$B$r%Q!<%9$7!$$V$i2<$,$j6uGr$r4^$`%i%$%s$rC5$9!%$=$7$F8+$D$1$k(B | |
913 $B$H%U%!%$%kL>$H9THV9f$rI=<($9$k!%$5$i$KJQ99$,$V$i2<$,$j6uGr$rDI2C$9$k$H!$(B | |
914 $B$3$N%U%C%/$O%3%_%C%H%3%a%s%H$rJ]B8$7!$=*N;A0$KJ]B8%U%!%$%k$NL>A0$rI=<($9(B | |
915 $B$k!%$=$7$F(BMercurial$B$K%H%i%s%6%/%7%g%s$r%m!<%k%P%C%/$9$k$3$H$r;X<($9$k!%Ld(B | |
916 $BBj$r=$@5$7$?8e$GJ]B8$5$l$?%3%_%C%H%a%C%;!<%8$r;H$&$K$O(B | |
917 \hgcmdargs{commit}{\hgopt{commit}{-l}~\emph{filename}}$B$H$9$l$P$h$$!%(B | |
918 | |
919 %As a final aside, note in figure~\ref{ex:hook:ws.better} the use of | |
920 %\command{perl}'s in-place editing feature to get rid of trailing | |
921 %whitespace from a file. This is concise and useful enough that I will | |
922 %reproduce it here. | |
923 | |
924 $B:G8e$K!$?^(B~\ref{ex:hook:ws.better}$B$N$h$&$K%U%!%$%k$+$i$V$i2<$,$j6uGr$r=|5n(B | |
925 $B$9$k$?$a$K(B\command{perl}$B%3%^%s%I$N%$%s%W%l%$%9JT=85!G=$rMQ$$$k!%$3$l$O$3(B | |
926 $B$3$G:F8=$9$k$KEv$?$C$F==J,C;$/$+$DM-8z$G$"$k!%(B | |
927 | |
49 | 928 \begin{codesample2} |
54 | 929 perl -pi -e 's,\\s+\$,,' filename |
49 | 930 \end{codesample2} |
931 | |
374 | 932 %\section{Bundled hooks} |
933 \section{$BAH$_9g$o$;%U%C%/(B} | |
49 | 934 |
382 | 935 %Mercurial ships with several bundled hooks. You can find them in the |
936 %\dirname{hgext} directory of a Mercurial source tree. If you are | |
937 %using a Mercurial binary package, the hooks will be located in the | |
938 %\dirname{hgext} directory of wherever your package installer put | |
939 %Mercurial. | |
940 | |
941 Mercurial$B$K$O$$$/$D$+$N%U%C%/$,F1:-$5$l$F$$$k!%%U%C%/$O(BMercurial$B%=!<%9%D(B | |
942 $B%j!<$N(B\dirname{hgext}$B%G%#%l%/%H%j$K$"$k!%(B Mercurial$B$N%P%$%J%j%Q%C%1!<%8$r(B | |
943 $B;HMQ$7$F$$$k$N$G$"$l$P!$%U%C%/$O%Q%C%1!<%8%$%s%9%H!<%i$,(BMercurial$B$r%$%s%9(B | |
944 $B%H!<%k$7$?%G%#%l%/%H%jFb$N(B\dirname{hgext}$B%G%#%l%/%H%j$K$"$k$O$:$@!%(B | |
49 | 945 |
374 | 946 %\subsection{\hgext{acl}---access control for parts of a repository} |
947 \subsection{\hgext{acl}---$B%j%]%8%H%j$NItJ,$KBP$9$k%"%/%;%9%3%s%H%m!<%k(B} | |
49 | 948 |
382 | 949 %The \hgext{acl} extension lets you control which remote users are |
950 %allowed to push changesets to a networked server. You can protect any | |
951 %portion of a repository (including the entire repo), so that a | |
952 %specific remote user can push changes that do not affect the protected | |
953 %portion. | |
954 | |
955 \hgext{acl}$B%(%/%9%F%s%7%g%s$O!$%j%b!<%H%f!<%6$K%A%'%s%8%;%C%H$r%M%C%H%o!<(B | |
956 $B%/@\B3$5$l$?%5!<%P$K%W%C%7%e$G$-$k$h$&$K$9$k!%FCDj$N%j%b!<%H%f!<%6$,J]8n(B | |
957 $B$5$l$?0J30$NItJ,$NJQ99$r%W%C%7%e$G$-$k$h$&$K%j%]%8%H%j$NG$0U$NItJ,!JA4BN(B | |
958 $B$r$b4^$`!K$rJ]8n$9$k$3$H$,$G$-$k!%(B | |
49 | 959 |
382 | 960 %This extension implements access control based on the identity of the |
961 %user performing a push, \emph{not} on who committed the changesets | |
962 %they're pushing. It makes sense to use this hook only if you have a | |
963 %locked-down server environment that authenticates remote users, and | |
964 %you want to be sure that only specific users are allowed to push | |
965 %changes to that server. | |
966 | |
967 $B$3$N%(%/%9%F%s%7%g%s$O%f!<%6$,%W%C%7%e$r9T$&:]$K!$C/$,%A%'%s%8%;%C%H$r%3(B | |
968 $B%_%C%H(B\emph{$B$G$-$J$$(B}$B$h$&$K$9$k$3$H$G%"%/%;%9%3%s%H%m!<%k$r<BAu$7$F$$$k!%(B | |
969 $B$3$N%U%C%/$O!$%j%b!<%H%f!<%6$NG'>Z$r9T$&J]8n$5$l$?%5!<%P4D6-$G!$;XDj$5$l(B | |
970 $B$?%f!<%6$@$1$,JQ99$r%5!<%P$K%W%C%7%e$G$-$k$h$&$K$7$?$$>l9g$K$N$_0UL#$r$J(B | |
971 $B$9!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
972 |
374 | 973 %\subsubsection{Configuring the \hook{acl} hook} |
974 \subsubsection{\hook{acl}$B%U%C%/$N@_Dj(B} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
975 |
383 | 976 %In order to manage incoming changesets, the \hgext{acl} hook must be |
977 %used as a \hook{pretxnchangegroup} hook. This lets it see which files | |
978 %are modified by each incoming changeset, and roll back a group of | |
979 %changesets if they modify ``forbidden'' files. Example: | |
980 %\begin{codesample2} | |
981 % [hooks] | |
982 % pretxnchangegroup.acl = python:hgext.acl.hook | |
983 %\end{codesample2} | |
984 | |
985 \hgext{acl}$B%U%C%/$r!$E~Ce$9$k%A%'%s%8%;%C%H$r4IM}$9$k$?$a$K;H$&$?$a$K$O!$(B | |
986 \hook{pretxnchangegroup}$B%U%C%/$H$7$FMQ$$$kI,MW$,$"$k!%$3$N%U%C%/$O!$3F!9(B | |
987 $B$N%A%'%s%8%;%C%H$G$I$N%U%!%$%k$,JQ99$5$l$?$N$+$r%A%'%C%/$7!$JQ996X;_$N%U%!(B | |
988 $B%$%k$XJQ99$,$"$C$?>l9g$O%A%'%s%8%;%C%H$r%m!<%k%P%C%/$9$k!%Nc!'(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
989 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
990 [hooks] |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
991 pretxnchangegroup.acl = python:hgext.acl.hook |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
992 \end{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
993 |
383 | 994 %The \hgext{acl} extension is configured using three sections. |
995 | |
996 \hgext{acl}$B%(%/%9%F%s%7%g%s$O(B3$B$D$N%;%/%7%g%s$G@_Dj$5$l$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
997 |
383 | 998 %The \rcsection{acl} section has only one entry, \rcitem{acl}{sources}, |
999 %which lists the sources of incoming changesets that the hook should | |
1000 %pay attention to. You don't normally need to configure this section. | |
1001 %\begin{itemize} | |
1002 %\item[\rcitem{acl}{serve}] Control incoming changesets that are arriving | |
1003 % from a remote repository over http or ssh. This is the default | |
1004 % value of \rcitem{acl}{sources}, and usually the only setting you'll | |
1005 % need for this configuration item. | |
1006 %\item[\rcitem{acl}{pull}] Control incoming changesets that are | |
1007 % arriving via a pull from a local repository. | |
1008 %\item[\rcitem{acl}{push}] Control incoming changesets that are | |
1009 % arriving via a push from a local repository. | |
1010 %\item[\rcitem{acl}{bundle}] Control incoming changesets that are | |
1011 % arriving from another repository via a bundle. | |
1012 %\end{itemize} | |
1013 | |
1014 \rcsection{acl}$B%;%/%7%g%s$O!$(B\rcitem{acl}{sources}$B$H$$$&%(%s%H%j(B1$B$D$r;}(B | |
1015 $B$D!%$3$N%(%s%H%j$G%U%C%/$,4F;k$9$Y$-E~Ce%A%'%s%8%;%C%HFb%=!<%9(B | |
1016 $B$rNs5s$9$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1017 \begin{itemize} |
383 | 1018 \item[\rcitem{acl}{serve}] $B%j%b!<%H%j%]%8%H%j$+$i(Bhttp$B$^$?$O(Bssh$B$r;H$C$FE~(B |
1019 $BCe$9$k%A%'%s%8%;%C%H$r@)8f$9$k!%(B\rcitem{acl}{sources}$B$N%G%U%)(B | |
1020 $B%k%HCM$G!$DL>o$O$3$N@_DjFb$GM#0l@_Dj$9$kI,MW$N$"$k9`L\$G$"(B | |
1021 $B$k!%(B | |
1022 \item[\rcitem{acl}{pull}] $B%m!<%+%k%j%]%8%H%j$+$i(Bpull$B$7$?%A%'%s%8%;%C%H$r(B | |
1023 $B@)8f$9$k!%(B | |
1024 \item[\rcitem{acl}{push}] $B%m!<%+%k%j%]%8%H%j$+$i(Bpush$B$7$?%A%'%s%8%;%C%H$r(B | |
1025 $B@)8f$9$k!%(B | |
1026 \item[\rcitem{acl}{bundle}] $BJL$N%j%]%8%H%j$+$i%P%s%I%k$K$h$C$FE~Ce$7$?%A%'(B | |
1027 $B%s%8%;%C%H$r@)8f$9$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1028 \end{itemize} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1029 |
383 | 1030 %The \rcsection{acl.allow} section controls the users that are allowed to |
1031 %add changesets to the repository. If this section is not present, all | |
1032 %users that are not explicitly denied are allowed. If this section is | |
1033 %present, all users that are not explicitly allowed are denied (so an | |
1034 %empty section means that all users are denied). | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1035 |
383 | 1036 \rcsection{acl.allow}$B%;%/%7%g%s$O%A%'%s%8%;%C%H$N%j%]%8%H%j$X$NDI2C$r5v(B |
1037 $B2D$5$l$F$$$k%f!<%6$r@_Dj$9$k!%$3$N%;%/%7%g%s$,B8:_$7$J$$>l9g!$L@<(E*$K5q(B | |
1038 $BH]$5$l$F$$$J$$$9$Y$F$N%f!<%6$O5v2D$5$l$k!%$3$N%;%/%7%g%s$,B8:_$9$k>l9g!$(B | |
1039 $BL@<(E*$K5v2D$5$l$F$$$J$$$9$Y$F$N%f!<%6$O5qH]$5$l$k!%!J$9$J$o$A!$6u$N%;%/(B | |
1040 $B%7%g%s$O$9$Y$F$N%f!<%6$N5qH]$H$$$&0UL#$K$J$k!%!K(B | |
1041 | |
1042 %The \rcsection{acl.deny} section determines which users are denied | |
1043 %from adding changesets to the repository. If this section is not | |
1044 %present or is empty, no users are denied. | |
1045 | |
1046 \rcsection{acl.deny}$B%;%/%7%g%s$O!$%j%]%8%H%j$X$N%A%'%s%8%;%C%HDI2C$r5qH](B | |
1047 $B$9$k%f!<%6$r@_Dj$9$k!%$3$N%;%/%7%g%s$,B8:_$7$J$$$+!$6u$N>l9g$O$I$N%f!<%6(B | |
1048 $B$b5qH]$5$l$J$$!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1049 |
383 | 1050 %The syntaxes for the \rcsection{acl.allow} and \rcsection{acl.deny} |
1051 %sections are identical. On the left of each entry is a glob pattern | |
1052 %that matches files or directories, relative to the root of the | |
1053 %repository; on the right, a user name. | |
1054 | |
1055 \rcsection{acl.allow}$B$H(B\rcsection{acl.deny}$B%;%/%7%g%s$N9=J8$OF10l$G$"$k!%(B | |
1056 $B3F!9$N%(%s%H%j$N:8JU$O%U%!%$%k$^$?$O%G%#%l%/%H%j$K%^%C%A$9$k(Bglob$B%Q%?!<%s(B | |
1057 $B$G!$%j%]%8%H%j%k!<%H$+$i$NAjBP%Q%9$G$"$k!%1&JU$O%f!<%6L>$G$"$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1058 |
383 | 1059 %In the following example, the user \texttt{docwriter} can only push |
1060 %changes to the \dirname{docs} subtree of the repository, while | |
1061 %\texttt{intern} can push changes to any file or directory except | |
1062 %\dirname{source/sensitive}. | |
1063 %\begin{codesample2} | |
1064 % [acl.allow] | |
1065 % docs/** = docwriter | |
1066 % | |
1067 % [acl.deny] | |
1068 % source/sensitive/** = intern | |
1069 %\end{codesample2} | |
1070 | |
1071 $B0J2<$NNc$G$O!$(B\texttt{docwriter}$B$H$$$&%f!<%6$O!$%j%]%8%H%j$N(B | |
1072 \dirname{docs}$B%5%V%D%j!<$K$7$+(Bpush$B$G$-$J$$!%$^$?(B\texttt{intern}$B$O(B | |
1073 \dirname{source/sensitive}$B0J30$J$i$P$I$N%G%#%l%/%H%j$N$I$N%U%!%$%k$K$bJQ(B | |
1074 $B99$r(Bpush$B$9$k$3$H$,$G$-$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1075 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1076 [acl.allow] |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1077 docs/** = docwriter |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1078 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1079 [acl.deny] |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1080 source/sensitive/** = intern |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1081 \end{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1082 |
374 | 1083 %\subsubsection{Testing and troubleshooting} |
1084 \subsubsection{$B%F%9%H$HLdBj2r7h(B} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1085 |
383 | 1086 %If you want to test the \hgext{acl} hook, run it with Mercurial's |
1087 | |
1088 %debugging output enabled. Since you'll probably be running it on a | |
1089 %server where it's not convenient (or sometimes possible) to pass in | |
1090 %the \hggopt{--debug} option, don't forget that you can enable | |
1091 %debugging output in your \hgrc: | |
1092 %\begin{codesample2} | |
1093 % [ui] | |
1094 % debug = true | |
1095 %\end{codesample2} | |
1096 %With this enabled, the \hgext{acl} hook will print enough information | |
1097 %to let you figure out why it is allowing or forbidding pushes from | |
1098 %specific users. | |
1099 | |
1100 \hgext{acl}$B%U%C%/$r%F%9%H$7$?$$>l9g$O!$(BMercurial$B$N%G%P%C%0=PNO$rM-8z$K$7(B | |
1101 $B$F<B9T$9$k$HNI$$!%%5!<%P>e$G<B9T$9$k$N$G$"$l$P!"(B\hggopt{--debug}$B%*%W%7%g(B | |
1102 $B%s$rEO$9$N$OITJX$G$"$C$?$j!"IT2DG=$G$"$C$?$j$9$k$3$H$,$"$k!#$3$N$?$a!"%G(B | |
1103 $B%P%C%0=PNO$O(B \hgrc $B$G$($bM-8z$K$G$-$k$3$H$r5-21$7$F$*$/$Y$-$G$"$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1104 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1105 [ui] |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1106 debug = true |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1107 \end{codesample2} |
383 | 1108 $B%G%P%C%0=PNO$,M-8z$N>l9g!$(B\hgext{acl}$B%U%C%/$O!$FCDj$N%f!<%6$r5v2D$"$k$$(B |
1109 $B$O5qH]$7$?M}M3$rCN$k$N$K==J,$J>pJs$r=PNO$9$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1110 |
374 | 1111 %\subsection{\hgext{bugzilla}---integration with Bugzilla} |
383 | 1112 \subsection{\hgext{bugzilla}---Bugzilla$B$H$N7k9g(B} |
1113 | |
1114 %The \hgext{bugzilla} extension adds a comment to a Bugzilla bug | |
1115 %whenever it finds a reference to that bug ID in a commit comment. You | |
1116 %can install this hook on a shared server, so that any time a remote | |
1117 %user pushes changes to this server, the hook gets run. | |
1118 | |
1119 \hgext{bugzilla}$B%(%/%9%F%s%7%g%s$O!$(BBugzilla$B$G4IM}$5$l$F$$$k%P%0$X!$%3%_%C(B | |
1120 $B%H%3%a%s%H$NCf$G%P%0(BID$B$r;2>H$7$F$$$k>l9g%3%a%s%H$rDI2C$9$k!%(B | |
1121 $B$3$N%U%C%/$O6&M-%5!<%P$K$b%$%s%9%H!<%k$G$-$k$N$G!$%j%b!<%H%f!<%6$,(B | |
1122 $BJQ99$r(Bpush$B$7$?>l9g$K$bF0:n$9$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1123 |
383 | 1124 %It adds a comment to the bug that looks like this (you can configure |
1125 %the contents of the comment---see below): | |
1126 %\begin{codesample2} | |
1127 % Changeset aad8b264143a, made by Joe User <joe.user@domain.com> in | |
1128 % the frobnitz repository, refers to this bug. | |
1129 % | |
1130 % For complete details, see | |
1131 % http://hg.domain.com/frobnitz?cmd=changeset;node=aad8b264143a | |
1132 % | |
1133 % Changeset description: | |
1134 % Fix bug 10483 by guarding against some NULL pointers | |
1135 %\end{codesample2} | |
1136 %The value of this hook is that it automates the process of updating a | |
1137 %bug any time a changeset refers to it. If you configure the hook | |
1138 %properly, it makes it easy for people to browse straight from a | |
1139 %Bugzilla bug to a changeset that refers to that bug. | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1140 |
383 | 1141 $B$3$N%U%C%/$O<!$N$h$&$K%P%0$X%3%a%s%H$rDI2C$9$k!%!J%3%a%s%H$NFbMF$O@_Dj2D(B |
1142 $BG=$G$"$k!%$3$l$K$D$$$F$O2<5-$r;2>H!%!K(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1143 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1144 Changeset aad8b264143a, made by Joe User <joe.user@domain.com> in |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1145 the frobnitz repository, refers to this bug. |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1146 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1147 For complete details, see |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1148 http://hg.domain.com/frobnitz?cmd=changeset;node=aad8b264143a |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1149 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1150 Changeset description: |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1151 Fix bug 10483 by guarding against some NULL pointers |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1152 \end{codesample2} |
383 | 1153 $B$3$N%U%C%/$O!$%A%'%s%8%;%C%H$,%P%0$r;2>H$7$?>l9g!$%P%0$N99?7$r<+F02=$G$-(B |
1154 $B$k$H$3$m$K2ACM$,$"$k!%$3$N%U%C%/$r$-$A$s$H@_Dj$9$l$P!$(BBugzilla$B%P%0$r1\Mw(B | |
1155 $B$7$F$$$k%f!<%6$,!$%P%0$+$iD>$A$K4X78$9$k%A%'%s%8%;%C%H$r;2>H$G$-$k$h$&$K(B | |
1156 $B$J$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1157 |
383 | 1158 %You can use the code in this hook as a starting point for some more |
1159 %exotic Bugzilla integration recipes. Here are a few possibilities: | |
1160 %\begin{itemize} | |
1161 %\item Require that every changeset pushed to the server have a valid | |
1162 % bug~ID in its commit comment. In this case, you'd want to configure | |
1163 % the hook as a \hook{pretxncommit} hook. This would allow the hook | |
1164 % to reject changes that didn't contain bug IDs. | |
1165 %\item Allow incoming changesets to automatically modify the | |
1166 % \emph{state} of a bug, as well as simply adding a comment. For | |
1167 % example, the hook could recognise the string ``fixed bug 31337'' as | |
1168 % indicating that it should update the state of bug 31337 to | |
1169 % ``requires testing''. | |
1170 %\end{itemize} | |
1171 | |
1172 $B$3$N%U%C%/$N%3!<%I$r=PH/E@$H$7$F!$JL$N(BBugzilla$B$H$N7k9g$r9T$&$3$H$b2DG=(B | |
1173 $B$G$"$k!%$$$/$D$+$NNc$r5s$2$k!'(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1174 \begin{itemize} |
383 | 1175 \item $B%5!<%P$K%W%C%7%e$5$l$?%A%'%s%8%;%C%H$9$Y$F$K%3%_%C%H%3%a%s%H$KM-8z(B |
1176 $B$J%P%0(BID$B$,$"$k$3$H$rMW5a$9$k!%$3$N>l9g!$%U%C%/$r(B | |
1177 \hook{pretxncommit}$B%U%C%/$H$7$F@_Dj$9$kI,MW$,$"$k!%$3$l$K$h$C$F!$(B | |
1178 $B%P%0(BID$B$r4^$^$J$$JQ99$r5qH]$9$k$3$H$,$G$-$k!%(B | |
1179 \item $BE~Ce$9$k%A%'%s%8%;%C%H$K!$%3%a%s%HDI2C$K2C$($F!$%P%0$N(B\emph{$B%9%F!<(B | |
1180 $B%H(B}$B$r<+F0E*$KJQ99$9$k$h$&$K$G$-$k!%Nc$($P!$%U%C%/$,(B``fixed bug | |
1181 31337''$B$N$h$&$JJ8;zNs$rG'<1$7$F!$(Bbug 31337$B$N%9%F!<%H$r(B``requires | |
1182 testing''$B$KJQ99$9$k$J$I$,9M$($i$l$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1183 \end{itemize} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1184 |
374 | 1185 %\subsubsection{Configuring the \hook{bugzilla} hook} |
1186 \subsubsection{\hook{bugzilla}$B%U%C%/$N@_Dj(B} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1187 \label{sec:hook:bugzilla:config} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1188 |
383 | 1189 %You should configure this hook in your server's \hgrc\ as an |
1190 %\hook{incoming} hook, for example as follows: | |
1191 %\begin{codesample2} | |
1192 % [hooks] | |
1193 % incoming.bugzilla = python:hgext.bugzilla.hook | |
1194 %\end{codesample2} | |
1195 | |
1196 $B$3$N%U%C%/$O<!$NNc$N$h$&$K%5!<%P>e$N(B\hgrc\ $B$G(B\hook{incoming}$B%U%C%/$H@_Dj(B | |
1197 $B$9$Y$-$G$"$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1198 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1199 [hooks] |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1200 incoming.bugzilla = python:hgext.bugzilla.hook |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1201 \end{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1202 |
383 | 1203 %Because of the specialised nature of this hook, and because Bugzilla |
1204 %was not written with this kind of integration in mind, configuring | |
1205 %this hook is a somewhat involved process. | |
1206 | |
1207 $B$3$N%U%C%/$NFCJL$J@-<A!$(BBugzilla$B$,$3$N$h$&$J7k9g$rG0F,$K=q$+$l$F$$$J$$$3(B | |
1208 $B$H$K$h$C$F!$$3$N%U%C%/$N@_Dj$OJ#;($J%W%m%;%9$H$J$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1209 |
383 | 1210 %Before you begin, you must install the MySQL bindings for Python on |
1211 %the host(s) where you'll be running the hook. If this is not | |
1212 %available as a binary package for your system, you can download it | |
1213 %from~\cite{web:mysql-python}. | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1214 |
383 | 1215 $B@_Dj$r3+;O$9$kA0$K!$%U%C%/$r<B9T$9$k%[%9%H>e$G(BPython$BMQ$N(BMySQL$B%P%$%s%G%#%s(B |
1216 $B%0$r%$%s%9%H!<%k$9$kI,MW$,$"$k!%<B9T4D6-MQ$K%P%$%J%j%Q%C%1!<%8$,MQ0U$5$l(B | |
1217 $B$F$$$J$1$l$P!$%=!<%9%U%!%$%k$r(B\cite{web:mysql-python}$B$+$i%@%&%s%m!<%I$9$k(B | |
1218 $B$3$H$,$G$-$k!%(B | |
1219 | |
1220 %Configuration information for this hook lives in the | |
1221 %\rcsection{bugzilla} section of your \hgrc. | |
1222 $B$3$N%U%C%/$N@_Dj>pJs$O!$(B\hgrc $B%U%!%$%k$N(B\rcsection{bugzilla}$B%;%/%7%g%s$K(B | |
1223 $B$"$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1224 \begin{itemize} |
383 | 1225 %\item[\rcitem{bugzilla}{version}] The version of Bugzilla installed on |
1226 % the server. The database schema that Bugzilla uses changes | |
1227 % occasionally, so this hook has to know exactly which schema to use. | |
1228 % At the moment, the only version supported is \texttt{2.16}. | |
1229 \item[\rcitem{bugzilla}{version}] $B%5!<%P$X%$%s%9%H!<%k$5$l$?(BBugzilla$B$N%P!<(B | |
1230 $B%8%g%s!%(BBugzilla$B$N;HMQ$9$k%G!<%?%Y!<%9$N%9%-!<%^$O;~$KJQ99(B | |
1231 $B$5$l$k$?$a!$%U%C%/$O$I$N%9%-!<%^$,;HMQ$5$l$k$N$+$rCN$kI,MW(B | |
1232 $B$,$"$k!%8=;~E@$G$O(BBugzilla\texttt{2.16}$B$@$1$,%5%]!<%H$5$l(B | |
1233 $B$F$$$k!%(B | |
1234 | |
1235 %\item[\rcitem{bugzilla}{host}] The hostname of the MySQL server that | |
1236 % stores your Bugzilla data. The database must be configured to allow | |
1237 % connections from whatever host you are running the \hook{bugzilla} | |
1238 % hook on. | |
1239 \item[\rcitem{bugzilla}{host}] Bugzilla$B%G!<%?$r3JG<$7$F$$$k(BMySQL$B%5!<%P$N(B | |
1240 $B%[%9%H%M!<%`!%%G!<%?%Y!<%9$O(B\hook{bugzilla}$B%U%C%/$r<B9T$9(B | |
1241 $B$k%[%9%H$+$i@\B32DG=$K@_Dj$5$l$F$$$J$1$l$P$J$i$J$$!%(B | |
1242 | |
1243 %\item[\rcitem{bugzilla}{user}] The username with which to connect to | |
1244 % the MySQL server. The database must be configured to allow this | |
1245 % user to connect from whatever host you are running the | |
1246 % \hook{bugzilla} hook on. This user must be able to access and | |
1247 % modify Bugzilla tables. The default value of this item is | |
1248 % \texttt{bugs}, which is the standard name of the Bugzilla user in a | |
1249 % MySQL database. | |
1250 \item[\rcitem{bugzilla}{user}] MySQL$B%5!<%P$K@\B3$9$k%f!<%6L>!%%G!<%?%Y!<(B | |
1251 $B%9$O(B\hook{bugzilla}$B%U%C%/$r<B9T$9$k%[%9%H>e$+$i$3$N%f!<%6$N(B | |
1252 $B@\B3$r5v2D$9$k$h$&$K@_Dj$5$l$F$$$J$1$l$P$J$i$J$$!%$3$N%f!<(B | |
1253 $B%6$O(BBugzilla$B%F!<%V%k$K%"%/%;%9$7!$JQ99$G$-$k8"8B$,$J$1$l$P(B | |
1254 $B$J$i$J$$!%$3$N9`L\$N%G%U%)%k%HCM$O(BMySQL$B%G!<%?%Y!<%9$G$N(B | |
1255 Bugzilla$B%f!<%6$NI8=`L>(B\texttt{bugs}$B$G$"$k!%(B | |
1256 | |
1257 %\item[\rcitem{bugzilla}{password}] The MySQL password for the user you | |
1258 % configured above. This is stored as plain text, so you should make | |
1259 % sure that unauthorised users cannot read the \hgrc\ file where you | |
1260 % store this information. | |
1261 \item[\rcitem{bugzilla}{password}] $B>e5-$N%f!<%6$N(BMySQL$B%Q%9%o!<%I!%J?J8$G(B | |
1262 $BJ]B8$5$l$k$?$a!$8"8B$N$J$$%f!<%6$,$3$N(B\hgrc\ $B%U%!%$%k$r3N<B(B | |
1263 $B$KFI$a$J$$$h$&$K$7$F$*$/I,MW$,$"$k!%(B | |
1264 | |
1265 %\item[\rcitem{bugzilla}{db}] The name of the Bugzilla database on the | |
1266 % MySQL server. The default value of this item is \texttt{bugs}, | |
1267 % which is the standard name of the MySQL database where Bugzilla | |
1268 % stores its data. | |
1269 \item[\rcitem{bugzilla}{db}] MySQL$B%5!<%P>e$N(BBugzilla$B%G!<%?%Y!<%9$NL>A0!%(B | |
1270 $B$3$N9`L\$N%G%U%)%k%HCM$O(B\texttt{bugs}$B$3$N9`L\$N%G%U%)%k%HCM(B | |
1271 $B$O(BBugzilla$B$,%G!<%?$rJ]B8$9$k(BMySQL$B%G!<%?%Y!<%9$NI8=`L>(B | |
1272 \texttt{bugs}$B$G$"$k!%(B | |
1273 | |
1274 %\item[\rcitem{bugzilla}{notify}] If you want Bugzilla to send out a | |
1275 % notification email to subscribers after this hook has added a | |
1276 % comment to a bug, you will need this hook to run a command whenever | |
1277 % it updates the database. The command to run depends on where you | |
1278 | |
1279 % have installed Bugzilla, but it will typically look something like | |
1280 % this, if you have Bugzilla installed in | |
1281 % \dirname{/var/www/html/bugzilla}: | |
1282 % \begin{codesample4} | |
1283 % cd /var/www/html/bugzilla && ./processmail %s nobody@nowhere.com | |
1284 % \end{codesample4} | |
1285 % The Bugzilla \texttt{processmail} program expects to be given a | |
1286 % bug~ID (the hook replaces ``\texttt{\%s}'' with the bug~ID) and an | |
1287 % email address. It also expects to be able to write to some files in | |
1288 % the directory that it runs in. If Bugzilla and this hook are not | |
1289 % installed on the same machine, you will need to find a way to run | |
1290 % \texttt{processmail} on the server where Bugzilla is installed. | |
1291 \item[\rcitem{bugzilla}{notify}] $B%U%C%/$+$i%P%0$K%3%a%s%H$,DI2C$5$l$?;~!$(B | |
1292 Bugzilla$B$+$i9VFI<T$KDLCN%a!<%k(B | |
1293 $B$,Aw$i$l$k$h$&$K$7$?$$>l9g$O!$%U%C%/$,%G!<%?%Y!<%9$r99?7$7(B | |
1294 $B$?>l9g$O>o$K%3%^%s%I$,<B9T$5$l$k$h$&$K@_Dj$7$J$1$l$P$J$i$J(B | |
1295 $B$$!%<B9T$9$k%3%^%s%I$O!$(BBugzilla$B$r$I$3$K%$%s%9%H!<%k$7$?$+$K(B | |
1296 $B0MB8$9$k!%(BBugzilla$B$r(B\dirname{/var/www/html/bugzilla}$B$K%$%s(B | |
1297 $B%9%H!<%k$7$?>l9g!$E57?E*$J%3%^%s%I$O<!$N$h$&$K$J$k!'(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1298 \begin{codesample4} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1299 cd /var/www/html/bugzilla && ./processmail %s nobody@nowhere.com |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1300 \end{codesample4} |
383 | 1301 Bugzilla \texttt{processmail}$B%W%m%0%i%`$O(Bbug~ID ($B%U%C%/$,(B |
1302 ``\texttt{\%s}''$B$r(Bbug~ID$B$KCV49$9$k!%(B)$B$H(Bemail$B%"%I%l%9$r<h$k!%$3$N%W%m%0%i(B | |
1303 $B%`$O$^$?<B9T$5$l$k%G%#%l%/%H%jFb$G$$$/$D$+$N%U%!%$%k$X=q$-9~$_$rI,MW$H$9(B | |
1304 $B$k!%(BBugzilla$B$H%U%C%/$,F1$8%^%7%s>e$K%$%s%9%H!<%k$5$l$F$$$J$$>l9g!$(B | |
1305 Bugzilla$B$,%$%s%9%H!<%k$5$l$?%5!<%P>e$G(B\texttt{processmail}$B$r<B9T$9$kJ}K!(B | |
1306 $B$r8+$D$1$kI,MW$,$"$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1307 \end{itemize} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1308 |
374 | 1309 %\subsubsection{Mapping committer names to Bugzilla user names} |
1310 \subsubsection{$B%3%_%C%H<T$NL>A0$r(BBugzilla$B$N%f!<%6L>$X%^%C%W$9$k(B} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1311 |
383 | 1312 %By default, the \hgext{bugzilla} hook tries to use the email address |
1313 %of a changeset's committer as the Bugzilla user name with which to | |
1314 %update a bug. If this does not suit your needs, you can map committer | |
1315 %email addresses to Bugzilla user names using a \rcsection{usermap} | |
1316 %section. | |
1317 | |
1318 $B%G%U%)%k%H$G$O(B\hgext{bugzilla}$B%U%C%/$O%P%0$r99?7$9$k(BBugzilla$B%f!<%6L>$H$7(B | |
1319 $B$F%A%'%s%8%;%C%H$N%3%_%C%?$N(Bemail$B%"%I%l%9$r;H$*$&$H$9$k!%(B | |
1320 $B$3$N5sF0$,K>$^$7$/$J$$>l9g$O!$(B\rcsection{usermap}$B%;%/%7%g%s$r$;$C$F$$$9$k(B | |
1321 $B$3$H$G%3%_%C%?$N(Bemail$B%"%I%l%9$r(BBugzilla$B$N%f!<%6L>$K%^%C%W$9$k$3$H$,$G$-$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1322 |
383 | 1323 %Each item in the \rcsection{usermap} section contains an email address |
1324 %on the left, and a Bugzilla user name on the right. | |
1325 %\begin{codesample2} | |
1326 % [usermap] | |
1327 % jane.user@example.com = jane | |
1328 %\end{codesample2} | |
1329 %You can either keep the \rcsection{usermap} data in a normal \hgrc, or | |
1330 %tell the \hgext{bugzilla} hook to read the information from an | |
1331 %external \filename{usermap} file. In the latter case, you can store | |
1332 %\filename{usermap} data by itself in (for example) a user-modifiable | |
1333 %repository. This makes it possible to let your users maintain their | |
1334 %own \rcitem{bugzilla}{usermap} entries. The main \hgrc\ file might | |
1335 %look like this: | |
1336 %\begin{codesample2} | |
1337 % # regular hgrc file refers to external usermap file | |
1338 % [bugzilla] | |
1339 % usermap = /home/hg/repos/userdata/bugzilla-usermap.conf | |
1340 %\end{codesample2} | |
1341 %While the \filename{usermap} file that it refers to might look like | |
1342 %this: | |
1343 %\begin{codesample2} | |
1344 % # bugzilla-usermap.conf - inside a hg repository | |
1345 % [usermap] | |
1346 % stephanie@example.com = steph | |
1347 %\end{codesample2} | |
1348 | |
1349 \rcsection{usermap}$B%;%/%7%g%s$N3F!9$N9`L\$O!$:8JU$K(Bemail$B%"%I%l%9!$1&JU$K(B | |
1350 Bugzilla$B%f!<%6L>$r;}$D!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1351 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1352 [usermap] |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1353 jane.user@example.com = jane |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1354 \end{codesample2} |
384 | 1355 \rcsection{usermap}$B%G!<%?$rDL>o$N(B \hgrc $B%U%!%$%k$KJ]B8$9$k$3$H$b(B |
383 | 1356 \hgext{bugzilla}$B%U%C%/$K30It$N(B\filename{usermap}$B%U%!%$%k$rFI$`$h$&$K;X<((B |
1357 $B$9$k$3$H$b$G$-$k!%8e<T$N>l9g!$Nc$($P(B\filename{usermap}$B%G!<%?$r%f!<%6$,JQ(B | |
1358 $B992DG=$J%j%]%8%H%j$KCV$/$3$H$b2DG=$G$"$k!%$3$l$O%f!<%6$K(B | |
1359 \rcitem{bugzilla}{usermap}$B%(%s%H%j$N4IM}$rG$$;$k$3$H$K$J$k!%%a%$%s$N(B | |
1360 \hgrc\ $B%U%!%$%k$O<!$N$h$&$K$J$k!%!'(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1361 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1362 # regular hgrc file refers to external usermap file |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1363 [bugzilla] |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1364 usermap = /home/hg/repos/userdata/bugzilla-usermap.conf |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1365 \end{codesample2} |
49 | 1366 |
374 | 1367 %\subsubsection{Configuring the text that gets added to a bug} |
1368 \subsubsection{$B%P%0$KDI2C$5$l$?J8;zNs$r@_Dj$9$k(B} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1369 |
779 | 1370 %You can configure the text that this hook adds as a comment; you |
1371 %specify it in the form of a Mercurial template. Several \hgrc\ | |
1372 %entries (still in the \rcsection{bugzilla} section) control this | |
1373 %behaviour. | |
1374 $B%U%C%/$,DI2C$9$k%3%a%s%HJ8;zNs$O(BMercurial$B%F%s%W%l!<%H$H$7$F;XDj$9$k$3$H$,(B | |
1375 $B$G$-$k!%(B\hgrc $B$N%(%s%H%j(B(\rcsection{bugzilla}$B%;%/%7%g%s$K4^$^$l$F$$$k$b$N(B | |
1376 $B$r4^$`(B)$B$G5sF0$r%3%s%H%m!<%k$G$-$k!%(B | |
1377 %\begin{itemize} | |
1378 %\item[\texttt{strip}] The number of leading path elements to strip | |
1379 % from a repository's path name to construct a partial path for a URL. | |
1380 % For example, if the repositories on your server live under | |
1381 % \dirname{/home/hg/repos}, and you have a repository whose path is | |
1382 % \dirname{/home/hg/repos/app/tests}, then setting \texttt{strip} to | |
1383 % \texttt{4} will give a partial path of \dirname{app/tests}. The | |
1384 % hook will make this partial path available when expanding a | |
1385 % template, as \texttt{webroot}. | |
1386 %\item[\texttt{template}] The text of the template to use. In addition | |
1387 % to the usual changeset-related variables, this template can use | |
1388 % \texttt{hgweb} (the value of the \texttt{hgweb} configuration item | |
1389 % above) and \texttt{webroot} (the path constructed using | |
1390 % \texttt{strip} above). | |
1391 %\end{itemize} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1392 \begin{itemize} |
779 | 1393 \item[\texttt{strip}] URL$B@8@.MQ$NItJ,%Q%9L>$r:n$k$?$a$K%j%]%8%H%j$N%Q%9L>(B |
1394 $B$+$i<h$j=|$+$l$k@h9TMWAG$N?t!%%5!<%P>e$N(B | |
1395 \dirname{/home/hg/repos}$B$K%j%]%8%H%j72$,$"(B | |
1396 $B$j!$(B\dirname{/home/hg/repos/app/tests}$B$H$$$&%j%]%8%H%j$r;}$C(B | |
1397 $B$F$$$k>l9g!$(B\texttt{strip}$B$r(B\texttt{4}$B$K$9$k$HItJ,%Q%9L>(B | |
1398 \dirname{app/tests}$B$,F@$i$l$k!%%U%C%/$O$3$NItJ,%Q%9$r%F%s%W(B | |
1399 $B%l!<%H$N(B\texttt{webroot}$B$KE,MQ$9$k!%(B | |
1400 | |
1401 \item[\texttt{template}] $B%F%s%W%l!<%H$K;HMQ$5$l$k%F%-%9%H!%DL>o$N%A%'%s%8(B | |
1402 $B%;%C%H4XO"$NJQ?t$K2C$($F!$(B\texttt{hgweb}$B!J>e5-$N(B | |
1403 \texttt{hgweb}$B$N@_DjCM!K$H(B\texttt{webroot}$B!J>e5-$N(B | |
1404 \texttt{strip}$B$r;H$C$F:n$C$?%Q%9!K$,MxMQ$G$-$k(B. | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1405 \end{itemize} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1406 |
779 | 1407 %In addition, you can add a \rcitem{web}{baseurl} item to the |
1408 %\rcsection{web} section of your \hgrc. The \hgext{bugzilla} hook will | |
1409 %make this available when expanding a template, as the base string to | |
1410 %use when constructing a URL that will let users browse from a Bugzilla | |
1411 %comment to view a changeset. Example: | |
1412 $B$5$i$K!$(B\rcitem{web}{baseurl}$B9`L\$r(B\hgrc $B$N(B\rcsection{web}$B%;%/%7%g%s$KDI(B | |
1413 $B2C$G$-$k!%$3$l$O%F%s%W%l!<%H$N3HD%;~$K(B\hgext{bugzilla}$B%U%C%/$K$h$j(B | |
1414 Bugzilla$B%3%a%s%H$+$i%A%'%s%8%;%C%H$r;2>H$9$k:]$N(BURL$B@8@.$N%Y!<%9J8;zNs$H$7(B | |
1415 $B$FMxMQ$5$l$k!%(B | |
1416 | |
64
d12a199ed472
Update hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
63
diff
changeset
|
1417 \begin{codesample2} |
d12a199ed472
Update hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
63
diff
changeset
|
1418 [web] |
d12a199ed472
Update hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
63
diff
changeset
|
1419 baseurl = http://hg.domain.com/ |
d12a199ed472
Update hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
63
diff
changeset
|
1420 \end{codesample2} |
d12a199ed472
Update hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
63
diff
changeset
|
1421 |
779 | 1422 %Here is an example set of \hgext{bugzilla} hook config information. |
1423 \hgext{bugzilla}$B%U%C%/$N@_Dj>pJs$NNc$r<($9!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1424 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1425 [bugzilla] |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1426 host = bugzilla.example.com |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1427 password = mypassword |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1428 version = 2.16 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1429 # server-side repos live in /home/hg/repos, so strip 4 leading |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1430 # separators |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1431 strip = 4 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1432 hgweb = http://hg.example.com/ |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1433 usermap = /home/hg/repos/notify/bugzilla.conf |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1434 template = Changeset \{node|short\}, made by \{author\} in the \{webroot\} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1435 repo, refers to this bug.\\nFor complete details, see |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1436 \{hgweb\}\{webroot\}?cmd=changeset;node=\{node|short\}\\nChangeset |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1437 description:\\n\\t\{desc|tabindent\} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1438 \end{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1439 |
374 | 1440 %\subsubsection{Testing and troubleshooting} |
1441 \subsubsection{$B%F%9%H$HLdBj2r7h(B} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1442 |
779 | 1443 %The most common problems with configuring the \hgext{bugzilla} hook |
1444 %relate to running Bugzilla's \filename{processmail} script and mapping | |
1445 %committer names to user names. | |
1446 | |
1447 \hgext{bugzilla}$B%U%C%/$r@_Dj$9$k:]$K(BBugzilla$B$N(B\filename{processmail}$B%9%/(B | |
1448 $B%j%W%H$N<B9T$H%3%_%C%?!<L>$N%f!<%6L>$X$N%^%C%T%s%0$,$h$/LdBj$K$J$k!%(B | |
1449 | |
1450 %Recall from section~\ref{sec:hook:bugzilla:config} above that the user | |
1451 %that runs the Mercurial process on the server is also the one that | |
1452 %will run the \filename{processmail} script. The | |
1453 %\filename{processmail} script sometimes causes Bugzilla to write to | |
1454 %files in its configuration directory, and Bugzilla's configuration | |
1455 %files are usually owned by the user that your web server runs under. | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1456 |
779 | 1457 \ref{sec:hook:bugzilla:config}$B@a$G!$%5!<%P>e$G(BMercurial$B$rF0:n$5$;$F$$$k%f!<(B |
1458 $B%6$H(B\filename{processmail}$B%9%/%j%W%H$rF0$+$7$F$$$k%f!<%6$,F1$8$@$H=R$Y$?!%(B | |
1459 \filename{processmail}$B%9%/%j%W%H$O(BBugzilla$B$K@_Dj%G%#%l%/%H%jFb$N%U%!%$%k(B | |
1460 $B$K=q$-9~$^$;$k$3$H$,$"$k!%(B Bugzilla$B$N@_Dj%U%!%$%k$ODL>o!$%&%'%V%5!<%P$r5/(B | |
1461 $BF0$7$F$$$k%f!<%6$N=jM-$G$"$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1462 |
779 | 1463 %You can cause \filename{processmail} to be run with the suitable |
1464 %user's identity using the \command{sudo} command. Here is an example | |
1465 %entry for a \filename{sudoers} file. | |
1466 %\begin{codesample2} | |
1467 % hg_user = (httpd_user) NOPASSWD: /var/www/html/bugzilla/processmail-wrapper %s | |
1468 %\end{codesample2} | |
1469 %This allows the \texttt{hg\_user} user to run a | |
1470 %\filename{processmail-wrapper} program under the identity of | |
1471 %\texttt{httpd\_user}. | |
1472 | |
1473 \command{sudo}$B%3%^%s%I$r;H$&$3$H$G(B\filename{processmail}$B$rE,@Z$J%f!<%6$N(B | |
1474 $B8"8B$G<B9T$9$k$3$H$,$G$-$k!%(B\filename{sudoers}$B%U%!%$%k$N5-=RNc$r<($9!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1475 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1476 hg_user = (httpd_user) NOPASSWD: /var/www/html/bugzilla/processmail-wrapper %s |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1477 \end{codesample2} |
779 | 1478 $B$3$NNc$G$O!$%f!<%6(B\texttt{hg\_user}$B$,(B\filename{processmail-wrapper}$B%W%m%0(B |
1479 $B%i%`$r%f!<%6(B\texttt{httpd\_user}$B$N8"8B$N85$G<B9T$9$k$3$H$,$G$-$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1480 |
779 | 1481 %This indirection through a wrapper script is necessary, because |
1482 %\filename{processmail} expects to be run with its current directory | |
1483 %set to wherever you installed Bugzilla; you can't specify that kind of | |
1484 %constraint in a \filename{sudoers} file. The contents of the wrapper | |
1485 %script are simple: | |
1486 %\begin{codesample2} | |
1487 % #!/bin/sh | |
1488 % cd `dirname $0` && ./processmail "$1" nobody@example.com | |
1489 %\end{codesample2} | |
1490 %It doesn't seem to matter what email address you pass to | |
1491 %\filename{processmail}. | |
1492 | |
1493 $B$3$N%i%C%Q!<%9%/%j%W%H$+$i<B9T$9$k4V@\<B9T$OI,MW$G$"(B | |
1494 $B$k!%(B\filename{processmail}$B$O(BBugzilla$B$r$I$3$K%$%s%9%H!<%k$7$F$b%+%l%s%H%G%#(B | |
1495 $B%l%/%H%j$+$i<B9T$5$l$k$?$a$G$"$k!%<B9T@)8B$N<oN`$r(B\filename{sudoers}$B%U%!(B | |
1496 $B%$%k$K5-=R$9$k!%%i%C%Q!<%9%/%j%W%H$NFbMF$O%7%s%W%k$J$b$N$G$"$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1497 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1498 #!/bin/sh |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1499 cd `dirname $0` && ./processmail "$1" nobody@example.com |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1500 \end{codesample2} |
779 | 1501 \filename{processmail}$B$KEO$9(Bemail$B%"%I%l%9$O$I$s$J$b$N$G$b$h$$!%(B |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1502 |
779 | 1503 %If your \rcsection{usermap} is not set up correctly, users will see an |
1504 %error message from the \hgext{bugzilla} hook when they push changes | |
1505 %to the server. The error message will look like this: | |
1506 %\begin{codesample2} | |
1507 % cannot find bugzilla user id for john.q.public@example.com | |
1508 %\end{codesample2} | |
1509 %What this means is that the committer's address, | |
1510 %\texttt{john.q.public@example.com}, is not a valid Bugzilla user name, | |
1511 %nor does it have an entry in your \rcsection{usermap} that maps it to | |
1512 %a valid Bugzilla user name. | |
1513 | |
1514 \rcsection{usermap}$B$,@5$7$/@_Dj$5$l$F$$$J$$>l9g!$JQ99$r%5!<%P$K%W%C%7%e$9(B | |
1515 $B$k:]$K(B\hgext{bugzilla}$B%U%C%/$+$i$N%(%i!<%a%C%;!<%8$,%f!<%6$KAw$i$l$k!%(B | |
1516 $B%(%i!<%a%C%;!<%8$O(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1517 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1518 cannot find bugzilla user id for john.q.public@example.com |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1519 \end{codesample2} |
779 | 1520 $B$N$h$&$JFbMF$G$"$k!%$3$l$O!$%3%_%C%?$N%"%I%l%9(B |
1521 \texttt{john.q.public@example.com}$B$,M-8z$J(BBugzilla$B%f!<%6%M!<%`$G$J$/!$$^(B | |
1522 $B$?M-8z$J(BBugzilla$B%f!<%6L>$X$N%^%C%W%U%!%$%k$G$"$k(B\rcsection{usermap}$B$K$b(B | |
1523 $B5-=R$,$J$$$H$$$&0UL#$G$"$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1524 |
374 | 1525 %\subsection{\hgext{notify}---send email notifications} |
1526 \subsection{\hgext{notify}---$B%a!<%k$GDLCN$r9T$&(B} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1527 |
779 | 1528 %Although Mercurial's built-in web server provides RSS feeds of changes |
1529 %in every repository, many people prefer to receive change | |
1530 %notifications via email. The \hgext{notify} hook lets you send out | |
1531 %notifications to a set of email addresses whenever changesets arrive | |
1532 %that those subscribers are interested in. | |
1533 | |
1534 Mercurial$B$NAH$_9~$_%&%'%V%5!<%P$OA4$F$N%j%]%8%H%j$NJQ99$N(BRSS$B%U%#!<%I$rDs(B | |
1535 $B6!$9$k$,!$JQ99$NDLCN$r%a!<%k$G<u$1<h$k$3$H$r9%$`%f!<%6$bB?$$!%(B\hgext{notify} | |
1536 \hgext{notify}$B%U%C%/$O!$%A%'%s%8%;%C%H$,E~Ce$7$?;~$K4X?4$r;}$D%f!<%6$N%a!<(B | |
1537 $B%k%"%I%l%9$KDLCN$rAw$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1538 |
779 | 1539 %As with the \hgext{bugzilla} hook, the \hgext{notify} hook is |
1540 %template-driven, so you can customise the contents of the notification | |
1541 %messages that it sends. | |
1542 | |
1543 \hgext{bugzilla}$B$HF1MM$K(B\hgext{notify}$B%U%C%/$b%F%s%W%l!<%H$r;H$C$FAw?.$5(B | |
1544 $B$l$kDLCN%a%C%;!<%8$NFbMF$r%+%9%?%^%$%:$9$k$3$H$,$G$-$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1545 |
779 | 1546 %By default, the \hgext{notify} hook includes a diff of every changeset |
1547 %that it sends out; you can limit the size of the diff, or turn this | |
1548 %feature off entirely. It is useful for letting subscribers review | |
1549 %changes immediately, rather than clicking to follow a URL. | |
1550 | |
1551 $B%G%U%)%k%H$G$O(B\hgext{notify}$B%U%C%/$OAw?.$5$l$kA4$F$N%A%'%s%8%;%C%H$N(Bdiff | |
1552 $B$r4^$`!%$3$N(Bdiff$B$N%5%$%:$N>e8B$r@_Dj$7$?$j!$Aw?.<+BN$rDd;_$9$k$3$H$,$G$-(B | |
1553 $B$k!%(Bdiff$B$rAw?.$9$k$H!$9VFI<T$,(BURL$B$r%/%j%C%/$9$k$3$H$J$/JQ99$r$9$0$K%l%S%e!<(B | |
1554 $B$G$-$kMxE@$,$"$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1555 |
374 | 1556 %\subsubsection{Configuring the \hgext{notify} hook} |
1557 \subsubsection{\hgext{notify}$B%U%C%/$N@_Dj(B} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1558 |
779 | 1559 %You can set up the \hgext{notify} hook to send one email message per |
1560 %incoming changeset, or one per incoming group of changesets (all those | |
1561 %that arrived in a single pull or push). | |
1562 | |
1563 \hgext{notify}$B%U%C%/$r@_Dj$7!$E~Ce$7$?%A%'%s%8%;%C%HKh$d!J0lEY$N(Bpull$B$d(B | |
1564 push$B$GE~Ce$7$?!K0lO"$N%A%'%s%8%;%C%HKh$K(Bemail$B$rAw?.$9$k$3$H$,$G$-(B | |
1565 $B$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1566 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1567 [hooks] |
779 | 1568 # $B0lO"$NJQ99Kh$K%a!<%k$rAw?.$9$k(B |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1569 changegroup.notify = python:hgext.notify.hook |
779 | 1570 # $BJQ990l$DKh$K%a!<%k$rAw?.$9$k(B |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1571 incoming.notify = python:hgext.notify.hook |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1572 \end{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1573 |
779 | 1574 %Configuration information for this hook lives in the |
1575 %\rcsection{notify} section of a \hgrc\ file. | |
1576 | |
1577 $B$3$N%U%C%/$N@_Dj$O(B\hgrc\ $B%U%!%$%k$N(B\rcsection{notify}$B%;%/%7%g%s$K=q$/!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1578 \begin{itemize} |
779 | 1579 %\item[\rcitem{notify}{test}] By default, this hook does not send out |
1580 % email at all; instead, it prints the message that it \emph{would} | |
1581 % send. Set this item to \texttt{false} to allow email to be sent. | |
1582 % The reason that sending of email is turned off by default is that it | |
1583 % takes several tries to configure this extension exactly as you would | |
1584 % like, and it would be bad form to spam subscribers with a number of | |
1585 % ``broken'' notifications while you debug your configuration. | |
1586 \item[\rcitem{notify}{test}] $B%G%U%)%k%H$G$O$3$N%U%C%/$O%a!<%k$rA4$/Aw?.$7(B | |
1587 $B$J$$!%$=$NBe$o$j!$Aw?.$5$l$N$HF1$8FbMF$rI=<($9$k!%$3$N9`L\$r(B | |
1588 \texttt{false}$B$K@_Dj$9$k$H%a!<%k$,Aw?.$5$l$k!%%G%U%)%k%H$G%a!<(B | |
1589 $B%kAw?.$,%*%U$K$5$l$F$$$kM}M3$O!$0U?^$9$kDL$j$K$3$N@_Dj$r9T$&(B | |
1590 $B$?$a$K$O?t2s$N;n9T$,I,MW$J$?$a$G$"$k!%%G%P%C%0Cf$K9VFI<T$K2u(B | |
1591 $B$l$?DLCN$rAw$k$N$O%9%Q%`$^$,$$$G9%$^$7$/$J$$!%(B | |
1592 | |
1593 %\item[\rcitem{notify}{config}] The path to a configuration file that | |
1594 % contains subscription information. This is kept separate from the | |
1595 % main \hgrc\ so that you can maintain it in a repository of its own. | |
1596 % People can then clone that repository, update their subscriptions, | |
1597 % and push the changes back to your server. | |
1598 \item[\rcitem{notify}{config}] $B9VFI<T>pJs$r4^$`@_Dj%U%!%$%k$X$N%Q%9!%%a%$(B | |
1599 $B%s$N(B\hgrc\ $B$HJ,N%$9$k$3$H$G!$%j%]%8%H%jKh$K%j%]%8%H%jFb$G4I(B | |
1600 $BM}$G$-$k!%6(NO<T$O%j%]%8%H%j$r%/%m!<%s$7!$9VFI<T$r%"%C%W%G!<(B | |
1601 $B%H$7$FJQ99$r%5!<%P$K(Bpush$B$G$-$k!%(B | |
1602 | |
1603 %\item[\rcitem{notify}{strip}] The number of leading path separator | |
1604 % characters to strip from a repository's path, when deciding whether | |
1605 % a repository has subscribers. For example, if the repositories on | |
1606 % your server live in \dirname{/home/hg/repos}, and \hgext{notify} is | |
1607 % considering a repository named \dirname{/home/hg/repos/shared/test}, | |
1608 % setting \rcitem{notify}{strip} to \texttt{4} will cause | |
1609 % \hgext{notify} to trim the path it considers down to | |
1610 % \dirname{shared/test}, and it will match subscribers against that. | |
1611 \item[\rcitem{notify}{strip}] $B%j%]%8%H%j$K9VFI<T$,$$$k$+$I$&$+H=Dj$9$k:](B | |
1612 $B$K!$%j%]%8%H%j$N%Q%9$+$i=|5n$9$k@h9TItJ,$r%Q%96h@Z$jJ8;z$G<((B | |
1613 $B$7$??t!%Nc$($P!$%5!<%P$G%j%]%8%H%j72$,(B | |
1614 \dirname{/home/hg/repos}$B$KCV$+$l$F$*$j!$(B \hgext{notify}$B$,(B | |
1615 \dirname{/home/hg/repos/shared/test}$B$H$$$&%j%]%8%H%j$rBP>]$H(B | |
1616 $B$9$k;~!$(B\rcitem{notify}{strip} $B$r(B \texttt{4}$B$K@_Dj$9$k$H(B | |
1617 \hgext{notify}$B$O%Q%9$r(B\dirname{shared/test}$B$KC;=L$7!$$3$l$r(B | |
1618 $BMQ$$$F9VFI<T$N%^%C%A$r9T$&!%(B | |
1619 | |
1620 %\item[\rcitem{notify}{template}] The template text to use when sending | |
1621 % messages. This specifies both the contents of the message header | |
1622 % and its body. | |
1623 \item[\rcitem{notify}{template}] $B%a%C%;!<%8$rAw?.$9$k;~$K;H$o$l$k%F%-%9(B | |
1624 $B%H$N%F%s%W%l!<%H!%%a%C%;!<%8$N%X%C%@$H%\%G%#N>J}$r@_Dj$9$k(B | |
1625 $B$3$H$,$G$-$k!%(B | |
1626 | |
1627 %\item[\rcitem{notify}{maxdiff}] The maximum number of lines of diff | |
1628 % data to append to the end of a message. If a diff is longer than | |
1629 % this, it is truncated. By default, this is set to 300. Set this to | |
1630 % \texttt{0} to omit diffs from notification emails. | |
1631 \item[\rcitem{notify}{maxdiff}] $B%a%C%;!<%8$NKvHx$KE:IU$5$l$k(Bdiff$B%G!<%?$N(B | |
1632 $B:GBg9T?t!%(Bdiff$B$,$3$NCM$h$jBg$-$$>l9g$O@Z$j5M$a$i$l$k!%%G%U%)(B | |
1633 $B%k%H$G$O(B300$B9T!%$3$NCM$r(B\texttt{0}$B$K$9$k$3$H$GDLCN(Bemail$B$X$N(B | |
1634 diff$B$NE:IU$rM^@)$9$k$3$H$,$G$-$k!%(B | |
1635 | |
1636 %\item[\rcitem{notify}{sources}] A list of sources of changesets to | |
1637 % consider. This lets you limit \hgext{notify} to only sending out | |
1638 % email about changes that remote users pushed into this repository | |
1639 % via a server, for example. See section~\ref{sec:hook:sources} for | |
1640 % the sources you can specify here. | |
1641 \item[\rcitem{notify}{sources}] $BBP>]%A%'%s%8%;%C%H$N%=!<%9$N%j%9%H!%Nc$((B | |
1642 $B$P!$$3$N%j%9%H$G%j%b!<%H%f!<%6$,%5!<%P7PM3$G%j%]%8%H%j$X%W%C(B | |
1643 $B%7%e$7$?JQ99$K4X$7$F$N$_DLCN$r9T$&$h$&$K@)8B$9$k$3$H$,$G$-(B | |
1644 $B$k!%$3$3$G;XDj$G$-$k%=!<%9$K$D$$$F$O(B\ref{sec:hook:sources} | |
1645 $B@a$r;2>H$N$3$H!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1646 \end{itemize} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1647 |
779 | 1648 %If you set the \rcitem{web}{baseurl} item in the \rcsection{web} |
1649 %section, you can use it in a template; it will be available as | |
1650 %\texttt{webroot}. | |
1651 | |
1652 \rcsection{web}$B%;%/%7%g%s$N(B\rcitem{web}{baseurl}$B9`L\$r@_Dj$7$F$$$k$J$i!$(B | |
1653 $B$3$l$r(B\texttt{webroot}$B$H$7$F%F%s%W%l!<%HFb$G;H$&$3$H$,$G$-$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1654 |
779 | 1655 %Here is an example set of \hgext{notify} configuration information. |
1656 \hgext{notify}$B@_Dj$NNc$r<($9!%(B | |
1657 %\begin{codesample2} | |
1658 % [notify] | |
1659 % # really send email | |
1660 % test = false | |
1661 % # subscriber data lives in the notify repo | |
1662 % config = /home/hg/repos/notify/notify.conf | |
1663 % # repos live in /home/hg/repos on server, so strip 4 "/" chars | |
1664 % strip = 4 | |
1665 % template = X-Hg-Repo: \{webroot\} | |
1666 % Subject: \{webroot\}: \{desc|firstline|strip\} | |
1667 % From: \{author\} | |
1668 % | |
1669 % changeset \{node|short\} in \{root\} | |
1670 % details: \{baseurl\}\{webroot\}?cmd=changeset;node=\{node|short\} | |
1671 % description: | |
1672 % \{desc|tabindent|strip\} | |
1673 % | |
1674 % [web] | |
1675 % baseurl = http://hg.example.com/ | |
1676 %\end{codesample2} | |
1677 | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1678 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1679 [notify] |
779 | 1680 # $B<B:]$K%a!<%k$rAw?.$9$k$+(B |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1681 test = false |
779 | 1682 # $B9VFI<T%G!<%?$,DLCN%j%]%8%H%jFb$K$"$k(B |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1683 config = /home/hg/repos/notify/notify.conf |
779 | 1684 # $B%j%]%8%H%j72$O%5!<%P$N(B /home/hg/repos $B$K$"$k$N$G(B 4$B$D$N(B "/" $BJ8;z$r%9%H%j%C%W$9$k(B |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1685 strip = 4 |
285
814698eebbaf
fixed a typo and formatted the notify hook configuration example nicer.
Timo Paulssen <timonator@perpetuum-immobile.de>
parents:
247
diff
changeset
|
1686 template = X-Hg-Repo: \{webroot\} |
814698eebbaf
fixed a typo and formatted the notify hook configuration example nicer.
Timo Paulssen <timonator@perpetuum-immobile.de>
parents:
247
diff
changeset
|
1687 Subject: \{webroot\}: \{desc|firstline|strip\} |
814698eebbaf
fixed a typo and formatted the notify hook configuration example nicer.
Timo Paulssen <timonator@perpetuum-immobile.de>
parents:
247
diff
changeset
|
1688 From: \{author\} |
814698eebbaf
fixed a typo and formatted the notify hook configuration example nicer.
Timo Paulssen <timonator@perpetuum-immobile.de>
parents:
247
diff
changeset
|
1689 |
814698eebbaf
fixed a typo and formatted the notify hook configuration example nicer.
Timo Paulssen <timonator@perpetuum-immobile.de>
parents:
247
diff
changeset
|
1690 changeset \{node|short\} in \{root\} |
814698eebbaf
fixed a typo and formatted the notify hook configuration example nicer.
Timo Paulssen <timonator@perpetuum-immobile.de>
parents:
247
diff
changeset
|
1691 details: \{baseurl\}\{webroot\}?cmd=changeset;node=\{node|short\} |
814698eebbaf
fixed a typo and formatted the notify hook configuration example nicer.
Timo Paulssen <timonator@perpetuum-immobile.de>
parents:
247
diff
changeset
|
1692 description: |
814698eebbaf
fixed a typo and formatted the notify hook configuration example nicer.
Timo Paulssen <timonator@perpetuum-immobile.de>
parents:
247
diff
changeset
|
1693 \{desc|tabindent|strip\} |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1694 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1695 [web] |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1696 baseurl = http://hg.example.com/ |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1697 \end{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1698 |
779 | 1699 %This will produce a message that looks like the following: |
1700 $B@8@.$5$l$k%a%C%;!<%8$O<!$N$h$&$K$J$k!'(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1701 \begin{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1702 X-Hg-Repo: tests/slave |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1703 Subject: tests/slave: Handle error case when slave has no buffers |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1704 Date: Wed, 2 Aug 2006 15:25:46 -0700 (PDT) |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1705 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1706 changeset 3cba9bfe74b5 in /home/hg/repos/tests/slave |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1707 details: http://hg.example.com/tests/slave?cmd=changeset;node=3cba9bfe74b5 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1708 description: |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1709 Handle error case when slave has no buffers |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1710 diffs (54 lines): |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1711 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1712 diff -r 9d95df7cf2ad -r 3cba9bfe74b5 include/tests.h |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1713 --- a/include/tests.h Wed Aug 02 15:19:52 2006 -0700 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1714 +++ b/include/tests.h Wed Aug 02 15:25:26 2006 -0700 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1715 @@ -212,6 +212,15 @@ static __inline__ void test_headers(void *h) |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1716 [...snip...] |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1717 \end{codesample2} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1718 |
374 | 1719 %\subsubsection{Testing and troubleshooting} |
1720 \subsubsection{$B%F%9%H$HLdBj2r7h(B} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1721 |
779 | 1722 %Do not forget that by default, the \hgext{notify} extension \emph{will |
1723 % not send any mail} until you explicitly configure it to do so, by | |
1724 %setting \rcitem{notify}{test} to \texttt{false}. Until you do that, | |
1725 %it simply prints the message it \emph{would} send. | |
1726 | |
1727 $B%G%U%)%k%H$G$O(B\hgext{notify}$B%(%/%9%F%s%7%g%s$O(B\emph{$B%a!<%k$rAw?.$7$J$$(B}$B$3(B | |
1728 $B$H$KN10U$9$k$3$H!%<B:]$KAw?.$5$;$k$?$a$K$OL@<(E*$K(B\rcitem{notify}{test}$B$r(B | |
1729 \texttt{false}$B$K@_Dj$7$J$1$l$P$J$i$J$$!%$3$N@_Dj$r$7$J$1$l$P!$Aw?.$9$k$N(B | |
1730 $B$HF1$8%a%C%;!<%8$rI=<($9$k$@$1$G$"$k!%(B | |
44
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
41
diff
changeset
|
1731 |
374 | 1732 %\section{Information for writers of hooks} |
1733 \section{$B%U%C%/:n@=<T$X$N>pJs(B} | |
41 | 1734 \label{sec:hook:ref} |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1735 |
374 | 1736 %\subsection{In-process hook execution} |
1737 \subsection{$B%W%m%;%9Fb%U%C%/$N<B9T(B} | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1738 |
779 | 1739 %An in-process hook is called with arguments of the following form: |
1740 $B%W%m%;%9Fb%U%C%/$O<!$N$h$&$J7A<0$N0z?t$rH<$C$F8F$S=P$5$l$k!'(B | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1741 \begin{codesample2} |
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1742 def myhook(ui, repo, **kwargs): |
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1743 pass |
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1744 \end{codesample2} |
779 | 1745 %The \texttt{ui} parameter is a \pymodclass{mercurial.ui}{ui} object. |
1746 %The \texttt{repo} parameter is a | |
1747 %\pymodclass{mercurial.localrepo}{localrepository} object. The | |
1748 %names and values of the \texttt{**kwargs} parameters depend on the | |
1749 %hook being invoked, with the following common features: | |
1750 \texttt{ui}$B%Q%i%a!<%?$O(B\pymodclass{mercurial.ui}{ui}$B$N%*%V%8%'%/%H$G$"$k!%(B | |
1751 \texttt{repo}$B%Q%i%a!<%?$O(B | |
1752 \pymodclass{mercurial.localrepo}{localrepository}$B$N%*%V%8%'%/%H$G$"$k!%(B | |
1753 \texttt{**kwargs}$B%Q%i%a!<%?$NL>A0$HCM$O!$8F$S=P$5$l$k%U%C%/$K0MB8$7!$<!(B | |
1754 $B$N$h$&$J6&DL$7$?FCD'$r;}$D!%(B | |
1755 %\begin{itemize} | |
1756 %\item If a parameter is named \texttt{node} or | |
1757 % \texttt{parent\emph{N}}, it will contain a hexadecimal changeset ID. | |
1758 % The empty string is used to represent ``null changeset ID'' instead | |
1759 % of a string of zeroes. | |
1760 %\item If a parameter is named \texttt{url}, it will contain the URL of | |
1761 % a remote repository, if that can be determined. | |
1762 %\item Boolean-valued parameters are represented as Python | |
1763 % \texttt{bool} objects. | |
1764 %\end{itemize} | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1765 \begin{itemize} |
779 | 1766 \item $B%Q%i%a!<%?$,(B\texttt{node}$B$^$?$O(B\texttt{parent\emph{N}}$B$HL>IU$1$i$l(B |
1767 $B$?>l9g!$(B16$B?J?t$N%A%'%s%8%;%C%H(BID$B$r;}$D!%(B ``$B%L%k%A%'%s%8%;%C%H(BID''$B$r(B | |
1768 $BI=$9$?$a$K(B0$B$G$O$J$/6u$NJ8;zNs$,MQ$$$i$l$k!%(B | |
1769 \item $B%Q%i%a!<%?$,(B\texttt{url}$B$HL>IU$1$i$l$?>l9g!$%j%b!<%H%j%]%8%H%j$,FC(B | |
1770 $BDj$5$l$k$J$i$P$=$N(BURL$B$r;}$D!%(B | |
1771 \item $B%V!<%kCM$r;}$D%Q%i%a!<%?$O(BPython$B$N(B\texttt{bool}$B%*%V%8%'%/%H$H$7$F(B | |
1772 $BI=8=$5$l$k!%(B | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1773 \end{itemize} |
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1774 |
779 | 1775 %An in-process hook is called without a change to the process's working |
1776 %directory (unlike external hooks, which are run in the root of the | |
1777 %repository). It must not change the process's working directory, or | |
1778 %it will cause any calls it makes into the Mercurial API to fail. | |
1779 | |
1780 $B%W%m%;%9Fb%U%C%/$O!$%j%]%8%H%j$N%k!<%H$G<B9T$5$l$k30It%U%C%/$H0[$J$j%W%m(B | |
1781 $B%;%9$N%o!<%-%s%0%G%#%l%/%H%j$NJQ99$J$7$K8F$S=P$5$l$k!%%W%m%;%9Fb%U%C%/$O(B | |
1782 $B%W%m%;%9%o!<%-%s%0%G%#%l%/%H%j$rJQ99$7$F$O$J$i$J$$!%$5$b$J$1$l(B | |
1783 $B$P!$(BMercurial API$B$X$N8F$S=P$7$OA4$F<:GT$9$k!%(B | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1784 |
779 | 1785 %If a hook returns a boolean ``false'' value, it is considered to have |
1786 %succeeded. If it returns a boolean ``true'' value or raises an | |
1787 %exception, it is considered to have failed. A useful way to think of | |
1788 %the calling convention is ``tell me if you fail''. | |
1789 | |
1790 $B%U%C%/$,%V!<%kCM(B``false''$B$rJV$7$?>l9g!$%U%C%/$N<B9T$O@.8y$7$?$H8+$J$5$l(B | |
1791 $B$k!%%V!<%kCM(B``true''$B$rJV$7$?>l9g$*$h$SNc30$rH/@8$5$;$?>l9g$O<:GT$7$?$H8+(B | |
1792 $B$J$5$l$k!%8F$S=P$74{Ls$O(B ``$B<:GT$7$?;~$O65$($k(B''$B$H3P$($k$H$h$$!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1793 |
779 | 1794 %Note that changeset IDs are passed into Python hooks as hexadecimal |
1795 %strings, not the binary hashes that Mercurial's APIs normally use. To | |
1796 %convert a hash from hex to binary, use the | |
1797 %\pymodfunc{mercurial.node}{bin} function. | |
1798 | |
1799 Python$B%U%C%/$KEO$5$l$k%A%'%s%8%;%C%H(BID$B$O!$(BMercurial API$B$,DL>oMQ$$$k%P%$%J(B | |
1800 $B%j%O%C%7%eCM$G$O$J$/(B16$B?J?tJ8;zNs$G$"$k$3$H$KCm0U!%%O%C%7%eCM$r(B16$B?J?tJ8;z(B | |
1801 $BNs$+$i%P%$%J%j$KJQ49$9$k$K$O(B\pymodfunc{mercurial.node}{bin}$B4X?t$rMQ$$$k!%(B | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1802 |
374 | 1803 %\subsection{External hook execution} |
1804 \subsection{$B%U%C%/$N30It<B9T(B} | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1805 |
780 | 1806 %An external hook is passed to the shell of the user running Mercurial. |
1807 %Features of that shell, such as variable substitution and command | |
1808 %redirection, are available. The hook is run in the root directory of | |
1809 %the repository (unlike in-process hooks, which are run in the same | |
1810 %directory that Mercurial was run in). | |
1811 | |
1812 $B30It%U%C%/$O(BMercurial$B$r<B9T$7$F$$$k%7%'%k$G<B9T$5$l$k!%JQ?t$NCV49$d%3%^%s(B | |
1813 $B%I$N%j%@%$%l%/%H$J$I$N%7%'%k$N5!G=$,MxMQ$G$-$k!%30It%U%C%/$O!$(BMercurial$B$N(B | |
1814 $B<B9T$HF1$8%G%#%l%/%H%jFb$G<B9T$5$l$k%W%m%;%9Fb%U%C%/$H$O0[$J$j!$%j%]%8%H(B | |
1815 $B%j$N%k!<%H%G%#%l%/%H%j$G<B9T$5$l$k!%(B | |
1816 | |
1817 %Hook parameters are passed to the hook as environment variables. Each | |
1818 %environment variable's name is converted in upper case and prefixed | |
1819 %with the string ``\texttt{HG\_}''. For example, if the name of a | |
1820 %parameter is ``\texttt{node}'', the name of the environment variable | |
1821 %representing that parameter will be ``\texttt{HG\_NODE}''. | |
1822 | |
1823 $B%U%C%/%Q%i%a!<%?$O%U%C%/$K4D6-JS%9%H$7$FEO$5$l$k!%3F!9$N4D6-JQ?tL>$OBgJ8(B | |
1824 $B;z$KJQ49$5$l!$@\F,<-(B``\texttt{HG\_}''$B$,IU$1$i$l$k!%Nc$($P(B | |
1825 ``\texttt{node}''$B$H$$$&%Q%i%a!<%?$,;H$o$l$?$H$9$k$H!$$3$N%Q%i%a!<%?$rI=(B | |
1826 $B$94D6-JQ?tL>$O(B``\texttt{HG\_NODE}''$B$H$J$k!%(B | |
1827 | |
1828 %A boolean parameter is represented as the string ``\texttt{1}'' for | |
1829 %``true'', ``\texttt{0}'' for ``false''. If an environment variable is | |
1830 %named \envar{HG\_NODE}, \envar{HG\_PARENT1} or \envar{HG\_PARENT2}, it | |
1831 %contains a changeset ID represented as a hexadecimal string. The | |
1832 %empty string is used to represent ``null changeset ID'' instead of a | |
1833 %string of zeroes. If an environment variable is named | |
1834 %\envar{HG\_URL}, it will contain the URL of a remote repository, if | |
1835 %that can be determined. | |
1836 | |
1837 $B%V!<%kCM%Q%i%a!<%?$K$D$$$F$O!$??$,(B``\texttt{1}''$B!$56$,(B``\texttt{0}''$B$HI=(B | |
1838 $B8=$5$l$k!%(B\envar{HG\_NODE}$B!$(B\envar{HG\_PARENT1}$B!$(B\envar{HG\_PARENT2}$B$H$$(B | |
1839 $B$&4D6-JQ?t$,Dj5A$5$l$F$$$k$H$-!$$3$l$i$O(B16$B?J?t$NJ8;zNs$GI=$5$l$?%A%'%s%8(B | |
1840 $B%;%C%H(BID$B$r4^$`!%(B``$B%L%k%A%'%s%8%;%C%H(BID''$B$rI=8=$9$k$?$a$K%<%m$G$J$/6u$NJ8(B | |
1841 $B;zNs$,MQ$$$i$l$k!%4D6-JQ?t$,(B\envar{HG\_URL}$B$G$"$k$H$-!$%j%b!<%H%j%]%8%H%j(B | |
1842 $B$,FCDj$G$-$l$P!$$=$N(BURL$B$,F~$k!%(B | |
1843 | |
1844 %If a hook exits with a status of zero, it is considered to have | |
1845 %succeeded. If it exits with a non-zero status, it is considered to | |
1846 %have failed. | |
1847 | |
1848 $B%U%C%/$,%9%F!<%?%9(B0$B$G=*N;$7$?>l9g$O@.8y$H8+$J$5$l$k!%(B0$B0J30$N%9%F!<%?%9$G(B | |
1849 $B=*N;$7$?>l9g$O<B9T$,<:GT$7$?$H8+$J$5$l$k!%(B | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1850 |
374 | 1851 %\subsection{Finding out where changesets come from} |
780 | 1852 \subsection{$B%A%'%s%8%;%C%H$N%=!<%9$rD4$Y$k(B} |
1853 | |
1854 %A hook that involves the transfer of changesets between a local | |
1855 %repository and another may be able to find out information about the | |
1856 %``far side''. Mercurial knows \emph{how} changes are being | |
1857 %transferred, and in many cases \emph{where} they are being transferred | |
1858 %to or from. | |
1859 | |
1860 $B%m!<%+%k$J%j%]%8%H%j!&B>$N%j%]%8%H%j4V$N%A%'%s%8%;%C%H$NE>Aw$K4XO"$7$?%U%C(B | |
1861 $B%/$O!$1s3VCO$N>pJs$rF@$k$3$H$,$G$-$k!%(BMercurial$B$O(B\emph{$B$I$N$h$&$K(B}$BJQ99$,(B | |
1862 $BE>Aw$5$l$k$+!$$^$?B?$/$N>l9g(B\emph{$B$I$3$X(B}$B!$$"$k$$$O(B\emph{$B$I$3$+$i(B}$BE>Aw$5(B | |
1863 $B$l$k$N$+$bCN$k$3$H$,$G$-$k!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1864 |
374 | 1865 %\subsubsection{Sources of changesets} |
780 | 1866 \subsubsection{$B%A%'%s%8%;%C%H$N%=!<%9(B} |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1867 \label{sec:hook:sources} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1868 |
780 | 1869 %Mercurial will tell a hook what means are, or were, used to transfer |
1870 %changesets between repositories. This is provided by Mercurial in a | |
1871 %Python parameter named \texttt{source}, or an environment variable named | |
1872 %\envar{HG\_SOURCE}. | |
1873 | |
1874 Mercurial$B$O%U%C%/$K%A%'%s%8%;%C%H$NFbMF!$%j%]%8%H%j4V$NE>AwJ}K!$J$I$rDLCN(B | |
1875 $B$9$k!%(B Mercurial$B$ODLCN$N$?$a$K(B\texttt{source}$B$H$$$&(BPython$B%Q%i%a!<%?$^$?$O(B | |
1876 \envar{HG\_SOURCE}$B$H$$$&4D6-JQ?t$rMQ$$$k!%(B | |
1877 | |
1878 %\begin{itemize} | |
1879 %\item[\texttt{serve}] Changesets are transferred to or from a remote | |
1880 % repository over http or ssh. | |
1881 %\item[\texttt{pull}] Changesets are being transferred via a pull from | |
1882 % one repository into another. | |
1883 %\item[\texttt{push}] Changesets are being transferred via a push from | |
1884 % one repository into another. | |
1885 %\item[\texttt{bundle}] Changesets are being transferred to or from a | |
1886 % bundle. | |
1887 %\end{itemize} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1888 |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1889 \begin{itemize} |
780 | 1890 \item[\texttt{serve}] $B%A%'%s%8%;%C%H$O%j%b!<%H%j%]%8%H%j$+$i(Bhttp$B$^$?$O(B |
1891 ssh$B$GE>Aw$5$l$?!%(B | |
1892 \item[\texttt{pull}] $B%A%'%s%8%;%C%H$O(B2$B$D$N%j%]%8%H%j4V$r(Bpull$B$K$h$C$FE>Aw(B | |
1893 $B$5$l$?!%(B | |
1894 \item[\texttt{push}] $B%A%'%s%8%;%C%H$O(B2$B$D$N%j%]%8%H%j4V$r(Bpush$B$K$h$C$FE>Aw(B | |
1895 $B$5$l$?!%(B | |
1896 \item[\texttt{bundle}] $B%A%'%s%8%;%C%H$O%P%s%I%k$K$h$C$FE>Aw$5$l$?!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1897 \end{itemize} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1898 |
374 | 1899 %\subsubsection{Where changes are going---remote repository URLs} |
1900 \subsubsection{$BJQ99$N9T$-@h(B---$B%j%b!<%H%j%]%8%H%j$N(BURL} | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1901 \label{sec:hook:url} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1902 |
780 | 1903 %When possible, Mercurial will tell a hook the location of the ``far |
1904 %side'' of an activity that transfers changeset data between | |
1905 %repositories. This is provided by Mercurial in a Python parameter | |
1906 %named \texttt{url}, or an environment variable named \envar{HG\_URL}. | |
1907 | |
1908 Mercurial$B$O!$2DG=$G$"$k$J$i$P%j%]%8%H%j4V$N%A%'%s%8%;%C%H%G!<%?$NE>Aw$NAj(B | |
1909 $B<j$N>pJs$r%U%C%/$KDLCN$9$k!%(B Mercurial$B$O(B\texttt{url}$B$H$$$&(BPython$B%Q%i%a!<(B | |
1910 $B%?$^$?$O(B\envar{HG\_URL}$B$H$$$&4D6-JQ?t$r;H$C$FDLCN$r9T$&!%(B | |
1911 | |
1912 %This information is not always known. If a hook is invoked in a | |
1913 %repository that is being served via http or ssh, Mercurial cannot tell | |
1914 %where the remote repository is, but it may know where the client is | |
1915 | |
1916 %connecting from. In such cases, the URL will take one of the | |
1917 %following forms: | |
1918 %\begin{itemize} | |
1919 %\item \texttt{remote:ssh:\emph{ip-address}}---remote ssh client, at | |
1920 % the given IP address. | |
1921 %\item \texttt{remote:http:\emph{ip-address}}---remote http client, at | |
1922 % the given IP address. If the client is using SSL, this will be of | |
1923 % the form \texttt{remote:https:\emph{ip-address}}. | |
1924 %\item Empty---no information could be discovered about the remote | |
1925 % client. | |
1926 %\end{itemize} | |
1927 | |
1928 $B$3$N>pJs$O$$$D$b4{CN$G$"$k!%(Bhttp$B$^$?$O(Bssh$B$G%5!<%S%9$5$l$F$$$k%j%]%8%H%j$+(B | |
1929 $B$i%U%C%/$,5/F0$5$l$?>l9g!$(BMercurial$B$O%j%b!<%H%j%]%8%H%j$,$I$3$K$"$k$N$+$r(B | |
1930 $BDLCN$9$k$3$H$O$G$-$J$$$,!$%/%i%$%"%s%H$,$I$3$+$i@\B3$7$F$$$k$N$+$OCN$k$3(B | |
1931 $B$H$,$G$-$k!%(B | |
1932 | |
1933 $B$=$N>l9g!$(BURL$B$O<!$N$$$:$l$+$N7A<0$r<h$k!'(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1934 \begin{itemize} |
780 | 1935 \item \texttt{remote:ssh:\emph{ip-address}}---$B$"$k(BIP$B%"%I%l%9>e$N%j%b!<%H(B |
1936 ssh$B%/%i%$%"%s%H(B | |
1937 \item \texttt{remote:http:\emph{ip-address}}---$B$"$k(BIP$B%"%I%l%9>e$N(Bhttp$B%/(B | |
1938 $B%i%$%"%s%H!%$b$7%/%i%$%"%s%H$,(BSSL$B$r;HMQ$7$F$$$k>l(B | |
1939 $B9g!$(B\texttt{remote:https:\emph{ip-address}}$B$N$h$&$J7A<0$K$J$k!%(B | |
1940 \item Empty---$B%j%b!<%H%/%i%$%"%s%H$K4X$9$k>pJs$,$J$$!%(B | |
1941 \end{itemize} | |
1942 | |
1943 %\begin{itemize} | |
1944 %\item \texttt{remote:ssh:\emph{ip-address}}---remote ssh client, at | |
1945 % the given IP address. | |
1946 %\item \texttt{remote:http:\emph{ip-address}}---remote http client, at | |
1947 % the given IP address. If the client is using SSL, this will be of | |
1948 % the form \texttt{remote:https:\emph{ip-address}}. | |
1949 %\item Empty---no information could be discovered about the remote | |
1950 % client. | |
1951 %\end{itemize} | |
1952 | |
1953 \begin{itemize} | |
1954 \item \texttt{remote:ssh:\emph{ip-address}}---$BM?$($i$l$?(BIP$B%"%I%l%9$N%j%b!<(B | |
1955 $B%H(Bssh$B%/%i%$%"%s%H!%(B | |
1956 \item \texttt{remote:http:\emph{ip-address}}---$BM?$($i$l$?(BIP$B%"%I%l%9$N%j%b!<(B | |
1957 $B%H(Bhttp$B%/%i%$%"%s%H!%%/%i%$%"%s%H$,(BSSL$B$r;H$C$F$$$k>l9g$O(B | |
1958 \texttt{remote:https:\emph{ip-address}}$B$N7A<0$K$J$k!%(B | |
1959 \item $B6uGr(B---$B%j%b!<%H%/%i%$%"%s%H$K$D$$$F$N>pJs$OF@$i$l$J$+$C$?!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1960 \end{itemize} |
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
1961 |
374 | 1962 %\section{Hook reference} |
1963 \section{$B%U%C%/;2>H(B} | |
64
d12a199ed472
Update hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
63
diff
changeset
|
1964 |
374 | 1965 %\subsection{\hook{changegroup}---after remote changesets added} |
1966 \subsection{\hook{changegroup}---$B%j%b!<%H%A%'%s%8%;%C%H$,DI2C$5$l$?8e(B} | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1967 \label{sec:hook:changegroup} |
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
1968 |
780 | 1969 %This hook is run after a group of pre-existing changesets has been |
1970 %added to the repository, for example via a \hgcmd{pull} or | |
1971 %\hgcmd{unbundle}. This hook is run once per operation that added one | |
1972 %or more changesets. This is in contrast to the \hook{incoming} hook, | |
1973 %which is run once per changeset, regardless of whether the changesets | |
1974 %arrive in a group. | |
1975 | |
1976 $B$3$N%U%C%/$O!$(B\hgcmd{pull}$B$^$?$O(B\hgcmd{unbundle}$B$J$I$G4{B8$N%A%'%s%8%;%C(B | |
1977 $B%H%0%k!<%W$,%j%]%8%H%j$KDI2C$5$l$?8e$K<B9T$5$l$k!%$3$N%U%C%/$O!$(B1$B$D0J>e$N(B | |
1978 $B%A%'%s%8%;%C%H$rDI2C$9$k%*%Z%l!<%7%g%s$K$D$-0lEY<B9T$5$l$k!%%0%k!<%W$K4X(B | |
1979 $B78$J$/%A%'%s%8%;%C%H(B1$B$DKh$K<B9T$5$l$k(B\hook{incoming}$B%U%C%/$H$OBP>HE*$G$"(B | |
1980 $B$k!%(B | |
1981 | |
1982 %Some possible uses for this hook include kicking off an automated | |
1983 %build or test of the added changesets, updating a bug database, or | |
1984 %notifying subscribers that a repository contains new changes. | |
1985 | |
1986 $B$3$N%U%C%/$r;H$C$FDI2C$5$l$?%A%'%s%8%;%C%H$KBP$9$k<+F0%S%k%I$d%F%9%H$r5/(B | |
1987 $BF0$9$k$3$H$d!$?7$?$JJQ99$r;}$D%j%]%8%H%j$N9VFI<T$KDLCN$9$k$3$H$,$G$-$k!%(B | |
1988 | |
1989 %Parameters to this hook: | |
1990 %\begin{itemize} | |
1991 %\item[\texttt{node}] A changeset ID. The changeset ID of the first | |
1992 % changeset in the group that was added. All changesets between this | |
1993 % and \index{tags!\texttt{tip}}\texttt{tip}, inclusive, were added by | |
1994 % a single \hgcmd{pull}, \hgcmd{push} or \hgcmd{unbundle}. | |
1995 %\item[\texttt{source}] A string. The source of these changes. See | |
1996 % section~\ref{sec:hook:sources} for details. | |
1997 %\item[\texttt{url}] A URL. The location of the remote repository, if | |
1998 % known. See section~\ref{sec:hook:url} for more information. | |
1999 %\end{itemize} | |
2000 | |
2001 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
2002 \begin{itemize} |
780 | 2003 \item[\texttt{node}] $B%A%'%s%8%;%C%H(BID$B!%DI2C$5$l$?%0%k!<%W$N:G=i$N%A%'%s%8(B |
2004 $B%;%C%H$N(BID$B!%$3$N(BID$B$r4^$_(B | |
2005 \index{tags!\texttt{tip}}\texttt{tip}$B$^$G$N4V$N%A%'%s%8%;%C(B | |
2006 $B%HA4$F$O0l2s$N(B\hgcmd{pull}$B!$(B\hgcmd{push}$B$^$?$O(B | |
2007 \hgcmd{unbundle}$B$GDI2C$5$l$?!%(B | |
2008 \item[\texttt{source}] $BJ8;zNs!%$3$l$i$NJQ99$N%=!<%9!%>\:Y$K$D$$$F$O(B | |
2009 \ref{sec:hook:sources}$B$r;2>H$N$3$H!%(B | |
2010 \item[\texttt{url}] URL$B!%%j%b!<%H%j%]%8%H%j$,FCDj$G$-$k>l9g$O$=$N%"%I%l(B | |
2011 $B%9!%>\:Y$K$D$$$F$O(B\ref{sec:hook:url}$B$r;2>H$N$3$H!%(B | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
2012 \end{itemize} |
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
2013 |
780 | 2014 %See also: \hook{incoming} (section~\ref{sec:hook:incoming}), |
2015 %\hook{prechangegroup} (section~\ref{sec:hook:prechangegroup}), | |
2016 %\hook{pretxnchangegroup} (section~\ref{sec:hook:pretxnchangegroup}) | |
2017 | |
2018 $B;29M!'(B\hook{incoming} (\ref{sec:hook:incoming}$B@a(B), \hook{prechangegroup} | |
2019 (\ref{sec:hook:prechangegroup}$B@a(B), \hook{pretxnchangegroup} | |
2020 (\ref{sec:hook:pretxnchangegroup}$B@a(B) | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
2021 |
374 | 2022 %\subsection{\hook{commit}---after a new changeset is created} |
2023 \subsection{\hook{commit}---$B?7$7$$%A%'%s%8%;%C%H$,:n@.$5$l$?8e(B} | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
2024 \label{sec:hook:commit} |
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
2025 |
780 | 2026 %This hook is run after a new changeset has been created. |
2027 | |
2028 $B$3$N%U%C%/$O?7$?$J%A%'%s%8%;%C%H$,:n$i$l$?8e$K8F$P$l$k!%(B | |
2029 | |
2030 %Parameters to this hook: | |
2031 %\begin{itemize} | |
2032 %\item[\texttt{node}] A changeset ID. The changeset ID of the newly | |
2033 % committed changeset. | |
2034 %\item[\texttt{parent1}] A changeset ID. The changeset ID of the first | |
2035 % parent of the newly committed changeset. | |
2036 %\item[\texttt{parent2}] A changeset ID. The changeset ID of the second | |
2037 % parent of the newly committed changeset. | |
2038 %\end{itemize} | |
2039 | |
2040 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2041 \begin{itemize} |
780 | 2042 \item[\texttt{node}] $B%A%'%s%8%;%C%H(BID$B!%?7$?$K%3%_%C%H$5$l$?%A%'%s%8%;%C(B |
2043 $B%H$N(BID$B!%(B | |
2044 \item[\texttt{parent1}] $B%A%'%s%8%;%C%H(BID$B!%?7$?$K%3%_%C%H$5$l$?%A%'%s%8%;%C(B | |
2045 $B%H$N(B1$B$DL\$N?F$N%A%'%s%8%;%C%H(BID. | |
2046 \item[\texttt{parent2}] $B%A%'%s%8%;%C%H(BID$B!%?7$?$K%3%_%C%H$5$l$?%A%'%s%8%;%C(B | |
2047 $B%H$N(B2$B$DL\$N?F$N%A%'%s%8%;%C%H(BID. | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2048 \end{itemize} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2049 |
780 | 2050 %See also: \hook{precommit} (section~\ref{sec:hook:precommit}), |
2051 %\hook{pretxncommit} (section~\ref{sec:hook:pretxncommit}) | |
2052 | |
2053 $B;29M!'(B\hook{precommit} (\ref{sec:hook:precommit}$B@a(B), \hook{pretxncommit} | |
2054 (\ref{sec:hook:pretxncommit}$B@a(B) | |
2055 | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2056 |
374 | 2057 %\subsection{\hook{incoming}---after one remote changeset is added} |
2058 \subsection{\hook{incoming}---$B%j%b!<%H%A%'%s%8%;%C%H$,DI2C$5$l$?8e(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2059 \label{sec:hook:incoming} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2060 |
780 | 2061 %This hook is run after a pre-existing changeset has been added to the |
2062 %repository, for example via a \hgcmd{push}. If a group of changesets | |
2063 %was added in a single operation, this hook is called once for each | |
2064 %added changeset. | |
2065 | |
2066 $B$3$N%U%C%/$O(B\hgcmd{push}$B%3%^%s%I$J$I$G4{B8$N%A%'%s%8%;%C%H$,%j%]%8%H%j$K(B | |
2067 $BDI2C$5$l$?8e$G<B9T$5$l$k!%%A%'%s%8%;%C%H$N%0%k!<%W$,0lEY$KDI2C$5$l$?>l(B | |
2068 $B9g!$3F!9$N%A%'%s%8%;%C%H$K$D$$$F0lEY$:$D$3$N%U%C%/$,8F$S=P$5$l$k!%(B | |
2069 | |
2070 %You can use this hook for the same purposes as the \hook{changegroup} | |
2071 %hook (section~\ref{sec:hook:changegroup}); it's simply more convenient | |
2072 %sometimes to run a hook once per group of changesets, while other | |
2073 %times it's handier once per changeset. | |
2074 | |
2075 $B$3$N%U%C%/$O(B\hook{changegroup}(\ref{sec:hook:changegroup}$B@a(B)$B$HF1$8L\E*$G(B | |
2076 $B;H$&$3$H$,$G$-$k!%0c$$$O(B\hook{changegroup}$B$,%A%'%s%8%;%C%H%0%k!<%WA4BN$K(B | |
2077 $BBP$7$F0lEY8F$P$l$kE@$G$"$k!%(B | |
2078 | |
2079 %Parameters to this hook: | |
2080 %\begin{itemize} | |
2081 %\item[\texttt{node}] A changeset ID. The ID of the newly added | |
2082 % changeset. | |
2083 %\item[\texttt{source}] A string. The source of these changes. See | |
2084 % section~\ref{sec:hook:sources} for details. | |
2085 %\item[\texttt{url}] A URL. The location of the remote repository, if | |
2086 % known. See section~\ref{sec:hook:url} for more information. | |
2087 %\end{itemize} | |
2088 | |
2089 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2090 \begin{itemize} |
780 | 2091 \item[\texttt{node}] $B%A%'%s%8%;%C%H(BID$B!%?7$?$KDI2C$5$l$k%A%'%s%8%;%C%H$N(B |
2092 ID$B!%(B | |
2093 \item[\texttt{source}] $BJ8;zNs!%$3$l$i$NJQ99$N%=!<%9!%>\:Y$K$D$$$F$O(B | |
2094 \ref{sec:hook:sources}$B$r;2>H$N$3$H!%(B | |
2095 \item[\texttt{url}] URL$B!%%j%b!<%H%j%]%8%H%j$,FCDj$G$-$k>l9g$K$O$=$N%"%I(B | |
2096 $B%l%9!%>\:Y$K$D$$$F$O(B\ref{sec:hook:url}$B$r;2>H$N$3$H!%(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2097 \end{itemize} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2098 |
780 | 2099 %See also: \hook{changegroup} (section~\ref{sec:hook:changegroup}) \hook{prechangegroup} (section~\ref{sec:hook:prechangegroup}), \hook{pretxnchangegroup} (section~\ref{sec:hook:pretxnchangegroup}) |
2100 $B;29M!'(B\hook{changegroup} (\ref{sec:hook:changegroup}$B@a(B) | |
2101 \hook{prechangegroup} (\ref{sec:hook:prechangegroup}$B@a(B), | |
2102 \hook{pretxnchangegroup} (\ref{sec:hook:pretxnchangegroup}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2103 |
374 | 2104 %\subsection{\hook{outgoing}---after changesets are propagated} |
2105 \subsection{\hook{outgoing}---$B%A%'%s%8%;%C%H$,GH5Z$7$?8e(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2106 \label{sec:hook:outgoing} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2107 |
780 | 2108 %This hook is run after a group of changesets has been propagated out |
2109 %of this repository, for example by a \hgcmd{push} or \hgcmd{bundle} | |
2110 %command. | |
2111 | |
2112 $B$3$N%U%C%/$O%A%'%s%8%;%C%H$N%0%k!<%W$,(B\hgcmd{push}$B$d(B\hgcmd{bundle}$B%3%^%s(B | |
2113 $B%I$J$I$K$h$C$F30It$KGH5Z$7$?8e$G<B9T$5$l$k!%(B | |
2114 | |
2115 %One possible use for this hook is to notify administrators that | |
2116 %changes have been pulled. | |
2117 | |
2118 $B$3$N%U%C%/$r;H$C$F4IM}<T$O(Bpull$B$5$l$?JQ99$rCN$k$3$H$,$G$-$k!%(B | |
2119 | |
2120 %Parameters to this hook: | |
2121 %\begin{itemize} | |
2122 %\item[\texttt{node}] A changeset ID. The changeset ID of the first | |
2123 % changeset of the group that was sent. | |
2124 %\item[\texttt{source}] A string. The source of the of the operation | |
2125 % (see section~\ref{sec:hook:sources}). If a remote client pulled | |
2126 % changes from this repository, \texttt{source} will be | |
2127 % \texttt{serve}. If the client that obtained changes from this | |
2128 % repository was local, \texttt{source} will be \texttt{bundle}, | |
2129 % \texttt{pull}, or \texttt{push}, depending on the operation the | |
2130 % client performed. | |
2131 %\item[\texttt{url}] A URL. The location of the remote repository, if | |
2132 % known. See section~\ref{sec:hook:url} for more information. | |
2133 %\end{itemize} | |
2134 | |
2135 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2136 \begin{itemize} |
780 | 2137 \item[\texttt{node}] $B%A%'%s%8%;%C%H(BID$B!%Aw?.$5$l$?%A%'%s%8%;%C%H%0%k!<%W(B |
2138 $B$N:G=i$N%A%'%s%8%;%C%H(BID. | |
2139 \item[\texttt{source}] $BJ8;zNs!%A`:n85(B(~\ref{sec:hook:sources}$B@a$r;2>H(B)$B!%(B | |
2140 $B%j%b!<%H%/%i%$%"%s%H$,JQ99$r%j%]%8%H%j$+$i(Bpull$B$9$k$H(B | |
2141 \texttt{source}$B$,(B\texttt{serve}$B$H$J$k!%%j%]%8%H%j$+$iJQ99$r(B | |
2142 $BF~<j$7$?%/%i%$%"%s%H$,%m!<%+%k$G$"$l$P!$(B\texttt{source}$B$O%/(B | |
2143 $B%i%$%"%s%H$N9T$C$?F0:n$K1~$8$F(B | |
2144 \texttt{bundle}$B!$(B\texttt{pull}$B!$(B\texttt{push}$B$N$$$:$l$+$H$J(B | |
2145 $B$k!%(B | |
2146 \item[\texttt{url}] URL$B!%%j%b!<%H%j%]%8%H%j$,FCDj$G$-$k>l9g$O$=$N%"%I%l%9!%(B | |
2147 $B>\:Y$K$D$$$F$O(B\ref{sec:hook:url}$B@a$r;2>H$N$3$H!%(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2148 \end{itemize} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2149 |
780 | 2150 |
2151 %See also: \hook{preoutgoing} (section~\ref{sec:hook:preoutgoing}) | |
2152 $B;29M!'(B \hook{preoutgoing} (\ref{sec:hook:preoutgoing}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2153 |
374 | 2154 %\subsection{\hook{prechangegroup}---before starting to add remote |
2155 %changesets} | |
2156 \subsection{\hook{prechangegroup}---$B%j%b!<%H%A%'%s%8%;%C%H$,$,DI2C$5$l$k(B | |
2157 $BA0(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2158 \label{sec:hook:prechangegroup} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2159 |
780 | 2160 %This controlling hook is run before Mercurial begins to add a group of |
2161 %changesets from another repository. | |
2162 | |
2163 $B$3$N@)8f%U%C%/$O(BMercurial$B$,0lO"$N%A%'%s%8%;%C%H$rJL$N%j%]%8%H%j$KDI2C$9(B | |
2164 $B$kA0$K<B9T$5$l$k!%(B | |
2165 | |
2166 %This hook does not have any information about the changesets to be | |
2167 %added, because it is run before transmission of those changesets is | |
2168 %allowed to begin. If this hook fails, the changesets will not be | |
2169 %transmitted. | |
2170 | |
2171 $B$3$N%U%C%/$ODI2C$5$l$k%A%'%s%8%;%C%H$N>pJs$O2?$b;}$?$J$$!%$J$<$J$i$3$N%U%C(B | |
2172 $B%/$O%A%'%s%8%;%C%H$NAw?.$,;O$^$kA0$K<B9T$5$l$k$+$i$@!%%U%C%/$N<B9T$,<:GT(B | |
2173 $B$7$?>l9g$O%A%'%s%8%;%C%H$OAw?.$5$l$J$$!%(B | |
2174 | |
2175 %One use for this hook is to prevent external changes from being added | |
2176 %to a repository. For example, you could use this to ``freeze'' a | |
2177 %server-hosted branch temporarily or permanently so that users cannot | |
2178 %push to it, while still allowing a local administrator to modify the | |
2179 %repository. | |
2180 | |
2181 $B$3$N%U%C%/$r;H$C$F!$30It$NJQ99$,%j%]%8%H%j$K$D$$$+$5$l$J$$$h$&$K$9$k$3$H(B | |
2182 $B$b$G$-$k!%Nc$($P!$$3$N%U%C%/$r%5!<%P$GDs6!$5$l$k%V%i%s%A$r0l;~E*$^$?$O1J(B | |
2183 $BB3E*$K(B``$BE`7k(B''$B$7!$%m!<%+%k$J4IM}<T$O%j%]%8%H%j$rJQ99$G$-$k$,!$%j%b!<%H(B | |
2184 $B%f!<%6$O$=$N%j%]%8%H%j$K(Bpush$B$G$-$J$$$h$&$K$G$-$k!%(B | |
2185 | |
2186 %Parameters to this hook: | |
2187 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
2188 \begin{itemize} |
780 | 2189 \item[\texttt{source}] $BJ8;zNs!%JQ99$N%=!<%9!%>\:Y$K$D$$$F$O(B |
2190 \ref{sec:hook:sources}$B$r;2>H!%(B | |
2191 \item[\texttt{url}] URL$B!%%j%b!<%H%j%]%8%H%j$,FCDj$5$l$k>l9g$O$=$N%"%I%l(B | |
2192 $B%9!%>\:Y$K$D$$$F$O(B\ref{sec:hook:url}$B$r;2>H!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
2193 \end{itemize} |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2194 |
780 | 2195 %See also: \hook{changegroup} (section~\ref{sec:hook:changegroup}), |
2196 %\hook{incoming} (section~\ref{sec:hook:incoming}), , | |
2197 %\hook{pretxnchangegroup} (section~\ref{sec:hook:pretxnchangegroup}) | |
2198 | |
2199 $B;29M!'(B \hook{changegroup} (\ref{sec:hook:changegroup}$B@a(B)$B!$(B | |
2200 \hook{incoming} (\ref{sec:hook:incoming}$B@a(B)$B!$(B | |
2201 \hook{pretxnchangegroup} (\ref{sec:hook:pretxnchangegroup}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2202 |
374 | 2203 %\subsection{\hook{precommit}---before starting to commit a changeset} |
2204 \subsection{\hook{precommit}---$B%A%'%s%8%;%C%H$r%3%_%C%H$9$kA0(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2205 \label{sec:hook:precommit} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2206 |
779 | 2207 %This hook is run before Mercurial begins to commit a new changeset. |
2208 %It is run before Mercurial has any of the metadata for the commit, | |
2209 %such as the files to be committed, the commit message, or the commit | |
2210 %date. | |
2211 | |
2212 $B$3$N%U%C%/$O(BMercurial$B$,?7$7$$%A%'%s%8%;%C%H$r%3%_%C%H$9$kA0$K<B9T$5$l$k!%(B | |
2213 $B<B9T$O(BMercurial$B$,%3%_%C%H$5$l$k%U%!%$%kL>!$%3%_%C%H%a%C%;!<%8!$%3%_%C%HF|(B | |
2214 $B;~$N$h$&$J%3%_%C%H$N$?$a$N%a%?%G!<%?$r;}$DA0$G$"$k!%(B | |
41 | 2215 |
779 | 2216 %One use for this hook is to disable the ability to commit new |
2217 %changesets, while still allowing incoming changesets. Another is to | |
2218 %run a build or test, and only allow the commit to begin if the build | |
2219 %or test succeeds. | |
2220 | |
2221 $B$3$N%U%C%/$r;H$C$F!$30It$+$i$N%A%'%s%8%;%C%H$N<h$j9~$_$r5v2D$9$k0lJ}$G!$(B | |
2222 $B?7$7$$%A%'%s%8%;%C%H$r%3%_%C%H$G$-$J$$$h$&$K$9$k$3$H$b$G$-$k!%$^$?!$%S%k(B | |
2223 $B%I$d%F%9%H$r<B9T$7$?$j!$$=$l$,@.8y$7$?;~$N$_%3%_%C%H$r9T$&$h$&$K$9$k$3$H(B | |
2224 $B$b$G$-$k!%(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2225 |
779 | 2226 %Parameters to this hook: |
2227 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
2228 %\begin{itemize} | |
2229 %\item[\texttt{parent1}] A changeset ID. The changeset ID of the first | |
2230 % parent of the working directory. | |
2231 %\item[\texttt{parent2}] A changeset ID. The changeset ID of the second | |
2232 % parent of the working directory. | |
2233 %\end{itemize} | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
2234 \begin{itemize} |
779 | 2235 \item[\texttt{parent1}] $B%A%'%s%8%;%C%H(BID$B!%%o!<%-%s%0%G%#%l%/%H%j$N(B1$B$DL\$N(B |
2236 $B?F$N%A%'%s%8%;%C%H(BID$B!%(B | |
2237 \item[\texttt{parent2}] $B%A%'%s%8%;%C%H(BID$B!%%o!<%-%s%0%G%#%l%/%H%j$N(B2$B$DL\$N(B | |
2238 $B?F$N%A%'%s%8%;%C%H(BID$B!%(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2239 \end{itemize} |
779 | 2240 %If the commit proceeds, the parents of the working directory will |
2241 %become the parents of the new changeset. | |
2242 | |
2243 $B%3%_%C%H$,?J9T$9$k$H%o!<%-%s%0%G%#%l%/%H%j$N?F$O?7$7$$%A%'%s%8%;%C%H$N?F(B | |
2244 $B$H$J$k!%(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2245 |
779 | 2246 %See also: \hook{commit} (section~\ref{sec:hook:commit}), |
2247 %\hook{pretxncommit} (section~\ref{sec:hook:pretxncommit}) | |
2248 | |
2249 $B;29M!'(B\hook{commit} (\ref{sec:hook:commit}$B@a(B)$B!$(B\hook{pretxncommit} | |
2250 (\ref{sec:hook:pretxncommit}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2251 |
374 | 2252 %\subsection{\hook{preoutgoing}---before starting to propagate |
2253 %changesets} | |
2254 \subsection{\hook{preoutgoing}---$B%A%'%s%8%;%C%H$rGH5Z$5$;$kA0$K(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2255 \label{sec:hook:preoutgoing} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2256 |
779 | 2257 %This hook is invoked before Mercurial knows the identities of the |
2258 %changesets to be transmitted. | |
2259 | |
2260 $B$3$N%U%C%/$O(BMercurial$B$,Aw?.$9$k%A%'%s%8%;%C%H$r<1JL$9$kA0$K<B9T$5$l$k!%(B | |
2261 | |
2262 %One use for this hook is to prevent changes from being transmitted to | |
2263 %another repository. | |
2264 | |
2265 $B$3$N%U%C%/$rMQ$$$F!$B>$N%j%]%8%H%j$XJQ99$rAw?.$7$J$$$h$&$K$9$k$3$H$b$G$-(B | |
2266 $B$k!%(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2267 |
779 | 2268 %Parameters to this hook: |
2269 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
2270 %\begin{itemize} | |
2271 %\item[\texttt{source}] A string. The source of the operation that is | |
2272 % attempting to obtain changes from this repository (see | |
2273 % section~\ref{sec:hook:sources}). See the documentation for the | |
2274 % \texttt{source} parameter to the \hook{outgoing} hook, in | |
2275 % section~\ref{sec:hook:outgoing}, for possible values of this | |
2276 % parameter. | |
2277 %\item[\texttt{url}] A URL. The location of the remote repository, if | |
2278 % known. See section~\ref{sec:hook:url} for more information. | |
2279 %\end{itemize} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2280 \begin{itemize} |
779 | 2281 \item[\texttt{source}] $BJ8;zNs!%$3$N%j%]%8%H%j$+$iJQ99$r<hF@$7$h$&$H$9$kF0(B |
2282 $B:n$N%=!<%9!J(B\ref{sec:hook:sources}$B$r;2>H!K!%$3$N%Q%i!<%a%?$,(B | |
2283 $B<h$jF@$kCM$K$D$$$F$O!$(B \ref{sec:hook:outgoing}$B@a$N(B | |
2284 \hook{outgoing}$B%U%C%/$X$N(B\texttt{source}$B%Q%i%a!<%?$N9`L\$r;2(B | |
2285 $B>H$N$3$H!%(B | |
2286 \item[\texttt{url}] URL$B!%%j%b!<%H%j%]%8%H%j$,FCDj$G$-$k>l9g$O$=$N%"%I%l(B | |
2287 $B%9!%>\:Y$K$D$$$F$O(B\ref{sec:hook:url}$B$r;2>H$N$3$H!%(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2288 \end{itemize} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2289 |
779 | 2290 %See also: \hook{outgoing} (section~\ref{sec:hook:outgoing}) |
2291 $B;29M!'(B \hook{outgoing} (\ref{sec:hook:outgoing}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2292 |
374 | 2293 %\subsection{\hook{pretag}---before tagging a changeset} |
2294 \subsection{\hook{pretag}---$B%A%'%s%8%;%C%H$K%?%0$r$D$1$kA0$K(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2295 \label{sec:hook:pretag} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2296 |
779 | 2297 %This controlling hook is run before a tag is created. If the hook |
2298 %succeeds, creation of the tag proceeds. If the hook fails, the tag is | |
2299 %not created. | |
2300 | |
2301 $B$3$N@)8f%U%C%/$O%?%0$,:n@.$5$l$kA0$K<B9T$5$l$k!%%U%C%/$N<B9T$,@.8y$7$?>l(B | |
2302 $B9g$O%?%0$,:n@.$5$l$k!%%U%C%/$N<B9T$,<:GT$7$?>l9g$O%?%0$O:n@.$5$l$J$$!%(B | |
41 | 2303 |
779 | 2304 %Parameters to this hook: |
780 | 2305 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B |
779 | 2306 %\begin{itemize} |
2307 %\item[\texttt{local}] A boolean. Whether the tag is local to this | |
2308 % repository instance (i.e.~stored in \sfilename{.hg/localtags}) or | |
2309 % managed by Mercurial (stored in \sfilename{.hgtags}). | |
2310 %\item[\texttt{node}] A changeset ID. The ID of the changeset to be tagged. | |
2311 %\item[\texttt{tag}] A string. The name of the tag to be created. | |
2312 %\end{itemize} | |
2313 | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2314 \begin{itemize} |
779 | 2315 \item[\texttt{local}] $B%V!<%kCM!%?7$7$$%?%0$,%j%]%8%H%j%m!<%+%k$J$b$N(B |
2316 (\sfilename{.hg/localtags}$B$KJ]B8$5$l$k(B)$B$+(BMercurial$B$K4IM}(B | |
2317 $B$5$l$k$b$N(B(\sfilename{.hgtags}$B$KJ]B8$5$l$k(B)$B$+$r<($9!%(B | |
2318 \item[\texttt{node}] $B%A%'%s%8%;%C%H(BID$B!%%?%0IU$1$5$l$k%A%'%s%8%;%C%H$N(BID. | |
2319 \item[\texttt{tag}] $BJ8;zNs!%@8@.$5$l$?%?%0$NL>A0!%(B | |
39
576fef93bb49
Further content for hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
38
diff
changeset
|
2320 \end{itemize} |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
2321 |
779 | 2322 %If the tag to be created is revision-controlled, the \hook{precommit} |
2323 %and \hook{pretxncommit} hooks (sections~\ref{sec:hook:commit} | |
2324 %and~\ref{sec:hook:pretxncommit}) will also be run. | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2325 |
779 | 2326 $B@8@.$5$l$?%?%0$,%j%S%8%g%s%3%s%H%m!<%k$5$l$F$$$k>l9g!$(B\hook{precommit}$B%U%C(B |
2327 $B%/$H(B\hook{pretxncommit}$B%U%C%/(B(\ref{sec:hook:commit}$B@a$*$h$S(B | |
2328 \ref{sec:hook:pretxncommit})$B@a(B)$B$NN>J}$,<B9T$5$l$k!%(B | |
2329 | |
2330 %See also: \hook{tag} (section~\ref{sec:hook:tag}) | |
2331 $B;29M!'(B \hook{tag} (\ref{sec:hook:tag}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2332 |
374 | 2333 %\subsection{\hook{pretxnchangegroup}---before completing addition of |
2334 %remote changesets} | |
2335 \subsection{\hook{pretxnchangegroup}---$B%j%b!<%H%A%'%s%8%;%C%H$NDI2C$r40(B | |
2336 $BN;$9$kA0$K(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2337 \label{sec:hook:pretxnchangegroup} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2338 |
779 | 2339 %This controlling hook is run before a transaction---that manages the |
2340 %addition of a group of new changesets from outside the | |
2341 %repository---completes. If the hook succeeds, the transaction | |
2342 %completes, and all of the changesets become permanent within this | |
2343 %repository. If the hook fails, the transaction is rolled back, and | |
2344 %the data for the changesets is erased. | |
2345 | |
2346 $B$3$N@)8f%U%C%/$O!$30It$+$i?7$7$$%A%'%s%8%;%C%H$rDI2C$9$k%H%i%s%6%/%7%g%s(B | |
2347 $B$,40N;$9$kA0$K<B9T$5$l$k!%%U%C%/$N<B9T$,@.8y$7$?>l9g!$%H%i%s%6%/%7%g%s$O(B | |
2348 $B40N;$7!$A4$F$N%A%'%s%8%;%C%H$O%j%]%8%H%jFb$G1JB3E*$K$J$k!%%U%C%/$N<B9T$,(B | |
2349 $B<:GT$7$?>l9g!$%H%i%s%6%/%7%g%s$O%m!<%k%P%C%/$5$l!$%A%'%s%8%;%C%H$N%G!<%?(B | |
2350 $B$O>C5n$5$l$k!%(B | |
41 | 2351 |
779 | 2352 %This hook can access the metadata associated with the almost-added |
2353 %changesets, but it should not do anything permanent with this data. | |
2354 %It must also not modify the working directory. | |
2355 | |
2356 $B$3$N%U%C%/$O%H%i%s%6%/%7%g%sCf$N%A%'%s%8%;%C%H$N%a%?%G!<%?$K%"%/%;%9$9$k(B | |
2357 $B$3$H$,$G$-$k$,!$$3$N%G!<%?$r;H$C$F1JB3E*$J$3$H$O0l@Z$7$F$O$J$i$J$$!%%o!<(B | |
2358 $B%-%s%0%G%#%l%/%H%j$NJQ99$b$7$F$O$J$i$J$$!%(B | |
2359 | |
2360 %While this hook is running, if other Mercurial processes access this | |
2361 %repository, they will be able to see the almost-added changesets as if | |
2362 %they are permanent. This may lead to race conditions if you do not | |
2363 %take steps to avoid them. | |
2364 | |
2365 $B$3$N%U%C%/$N<B9TCf!$B>$N(BMercurial$B%W%m%;%9$,%j%]%8%H%j$K%"%/%;%9$9$k$H!$%H(B | |
2366 $B%i%s%6%/%7%g%sCf$N%A%'%s%8%;%C%H$r1JB3E*$J$b$N$H8+$J$92DG=@-$,$"$k!%E,@Z(B | |
2367 $B$J2sHr:v$r9V$8$J$1$l$P!$$3$l$,6%9g>uBV$r0z$-5/$3$92DG=@-$,$"$k!%(B | |
41 | 2368 |
779 | 2369 %This hook can be used to automatically vet a group of changesets. If |
2370 %the hook fails, all of the changesets are ``rejected'' when the | |
2371 %transaction rolls back. | |
41 | 2372 |
779 | 2373 $B$3$N%U%C%/$O0lO"$N%A%'%s%8%;%C%H$r<+F0E*$KGS=|$9$k$?$a$K;H$&$3$H$b$G$-(B |
2374 $B$k!%$3$N%U%C%/$N<B9T$,<:GT$7$?>l9g!$%H%i%s%6%/%7%g%s$,%m!<%k%P%C%/$5$l$k(B | |
2375 $B;~$K%A%'%s%8%;%C%HA4BN$,%j%8%'%/%H$5$l$k!%(B | |
41 | 2376 |
779 | 2377 %Parameters to this hook: |
2378 %\begin{itemize} | |
2379 %\item[\texttt{node}] A changeset ID. The changeset ID of the first | |
2380 % changeset in the group that was added. All changesets between this | |
2381 % and \index{tags!\texttt{tip}}\texttt{tip}, inclusive, were added by | |
2382 % a single \hgcmd{pull}, \hgcmd{push} or \hgcmd{unbundle}. | |
2383 %\item[\texttt{source}] A string. The source of these changes. See | |
2384 % section~\ref{sec:hook:sources} for details. | |
2385 %\item[\texttt{url}] A URL. The location of the remote repository, if | |
2386 % known. See section~\ref{sec:hook:url} for more information. | |
2387 %\end{itemize} | |
2388 | |
2389 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
2390 \begin{itemize} |
779 | 2391 \item[\texttt{node}] $B%A%'%s%8%;%C%H(BID$B!%DI2C$5$l$k0lO"$N%A%'%s%8%;%C%H$N(B |
2392 $B$&$A!$:G=i$N%A%'%s%8%;%C%H(BID$B!%$3$l$H(B | |
2393 \index{tags!\texttt{tip}}\texttt{tip}$B$N4V$NA4$F$N%A%'%s%8%;%C(B | |
2394 $B%H$,0lEY$N(B\hgcmd{pull}, \hgcmd{push} $B$^$?$O(B | |
2395 \item[\texttt{source}] $BJ8;zNs!%$3$l$i$NJQ99$N%=!<%9!%>\:Y$K$D$$$F$O(B | |
2396 \ref{sec:hook:sources}$B@a$r;2>H$N$3$H!%(B | |
2397 \item[\texttt{url}] URL$B!%4{CN$N%j%b!<%H%j%]%8%H%j$N>l=j!%>\:Y$K$D$$$F$O(B | |
2398 \ref{sec:hook:url}$B@a$r;2>H$N$3$H!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
2399 \end{itemize} |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2400 |
779 | 2401 %See also: \hook{changegroup} (section~\ref{sec:hook:changegroup}), |
2402 %\hook{incoming} (section~\ref{sec:hook:incoming}), | |
2403 %\hook{prechangegroup} (section~\ref{sec:hook:prechangegroup}) | |
2404 | |
2405 $B;29M!'(B \hook{changegroup} (\ref{sec:hook:changegroup}$B@a(B), | |
2406 \hook{incoming} (\ref{sec:hook:incoming}$B@a(B), | |
2407 \hook{prechangegroup} (\ref{sec:hook:prechangegroup}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2408 |
374 | 2409 %\subsection{\hook{pretxncommit}---before completing commit of new |
2410 %changeset} | |
2411 \subsection{\hook{pretxncommit}---$B?7$7$$%A%'%s%8%;%C%H$N%3%_%C%H$r40N;$9(B | |
2412 $B$kA0$K(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2413 \label{sec:hook:pretxncommit} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2414 |
779 | 2415 %This controlling hook is run before a transaction---that manages a new |
2416 %commit---completes. If the hook succeeds, the transaction completes | |
2417 %and the changeset becomes permanent within this repository. If the | |
2418 %hook fails, the transaction is rolled back, and the commit data is | |
2419 %erased. | |
41 | 2420 |
779 | 2421 $B$3$N@)8f%U%C%/$O?7$?$J%3%_%C%H$N$?$a$N%H%i%s%6%/%7%g%s$N40N;A0$K<B9T$5$l(B |
2422 $B$k!%$3$N%U%C%/$N<B9T$,@.8y$7$?>l9g!$%H%i%s%6%/%7%g%s$,40N;$5$l!$%A%'%s%8(B | |
2423 $B%;%C%H$O%j%]%8%H%jFb$G1JB3E*$K$J$k!%%U%C%/$N<B9T$,<:GT$7$?>l9g$O%H%i%s%6(B | |
2424 $B%/%7%g%s$O%m!<%k%P%C%/$5$l!$%3%_%C%H%G!<%?$O>C5n$5$l$k!%(B | |
2425 | |
2426 %This hook can access the metadata associated with the almost-new | |
2427 %changeset, but it should not do anything permanent with this data. It | |
2428 %must also not modify the working directory. | |
2429 | |
2430 $B$3$N%U%C%/$O%H%i%s%6%/%7%g%sCf$N%A%'%s%8%;%C%H$N%a%?%G!<%?$K%"%/%;%9$9$k(B | |
2431 $B$3$H$,$G$-$k$,!$$3$N%G!<%?$r;H$C$F1JB3E*$J$3$H$O0l@Z$7$F$O$J$i$J$$!%%o!<(B | |
2432 $B%-%s%0%G%#%l%/%H%j$NJQ99$b$7$F$O$J$i$J$$!%(B | |
41 | 2433 |
779 | 2434 %While this hook is running, if other Mercurial processes access this |
2435 %repository, they will be able to see the almost-new changeset as if it | |
2436 %is permanent. This may lead to race conditions if you do not take | |
2437 %steps to avoid them. | |
2438 | |
2439 $B$3$N%U%C%/$N<B9TCf!$B>$N(BMercurial$B%W%m%;%9$,%j%]%8%H%j$K%"%/%;%9$9$k$H!$%H(B | |
2440 $B%i%s%6%/%7%g%sCf$N%A%'%s%8%;%C%H$r1JB3E*$J$b$N$H8+$J$92DG=@-$,$"$k!%E,@Z(B | |
2441 $B$J2sHr:v$r9V$8$J$1$l$P!$$3$l$,6%9g>uBV$r0z$-5/$3$92DG=@-$,$"$k!%(B | |
41 | 2442 |
779 | 2443 %Parameters to this hook: |
2444 %\begin{itemize} | |
2445 %\item[\texttt{node}] A changeset ID. The changeset ID of the newly | |
2446 % committed changeset. | |
2447 %\item[\texttt{parent1}] A changeset ID. The changeset ID of the first | |
2448 % parent of the newly committed changeset. | |
2449 %\item[\texttt{parent2}] A changeset ID. The changeset ID of the second | |
2450 % parent of the newly committed changeset. | |
2451 %\end{itemize} | |
2452 | |
2453 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
2454 \begin{itemize} |
779 | 2455 \item[\texttt{node}] $B%A%'%s%8%;%C%H(BID$B!%?7$?$K$38+$s$H$5$l$?%A%'%s%8%;%C(B |
2456 $B%H$N(BID$B!%(B | |
2457 \item[\texttt{parent1}] $B%A%'%s%8%;%C%H(BID$B!%?7$?$K%3%_%C%H$5$l$?%A%'%s%8%;%C(B | |
2458 $B%H$N(B1$B$DL\$N?F$N%A%'%s%8%;%C%H(BID$B!%(B | |
2459 \item[\texttt{parent2}] $B%A%'%s%8%;%C%H(BID$B!%?7$?$K%3%_%C%H$5$l$?%A%'%s%8%;%C(B | |
2460 $B%H$N(B2$B$DL\$N?F$N%A%'%s%8%;%C%H(BID$B!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
2461 \end{itemize} |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2462 |
779 | 2463 %See also: \hook{precommit} (section~\ref{sec:hook:precommit}) |
2464 $B;29M!'(B\hook{precommit} (\ref{sec:hook:precommit}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2465 |
374 | 2466 %\subsection{\hook{preupdate}---before updating or merging working |
2467 %directory} | |
2468 \subsection{\hook{preupdate}---$B%o!<%-%s%0%G%#%l%/%H%j$N%"%C%W%G!<%H$^$?(B | |
2469 $B$O%^!<%8$NA0$K(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2470 \label{sec:hook:preupdate} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2471 |
779 | 2472 %This controlling hook is run before an update or merge of the working |
2473 %directory begins. It is run only if Mercurial's normal pre-update | |
2474 %checks determine that the update or merge can proceed. If the hook | |
2475 %succeeds, the update or merge may proceed; if it fails, the update or | |
2476 %merge does not start. | |
2477 | |
2478 $B$3$N@)8f%U%C%/$O%o!<%-%s%0%G%#%l%/%H%j$N%"%C%W%G!<%H$^$?$O%^!<%8$,;O$^$k(B | |
2479 $BA0$K<B9T$5$l$k!%(B Mercurial$B$NDL>o$N%"%C%W%G!<%HA0%A%'%C%/$,%"%C%W%G!<%H$^(B | |
2480 $B$?$O%^!<%8$r<B9T$G$-$k$HH=CG$7$?>l9g$K$N$_<B9T$5$l$k!%%U%C%/$N<B9T$,@.8y(B | |
2481 $B$7$?>l9g!$%"%C%W%G!<%H$^$?$O%^!<%8$,9T$o$l$k!%<:GT$7$?>l9g$O%"%C%W%G!<%H(B | |
2482 $B$^$?$O%^!<%8$O3+;O$5$l$J$$!%(B | |
41 | 2483 |
779 | 2484 %Parameters to this hook: |
2485 %\begin{itemize} | |
2486 %\item[\texttt{parent1}] A changeset ID. The ID of the parent that the | |
2487 % working directory is to be updated to. If the working directory is | |
2488 % being merged, it will not change this parent. | |
2489 %\item[\texttt{parent2}] A changeset ID. Only set if the working | |
2490 % directory is being merged. The ID of the revision that the working | |
2491 % directory is being merged with. | |
2492 %\end{itemize} | |
2493 | |
2494 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2495 \begin{itemize} |
779 | 2496 \item[\texttt{parent1}] $B%A%'%s%8%;%C%H(BID$B!%%o!<%-%s%0%G%#%l%/%H%j$,%"%C%W(B |
2497 $B%G!<%H$5$l$k?F(BID.$B%o!<%-%s%0%G%#%l%/%H%j$,%^!<%8$5$l$k>l9g!$(B | |
2498 $B?F(BID$B$OJQ99$5$l$J$$!%(B | |
2499 \item[\texttt{parent2}] $B%A%'%s%8%;%C%H(BID$B!%%o!<%-%s%0%G%#%l%/%H%j$,%^!<%8(B | |
2500 $B$5$l$k>l9g$N$_%;%C%H$5$l$k!%%o!<%-%s%0%G%#%l%/%H%j$,%^!<%8(B | |
2501 $B$5$l$k%j%S%8%g%s(BID$B!%(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2502 \end{itemize} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2503 |
779 | 2504 %See also: \hook{update} (section~\ref{sec:hook:update}) |
2505 | |
2506 $B;29M!'(B \hook{update} (\ref{sec:hook:update}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2507 |
374 | 2508 %\subsection{\hook{tag}---after tagging a changeset} |
2509 \subsection{\hook{tag}---$B%A%'%s%8%;%C%H$K%?%0IU$1$7$?8e$K(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2510 \label{sec:hook:tag} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2511 |
779 | 2512 %This hook is run after a tag has been created. |
2513 $B$3$N%U%C%/$O%?%0$,@8@.$5$l$?8e$K<B9T$5$l$k!%(B | |
41 | 2514 |
779 | 2515 %Parameters to this hook: |
2516 %\begin{itemize} | |
2517 %\item[\texttt{local}] A boolean. Whether the new tag is local to this | |
2518 % repository instance (i.e.~stored in \sfilename{.hg/localtags}) or | |
2519 % managed by Mercurial (stored in \sfilename{.hgtags}). | |
2520 %\item[\texttt{node}] A changeset ID. The ID of the changeset that was | |
2521 % tagged. | |
2522 %\item[\texttt{tag}] A string. The name of the tag that was created. | |
2523 %\end{itemize} | |
2524 | |
2525 $B$3$N%U%C%/$X$N%Q%i%a!<%?!'(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
2526 \begin{itemize} |
779 | 2527 \item[\texttt{local}] $B%V!<%kCM!%?7$7$$%?%0$,%j%]%8%H%j%m!<%+%k$J$b$N(B |
2528 (\sfilename{.hg/localtags}$B$KJ]B8$5$l$k(B)$B$+(BMercurial$B$K4IM}(B | |
2529 $B$5$l$k$b$N(B(\sfilename{.hgtags}$B$KJ]B8$5$l$k(B)$B$+$r<($9!%(B | |
2530 \item[\texttt{node}] $B%A%'%s%8%;%C%H(BID$B!%%?%0IU$1$5$l$k%A%'%s%8%;%C%H$N(BID. | |
2531 \item[\texttt{tag}] $BJ8;zNs!%@8@.$5$l$?%?%0$NL>A0!%(B | |
62
8806b2875f10
Finish off a big whack of content for the hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
54
diff
changeset
|
2532 \end{itemize} |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2533 |
779 | 2534 %If the created tag is revision-controlled, the \hook{commit} hook |
2535 %(section~\ref{sec:hook:commit}) is run before this hook. | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2536 |
779 | 2537 $B@8@.$5$l$?%?%0$,%j%S%8%g%s%3%s%H%m!<%k$5$l$F$$$k>l9g!$(B\hook{commit}$B%U%C(B |
2538 $B%/(B(\ref{sec:hook:commit}$B@a(B)$B$O$3$N%U%C%/$NA0$K<B9T$5$l$k!%(B | |
2539 | |
2540 %See also: \hook{pretag} (section~\ref{sec:hook:pretag}) | |
2541 | |
2542 $B;29M!'(B \hook{pretag} (\ref{sec:hook:pretag}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2543 |
374 | 2544 %\subsection{\hook{update}---after updating or merging working |
2545 %directory} | |
2546 \subsection{\hook{update}---$B%o!<%-%s%0%G%#%l%/%H%j$r99?7$^$?$O%^!<%8$7$?(B | |
2547 $B8e$K(B} | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2548 \label{sec:hook:update} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2549 |
779 | 2550 %This hook is run after an update or merge of the working directory |
2551 %completes. Since a merge can fail (if the external \command{hgmerge} | |
2552 %command fails to resolve conflicts in a file), this hook communicates | |
2553 %whether the update or merge completed cleanly. | |
2554 | |
2555 $B$3$N%U%C%/$O%o!<%-%s%0%G%#%l%/%H%j$N%"%C%W%G!<%H$^$?$O%^!<%8$,40N;$7$?8e(B | |
2556 $B$K<B9T$5$l$k!%%^!<%8$O<:GT$9$k$3$H$b$"$k!J30It$N(B\command{hgmerge}$B%3%^%s%I(B | |
2557 $B$O%U%!%$%kFb$N%3%s%U%j%/%H$r2r7h$G$-$J$$$3$H$,$"$k!K$N$G!$$3$N%U%C%/$O%"%C(B | |
2558 $B%W%G!<%H$^$?$O%^!<%8$,@5>o$K40N;$7$?$+$I$&$+$rLd$$9g$o$;$k!%(B | |
2559 | |
2560 %\begin{itemize} | |
2561 %\item[\texttt{error}] A boolean. Indicates whether the update or | |
2562 % merge completed successfully. | |
2563 %\item[\texttt{parent1}] A changeset ID. The ID of the parent that the | |
2564 % working directory was updated to. If the working directory was | |
2565 % merged, it will not have changed this parent. | |
2566 %\item[\texttt{parent2}] A changeset ID. Only set if the working | |
2567 % directory was merged. The ID of the revision that the working | |
2568 % directory was merged with. | |
2569 %\end{itemize} | |
41 | 2570 |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2571 \begin{itemize} |
779 | 2572 \item[\texttt{error}] $B%V!<%kCM!%%"%C%W%G!<%H$^$?$O%^!<%8$,@5>o$K40N;$7$?(B |
2573 $B$+$I$&$+$r<($9!%(B | |
2574 \item[\texttt{parent1}] $B%A%'%s%8%;%C%H(BID$B!%%o!<%-%s%0%G%#%l%/%H%j$,%"%C%W(B | |
2575 $B%G!<%H$5$l$k?F(BID$B!%%o!<%-%s%0%G%#%l%/%H%j$,%^!<%8$5$l$k>l9g!$?F(B | |
2576 ID$B$OJQ2=$7$J$$!%(Bxxx | |
2577 \item[\texttt{parent2}] $B%A%'%s%8%;%C%H(BID$B!%%o!<%-%s%0%G%#%l%/%H%j$,%^!<%8(B | |
2578 $B$5$l$k;~$N$_%;%C%H$5$l$k!%%o!<%-%s%0%G%#%l%/%H%j$,%^!<%8$5$l(B | |
2579 $B$k%j%S%8%g%s(BID$B!%(B | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2580 \end{itemize} |
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2581 |
779 | 2582 %See also: \hook{preupdate} (section~\ref{sec:hook:preupdate}) |
2583 $B;29M(B: \hook{preupdate} (\ref{sec:hook:preupdate}$B@a(B) | |
40
b2fe9964b21b
More content for hook reference.
Bryan O'Sullivan <bos@serpentine.com>
parents:
39
diff
changeset
|
2584 |
374 | 2585 %%% Local Variables: |
293
3b1291f24c0d
- replaved latex-mode to yatex-mode
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
290
diff
changeset
|
2586 %%% mode: yatex |
34
c0979ed1eabd
Get started on hook chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
2587 %%% TeX-master: "00book" |
374 | 2588 %%% End: |