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