hgbook

view en/ch09-hook.xml @ 690:2c266a253b44

Merge with myself
author Bryan O'Sullivan <bos@serpentine.com>
date Sun Apr 26 23:23:06 2009 -0700 (2009-04-26)
parents b338f5490029
children 88828b784971
line source
1 <!-- vim: set filetype=docbkxml shiftwidth=2 autoindent expandtab tw=77 : -->
3 <chapter id="chap:hook">
4 <?dbhtml filename="handling-repository-events-with-hooks.html"?>
5 <title>Handling repository events with hooks</title>
7 <para id="x_1e6">Mercurial offers a powerful mechanism to let you perform
8 automated actions in response to events that occur in a
9 repository. In some cases, you can even control Mercurial's
10 response to those events.</para>
12 <para id="x_1e7">The name Mercurial uses for one of these actions is a
13 <emphasis>hook</emphasis>. Hooks are called
14 <quote>triggers</quote> in some revision control systems, but the
15 two names refer to the same idea.</para>
17 <sect1>
18 <title>An overview of hooks in Mercurial</title>
20 <para id="x_1e8">Here is a brief list of the hooks that Mercurial
21 supports. We will revisit each of these hooks in more detail
22 later, in <xref linkend="sec:hook:ref"/>.</para>
24 <itemizedlist>
25 <listitem><para id="x_1e9"><literal role="hook">changegroup</literal>: This
26 is run after a group of changesets has been brought into the
27 repository from elsewhere.</para>
28 </listitem>
29 <listitem><para id="x_1ea"><literal role="hook">commit</literal>: This is
30 run after a new changeset has been created in the local
31 repository.</para>
32 </listitem>
33 <listitem><para id="x_1eb"><literal role="hook">incoming</literal>: This is
34 run once for each new changeset that is brought into the
35 repository from elsewhere. Notice the difference from
36 <literal role="hook">changegroup</literal>, which is run
37 once per <emphasis>group</emphasis> of changesets brought
38 in.</para>
39 </listitem>
40 <listitem><para id="x_1ec"><literal role="hook">outgoing</literal>: This is
41 run after a group of changesets has been transmitted from
42 this repository.</para>
43 </listitem>
44 <listitem><para id="x_1ed"><literal role="hook">prechangegroup</literal>:
45 This is run before starting to bring a group of changesets
46 into the repository.
47 </para>
48 </listitem>
49 <listitem><para id="x_1ee"><literal role="hook">precommit</literal>:
50 Controlling. This is run before starting a commit.
51 </para>
52 </listitem>
53 <listitem><para id="x_1ef"><literal role="hook">preoutgoing</literal>:
54 Controlling. This is run before starting to transmit a group
55 of changesets from this repository.
56 </para>
57 </listitem>
58 <listitem><para id="x_1f0"><literal role="hook">pretag</literal>:
59 Controlling. This is run before creating a tag.
60 </para>
61 </listitem>
62 <listitem><para id="x_1f1"><literal
63 role="hook">pretxnchangegroup</literal>: Controlling. This
64 is run after a group of changesets has been brought into the
65 local repository from another, but before the transaction
66 completes that will make the changes permanent in the
67 repository.
68 </para>
69 </listitem>
70 <listitem><para id="x_1f2"><literal role="hook">pretxncommit</literal>:
71 Controlling. This is run after a new changeset has been
72 created in the local repository, but before the transaction
73 completes that will make it permanent.
74 </para>
75 </listitem>
76 <listitem><para id="x_1f3"><literal role="hook">preupdate</literal>:
77 Controlling. This is run before starting an update or merge
78 of the working directory.
79 </para>
80 </listitem>
81 <listitem><para id="x_1f4"><literal role="hook">tag</literal>: This is run
82 after a tag is created.
83 </para>
84 </listitem>
85 <listitem><para id="x_1f5"><literal role="hook">update</literal>: This is
86 run after an update or merge of the working directory has
87 finished.
88 </para>
89 </listitem></itemizedlist>
90 <para id="x_1f6">Each of the hooks whose description begins with the word
91 <quote>Controlling</quote> has the ability to determine whether
92 an activity can proceed. If the hook succeeds, the activity may
93 proceed; if it fails, the activity is either not permitted or
94 undone, depending on the hook.
95 </para>
97 </sect1>
98 <sect1>
99 <title>Hooks and security</title>
101 <sect2>
102 <title>Hooks are run with your privileges</title>
104 <para id="x_1f7">When you run a Mercurial command in a repository, and the
105 command causes a hook to run, that hook runs on
106 <emphasis>your</emphasis> system, under
107 <emphasis>your</emphasis> user account, with
108 <emphasis>your</emphasis> privilege level. Since hooks are
109 arbitrary pieces of executable code, you should treat them
110 with an appropriate level of suspicion. Do not install a hook
111 unless you are confident that you know who created it and what
112 it does.
113 </para>
115 <para id="x_1f8">In some cases, you may be exposed to hooks that you did
116 not install yourself. If you work with Mercurial on an
117 unfamiliar system, Mercurial will run hooks defined in that
118 system's global <filename role="special">~/.hgrc</filename>
119 file.
120 </para>
122 <para id="x_1f9">If you are working with a repository owned by another
123 user, Mercurial can run hooks defined in that user's
124 repository, but it will still run them as <quote>you</quote>.
125 For example, if you <command role="hg-cmd">hg pull</command>
126 from that repository, and its <filename
127 role="special">.hg/hgrc</filename> defines a local <literal
128 role="hook">outgoing</literal> hook, that hook will run
129 under your user account, even though you don't own that
130 repository.
131 </para>
133 <note>
134 <para id="x_1fa"> This only applies if you are pulling from a repository
135 on a local or network filesystem. If you're pulling over
136 http or ssh, any <literal role="hook">outgoing</literal>
137 hook will run under whatever account is executing the server
138 process, on the server.
139 </para>
140 </note>
142 <para id="x_1fb">XXX To see what hooks are defined in a repository, use the
143 <command role="hg-cmd">hg config hooks</command> command. If
144 you are working in one repository, but talking to another that
145 you do not own (e.g. using <command role="hg-cmd">hg
146 pull</command> or <command role="hg-cmd">hg
147 incoming</command>), remember that it is the other
148 repository's hooks you should be checking, not your own.
149 </para>
150 </sect2>
152 <sect2>
153 <title>Hooks do not propagate</title>
155 <para id="x_1fc">In Mercurial, hooks are not revision controlled, and do
156 not propagate when you clone, or pull from, a repository. The
157 reason for this is simple: a hook is a completely arbitrary
158 piece of executable code. It runs under your user identity,
159 with your privilege level, on your machine.
160 </para>
162 <para id="x_1fd">It would be extremely reckless for any distributed
163 revision control system to implement revision-controlled
164 hooks, as this would offer an easily exploitable way to
165 subvert the accounts of users of the revision control system.
166 </para>
168 <para id="x_1fe">Since Mercurial does not propagate hooks, if you are
169 collaborating with other people on a common project, you
170 should not assume that they are using the same Mercurial hooks
171 as you are, or that theirs are correctly configured. You
172 should document the hooks you expect people to use.
173 </para>
175 <para id="x_1ff">In a corporate intranet, this is somewhat easier to
176 control, as you can for example provide a
177 <quote>standard</quote> installation of Mercurial on an NFS
178 filesystem, and use a site-wide <filename role="special">~/.hgrc</filename> file to define hooks that all users will
179 see. However, this too has its limits; see below.
180 </para>
181 </sect2>
183 <sect2>
184 <title>Hooks can be overridden</title>
186 <para id="x_200">Mercurial allows you to override a hook definition by
187 redefining the hook. You can disable it by setting its value
188 to the empty string, or change its behavior as you wish.
189 </para>
191 <para id="x_201">If you deploy a system- or site-wide <filename
192 role="special">~/.hgrc</filename> file that defines some
193 hooks, you should thus understand that your users can disable
194 or override those hooks.
195 </para>
196 </sect2>
198 <sect2>
199 <title>Ensuring that critical hooks are run</title>
201 <para id="x_202">Sometimes you may want to enforce a policy that you do not
202 want others to be able to work around. For example, you may
203 have a requirement that every changeset must pass a rigorous
204 set of tests. Defining this requirement via a hook in a
205 site-wide <filename role="special">~/.hgrc</filename> won't
206 work for remote users on laptops, and of course local users
207 can subvert it at will by overriding the hook.
208 </para>
210 <para id="x_203">Instead, you can set up your policies for use of Mercurial
211 so that people are expected to propagate changes through a
212 well-known <quote>canonical</quote> server that you have
213 locked down and configured appropriately.
214 </para>
216 <para id="x_204">One way to do this is via a combination of social
217 engineering and technology. Set up a restricted-access
218 account; users can push changes over the network to
219 repositories managed by this account, but they cannot log into
220 the account and run normal shell commands. In this scenario,
221 a user can commit a changeset that contains any old garbage
222 they want.
223 </para>
225 <para id="x_205">When someone pushes a changeset to the server that
226 everyone pulls from, the server will test the changeset before
227 it accepts it as permanent, and reject it if it fails to pass
228 the test suite. If people only pull changes from this
229 filtering server, it will serve to ensure that all changes
230 that people pull have been automatically vetted.
231 </para>
233 </sect2>
234 </sect1>
236 <sect1 id="sec:hook:simple">
237 <title>A short tutorial on using hooks</title>
239 <para id="x_212">It is easy to write a Mercurial hook. Let's start with a
240 hook that runs when you finish a <command role="hg-cmd">hg
241 commit</command>, and simply prints the hash of the changeset
242 you just created. The hook is called <literal
243 role="hook">commit</literal>.
244 </para>
246 <para id="x_213">All hooks follow the pattern in this example.</para>
248 &interaction.hook.simple.init;
250 <para id="x_214">You add an entry to the <literal
251 role="rc-hooks">hooks</literal> section of your <filename
252 role="special">~/.hgrc</filename>. On the left is the name of
253 the event to trigger on; on the right is the action to take. As
254 you can see, you can run an arbitrary shell command in a hook.
255 Mercurial passes extra information to the hook using environment
256 variables (look for <envar>HG_NODE</envar> in the example).
257 </para>
259 <sect2>
260 <title>Performing multiple actions per event</title>
262 <para id="x_215">Quite often, you will want to define more than one hook
263 for a particular kind of event, as shown below.</para>
265 &interaction.hook.simple.ext;
267 <para id="x_216">Mercurial lets you do this by adding an
268 <emphasis>extension</emphasis> to the end of a hook's name.
269 You extend a hook's name by giving the name of the hook,
270 followed by a full stop (the
271 <quote><literal>.</literal></quote> character), followed by
272 some more text of your choosing. For example, Mercurial will
273 run both <literal>commit.foo</literal> and
274 <literal>commit.bar</literal> when the
275 <literal>commit</literal> event occurs.
276 </para>
278 <para id="x_217">To give a well-defined order of execution when there are
279 multiple hooks defined for an event, Mercurial sorts hooks by
280 extension, and executes the hook commands in this sorted
281 order. In the above example, it will execute
282 <literal>commit.bar</literal> before
283 <literal>commit.foo</literal>, and <literal>commit</literal>
284 before both.
285 </para>
287 <para id="x_218">It is a good idea to use a somewhat descriptive
288 extension when you define a new hook. This will help you to
289 remember what the hook was for. If the hook fails, you'll get
290 an error message that contains the hook name and extension, so
291 using a descriptive extension could give you an immediate hint
292 as to why the hook failed (see <xref
293 linkend="sec:hook:perm"/> for an example).
294 </para>
296 </sect2>
297 <sect2 id="sec:hook:perm">
298 <title>Controlling whether an activity can proceed</title>
300 <para id="x_219">In our earlier examples, we used the <literal
301 role="hook">commit</literal> hook, which is run after a
302 commit has completed. This is one of several Mercurial hooks
303 that run after an activity finishes. Such hooks have no way
304 of influencing the activity itself.
305 </para>
307 <para id="x_21a">Mercurial defines a number of events that occur before an
308 activity starts; or after it starts, but before it finishes.
309 Hooks that trigger on these events have the added ability to
310 choose whether the activity can continue, or will abort.
311 </para>
313 <para id="x_21b">The <literal role="hook">pretxncommit</literal> hook runs
314 after a commit has all but completed. In other words, the
315 metadata representing the changeset has been written out to
316 disk, but the transaction has not yet been allowed to
317 complete. The <literal role="hook">pretxncommit</literal>
318 hook has the ability to decide whether the transaction can
319 complete, or must be rolled back.
320 </para>
322 <para id="x_21c">If the <literal role="hook">pretxncommit</literal> hook
323 exits with a status code of zero, the transaction is allowed
324 to complete; the commit finishes; and the <literal
325 role="hook">commit</literal> hook is run. If the <literal
326 role="hook">pretxncommit</literal> hook exits with a
327 non-zero status code, the transaction is rolled back; the
328 metadata representing the changeset is erased; and the
329 <literal role="hook">commit</literal> hook is not run.
330 </para>
332 &interaction.hook.simple.pretxncommit;
334 <para id="x_21d">The hook in the example above checks that a commit comment
335 contains a bug ID. If it does, the commit can complete. If
336 not, the commit is rolled back.
337 </para>
339 </sect2>
340 </sect1>
341 <sect1>
342 <title>Writing your own hooks</title>
344 <para id="x_21e">When you are writing a hook, you might find it useful to run
345 Mercurial either with the <option
346 role="hg-opt-global">-v</option> option, or the <envar
347 role="rc-item-ui">verbose</envar> config item set to
348 <quote>true</quote>. When you do so, Mercurial will print a
349 message before it calls each hook.
350 </para>
352 <sect2 id="sec:hook:lang">
353 <title>Choosing how your hook should run</title>
355 <para id="x_21f">You can write a hook either as a normal
356 program&emdash;typically a shell script&emdash;or as a Python
357 function that is executed within the Mercurial process.
358 </para>
360 <para id="x_220">Writing a hook as an external program has the advantage
361 that it requires no knowledge of Mercurial's internals. You
362 can call normal Mercurial commands to get any added
363 information you need. The trade-off is that external hooks
364 are slower than in-process hooks.
365 </para>
367 <para id="x_221">An in-process Python hook has complete access to the
368 Mercurial API, and does not <quote>shell out</quote> to
369 another process, so it is inherently faster than an external
370 hook. It is also easier to obtain much of the information
371 that a hook requires by using the Mercurial API than by
372 running Mercurial commands.
373 </para>
375 <para id="x_222">If you are comfortable with Python, or require high
376 performance, writing your hooks in Python may be a good
377 choice. However, when you have a straightforward hook to
378 write and you don't need to care about performance (probably
379 the majority of hooks), a shell script is perfectly fine.
380 </para>
382 </sect2>
383 <sect2 id="sec:hook:param">
384 <title>Hook parameters</title>
386 <para id="x_223">Mercurial calls each hook with a set of well-defined
387 parameters. In Python, a parameter is passed as a keyword
388 argument to your hook function. For an external program, a
389 parameter is passed as an environment variable.
390 </para>
392 <para id="x_224">Whether your hook is written in Python or as a shell
393 script, the hook-specific parameter names and values will be
394 the same. A boolean parameter will be represented as a
395 boolean value in Python, but as the number 1 (for
396 <quote>true</quote>) or 0 (for <quote>false</quote>) as an
397 environment variable for an external hook. If a hook
398 parameter is named <literal>foo</literal>, the keyword
399 argument for a Python hook will also be named
400 <literal>foo</literal>, while the environment variable for an
401 external hook will be named <literal>HG_FOO</literal>.
402 </para>
403 </sect2>
405 <sect2>
406 <title>Hook return values and activity control</title>
408 <para id="x_225">A hook that executes successfully must exit with a status
409 of zero if external, or return boolean <quote>false</quote> if
410 in-process. Failure is indicated with a non-zero exit status
411 from an external hook, or an in-process hook returning boolean
412 <quote>true</quote>. If an in-process hook raises an
413 exception, the hook is considered to have failed.
414 </para>
416 <para id="x_226">For a hook that controls whether an activity can proceed,
417 zero/false means <quote>allow</quote>, while
418 non-zero/true/exception means <quote>deny</quote>.
419 </para>
420 </sect2>
422 <sect2>
423 <title>Writing an external hook</title>
425 <para id="x_227">When you define an external hook in your <filename
426 role="special">~/.hgrc</filename> and the hook is run, its
427 value is passed to your shell, which interprets it. This
428 means that you can use normal shell constructs in the body of
429 the hook.
430 </para>
432 <para id="x_228">An executable hook is always run with its current
433 directory set to a repository's root directory.
434 </para>
436 <para id="x_229">Each hook parameter is passed in as an environment
437 variable; the name is upper-cased, and prefixed with the
438 string <quote><literal>HG_</literal></quote>.
439 </para>
441 <para id="x_22a">With the exception of hook parameters, Mercurial does not
442 set or modify any environment variables when running a hook.
443 This is useful to remember if you are writing a site-wide hook
444 that may be run by a number of different users with differing
445 environment variables set. In multi-user situations, you
446 should not rely on environment variables being set to the
447 values you have in your environment when testing the hook.
448 </para>
449 </sect2>
451 <sect2>
452 <title>Telling Mercurial to use an in-process hook</title>
454 <para id="x_22b">The <filename role="special">~/.hgrc</filename> syntax
455 for defining an in-process hook is slightly different than for
456 an executable hook. The value of the hook must start with the
457 text <quote><literal>python:</literal></quote>, and continue
458 with the fully-qualified name of a callable object to use as
459 the hook's value.
460 </para>
462 <para id="x_22c">The module in which a hook lives is automatically imported
463 when a hook is run. So long as you have the module name and
464 <envar>PYTHONPATH</envar> right, it should <quote>just
465 work</quote>.
466 </para>
468 <para id="x_22d">The following <filename role="special">~/.hgrc</filename>
469 example snippet illustrates the syntax and meaning of the
470 notions we just described.
471 </para>
472 <programlisting>[hooks]
473 commit.example = python:mymodule.submodule.myhook</programlisting>
474 <para id="x_22e">When Mercurial runs the <literal>commit.example</literal>
475 hook, it imports <literal>mymodule.submodule</literal>, looks
476 for the callable object named <literal>myhook</literal>, and
477 calls it.
478 </para>
479 </sect2>
481 <sect2>
482 <title>Writing an in-process hook</title>
484 <para id="x_22f">The simplest in-process hook does nothing, but illustrates
485 the basic shape of the hook API:
486 </para>
487 <programlisting>def myhook(ui, repo, **kwargs):
488 pass</programlisting>
489 <para id="x_230">The first argument to a Python hook is always a <literal
490 role="py-mod-mercurial.ui">ui</literal> object. The second
491 is a repository object; at the moment, it is always an
492 instance of <literal
493 role="py-mod-mercurial.localrepo">localrepository</literal>.
494 Following these two arguments are other keyword arguments.
495 Which ones are passed in depends on the hook being called, but
496 a hook can ignore arguments it doesn't care about by dropping
497 them into a keyword argument dict, as with
498 <literal>**kwargs</literal> above.
499 </para>
501 </sect2>
502 </sect1>
503 <sect1>
504 <title>Some hook examples</title>
506 <sect2>
507 <title>Writing meaningful commit messages</title>
509 <para id="x_231">It's hard to imagine a useful commit message being very
510 short. The simple <literal role="hook">pretxncommit</literal>
511 hook of the example below will prevent you from committing a
512 changeset with a message that is less than ten bytes long.
513 </para>
515 &interaction.hook.msglen.go;
516 </sect2>
518 <sect2>
519 <title>Checking for trailing whitespace</title>
521 <para id="x_232">An interesting use of a commit-related hook is to help you
522 to write cleaner code. A simple example of <quote>cleaner
523 code</quote> is the dictum that a change should not add any
524 new lines of text that contain <quote>trailing
525 whitespace</quote>. Trailing whitespace is a series of
526 space and tab characters at the end of a line of text. In
527 most cases, trailing whitespace is unnecessary, invisible
528 noise, but it is occasionally problematic, and people often
529 prefer to get rid of it.
530 </para>
532 <para id="x_233">You can use either the <literal
533 role="hook">precommit</literal> or <literal
534 role="hook">pretxncommit</literal> hook to tell whether you
535 have a trailing whitespace problem. If you use the <literal
536 role="hook">precommit</literal> hook, the hook will not know
537 which files you are committing, so it will have to check every
538 modified file in the repository for trailing white space. If
539 you want to commit a change to just the file
540 <filename>foo</filename>, but the file
541 <filename>bar</filename> contains trailing whitespace, doing a
542 check in the <literal role="hook">precommit</literal> hook
543 will prevent you from committing <filename>foo</filename> due
544 to the problem with <filename>bar</filename>. This doesn't
545 seem right.
546 </para>
548 <para id="x_234">Should you choose the <literal
549 role="hook">pretxncommit</literal> hook, the check won't
550 occur until just before the transaction for the commit
551 completes. This will allow you to check for problems only the
552 exact files that are being committed. However, if you entered
553 the commit message interactively and the hook fails, the
554 transaction will roll back; you'll have to re-enter the commit
555 message after you fix the trailing whitespace and run <command
556 role="hg-cmd">hg commit</command> again.
557 </para>
559 &interaction.hook.ws.simple;
561 <para id="x_235">In this example, we introduce a simple <literal
562 role="hook">pretxncommit</literal> hook that checks for
563 trailing whitespace. This hook is short, but not very
564 helpful. It exits with an error status if a change adds a
565 line with trailing whitespace to any file, but does not print
566 any information that might help us to identify the offending
567 file or line. It also has the nice property of not paying
568 attention to unmodified lines; only lines that introduce new
569 trailing whitespace cause problems.
570 </para>
572 <para id="x_236">The above version is much more complex, but also more
573 useful. It parses a unified diff to see if any lines add
574 trailing whitespace, and prints the name of the file and the
575 line number of each such occurrence. Even better, if the
576 change adds trailing whitespace, this hook saves the commit
577 comment and prints the name of the save file before exiting
578 and telling Mercurial to roll the transaction back, so you can
579 use the <option role="hg-opt-commit">-l filename</option>
580 option to <command role="hg-cmd">hg commit</command> to reuse
581 the saved commit message once you've corrected the problem.
582 </para>
584 &interaction.hook.ws.better;
586 <para id="x_237">As a final aside, note in the example above the use of
587 <command>perl</command>'s in-place editing feature to get rid
588 of trailing whitespace from a file. This is concise and
589 useful enough that I will reproduce it here.
590 </para>
591 <programlisting>perl -pi -e 's,\s+$,,' filename</programlisting>
593 </sect2>
594 </sect1>
595 <sect1>
596 <title>Bundled hooks</title>
598 <para id="x_238">Mercurial ships with several bundled hooks. You can find
599 them in the <filename class="directory">hgext</filename>
600 directory of a Mercurial source tree. If you are using a
601 Mercurial binary package, the hooks will be located in the
602 <filename class="directory">hgext</filename> directory of
603 wherever your package installer put Mercurial.
604 </para>
606 <sect2>
607 <title><literal role="hg-ext">acl</literal>&emdash;access
608 control for parts of a repository</title>
610 <para id="x_239">The <literal role="hg-ext">acl</literal> extension lets
611 you control which remote users are allowed to push changesets
612 to a networked server. You can protect any portion of a
613 repository (including the entire repo), so that a specific
614 remote user can push changes that do not affect the protected
615 portion.
616 </para>
618 <para id="x_23a">This extension implements access control based on the
619 identity of the user performing a push,
620 <emphasis>not</emphasis> on who committed the changesets
621 they're pushing. It makes sense to use this hook only if you
622 have a locked-down server environment that authenticates
623 remote users, and you want to be sure that only specific users
624 are allowed to push changes to that server.
625 </para>
627 <sect3>
628 <title>Configuring the <literal role="hook">acl</literal>
629 hook</title>
631 <para id="x_23b">In order to manage incoming changesets, the <literal
632 role="hg-ext">acl</literal> hook must be used as a
633 <literal role="hook">pretxnchangegroup</literal> hook. This
634 lets it see which files are modified by each incoming
635 changeset, and roll back a group of changesets if they
636 modify <quote>forbidden</quote> files. Example:
637 </para>
638 <programlisting>[hooks]
639 pretxnchangegroup.acl = python:hgext.acl.hook</programlisting>
641 <para id="x_23c">The <literal role="hg-ext">acl</literal> extension is
642 configured using three sections.
643 </para>
645 <para id="x_23d">The <literal role="rc-acl">acl</literal> section has
646 only one entry, <envar role="rc-item-acl">sources</envar>,
647 which lists the sources of incoming changesets that the hook
648 should pay attention to. You don't normally need to
649 configure this section.
650 </para>
651 <itemizedlist>
652 <listitem><para id="x_23e"><envar role="rc-item-acl">serve</envar>:
653 Control incoming changesets that are arriving from a
654 remote repository over http or ssh. This is the default
655 value of <envar role="rc-item-acl">sources</envar>, and
656 usually the only setting you'll need for this
657 configuration item.
658 </para>
659 </listitem>
660 <listitem><para id="x_23f"><envar role="rc-item-acl">pull</envar>:
661 Control incoming changesets that are arriving via a pull
662 from a local repository.
663 </para>
664 </listitem>
665 <listitem><para id="x_240"><envar role="rc-item-acl">push</envar>:
666 Control incoming changesets that are arriving via a push
667 from a local repository.
668 </para>
669 </listitem>
670 <listitem><para id="x_241"><envar role="rc-item-acl">bundle</envar>:
671 Control incoming changesets that are arriving from
672 another repository via a bundle.
673 </para>
674 </listitem></itemizedlist>
676 <para id="x_242">The <literal role="rc-acl.allow">acl.allow</literal>
677 section controls the users that are allowed to add
678 changesets to the repository. If this section is not
679 present, all users that are not explicitly denied are
680 allowed. If this section is present, all users that are not
681 explicitly allowed are denied (so an empty section means
682 that all users are denied).
683 </para>
685 <para id="x_243">The <literal role="rc-acl.deny">acl.deny</literal>
686 section determines which users are denied from adding
687 changesets to the repository. If this section is not
688 present or is empty, no users are denied.
689 </para>
691 <para id="x_244">The syntaxes for the <literal
692 role="rc-acl.allow">acl.allow</literal> and <literal
693 role="rc-acl.deny">acl.deny</literal> sections are
694 identical. On the left of each entry is a glob pattern that
695 matches files or directories, relative to the root of the
696 repository; on the right, a user name.
697 </para>
699 <para id="x_245">In the following example, the user
700 <literal>docwriter</literal> can only push changes to the
701 <filename class="directory">docs</filename> subtree of the
702 repository, while <literal>intern</literal> can push changes
703 to any file or directory except <filename
704 class="directory">source/sensitive</filename>.
705 </para>
706 <programlisting>[acl.allow]
707 docs/** = docwriter
708 [acl.deny]
709 source/sensitive/** = intern</programlisting>
711 </sect3>
712 <sect3>
713 <title>Testing and troubleshooting</title>
715 <para id="x_246">If you want to test the <literal
716 role="hg-ext">acl</literal> hook, run it with Mercurial's
717 debugging output enabled. Since you'll probably be running
718 it on a server where it's not convenient (or sometimes
719 possible) to pass in the <option
720 role="hg-opt-global">--debug</option> option, don't forget
721 that you can enable debugging output in your <filename
722 role="special">~/.hgrc</filename>:
723 </para>
724 <programlisting>[ui]
725 debug = true</programlisting>
726 <para id="x_247">With this enabled, the <literal
727 role="hg-ext">acl</literal> hook will print enough
728 information to let you figure out why it is allowing or
729 forbidding pushes from specific users.
730 </para>
732 </sect3> </sect2>
734 <sect2>
735 <title><literal
736 role="hg-ext">bugzilla</literal>&emdash;integration with
737 Bugzilla</title>
739 <para id="x_248">The <literal role="hg-ext">bugzilla</literal> extension
740 adds a comment to a Bugzilla bug whenever it finds a reference
741 to that bug ID in a commit comment. You can install this hook
742 on a shared server, so that any time a remote user pushes
743 changes to this server, the hook gets run.
744 </para>
746 <para id="x_249">It adds a comment to the bug that looks like this (you can
747 configure the contents of the comment&emdash;see below):
748 </para>
749 <programlisting>Changeset aad8b264143a, made by Joe User
750 &lt;joe.user@domain.com&gt; in the frobnitz repository, refers
751 to this bug. For complete details, see
752 http://hg.domain.com/frobnitz?cmd=changeset;node=aad8b264143a
753 Changeset description: Fix bug 10483 by guarding against some
754 NULL pointers</programlisting>
755 <para id="x_24a">The value of this hook is that it automates the process of
756 updating a bug any time a changeset refers to it. If you
757 configure the hook properly, it makes it easy for people to
758 browse straight from a Bugzilla bug to a changeset that refers
759 to that bug.
760 </para>
762 <para id="x_24b">You can use the code in this hook as a starting point for
763 some more exotic Bugzilla integration recipes. Here are a few
764 possibilities:
765 </para>
766 <itemizedlist>
767 <listitem><para id="x_24c">Require that every changeset pushed to the
768 server have a valid bug ID in its commit comment. In this
769 case, you'd want to configure the hook as a <literal
770 role="hook">pretxncommit</literal> hook. This would
771 allow the hook to reject changes that didn't contain bug
772 IDs.
773 </para>
774 </listitem>
775 <listitem><para id="x_24d">Allow incoming changesets to automatically
776 modify the <emphasis>state</emphasis> of a bug, as well as
777 simply adding a comment. For example, the hook could
778 recognise the string <quote>fixed bug 31337</quote> as
779 indicating that it should update the state of bug 31337 to
780 <quote>requires testing</quote>.
781 </para>
782 </listitem></itemizedlist>
784 <sect3 id="sec:hook:bugzilla:config">
785 <title>Configuring the <literal role="hook">bugzilla</literal>
786 hook</title>
788 <para id="x_24e">You should configure this hook in your server's
789 <filename role="special">~/.hgrc</filename> as an <literal
790 role="hook">incoming</literal> hook, for example as
791 follows:
792 </para>
793 <programlisting>[hooks]
794 incoming.bugzilla = python:hgext.bugzilla.hook</programlisting>
796 <para id="x_24f">Because of the specialised nature of this hook, and
797 because Bugzilla was not written with this kind of
798 integration in mind, configuring this hook is a somewhat
799 involved process.
800 </para>
802 <para id="x_250">Before you begin, you must install the MySQL bindings
803 for Python on the host(s) where you'll be running the hook.
804 If this is not available as a binary package for your
805 system, you can download it from
806 <citation>web:mysql-python</citation>.
807 </para>
809 <para id="x_251">Configuration information for this hook lives in the
810 <literal role="rc-bugzilla">bugzilla</literal> section of
811 your <filename role="special">~/.hgrc</filename>.
812 </para>
813 <itemizedlist>
814 <listitem><para id="x_252"><envar
815 role="rc-item-bugzilla">version</envar>: The version
816 of Bugzilla installed on the server. The database
817 schema that Bugzilla uses changes occasionally, so this
818 hook has to know exactly which schema to use. At the
819 moment, the only version supported is
820 <literal>2.16</literal>.
821 </para>
822 </listitem>
823 <listitem><para id="x_253"><envar role="rc-item-bugzilla">host</envar>:
824 The hostname of the MySQL server that stores your
825 Bugzilla data. The database must be configured to allow
826 connections from whatever host you are running the
827 <literal role="hook">bugzilla</literal> hook on.
828 </para>
829 </listitem>
830 <listitem><para id="x_254"><envar role="rc-item-bugzilla">user</envar>:
831 The username with which to connect to the MySQL server.
832 The database must be configured to allow this user to
833 connect from whatever host you are running the <literal
834 role="hook">bugzilla</literal> hook on. This user
835 must be able to access and modify Bugzilla tables. The
836 default value of this item is <literal>bugs</literal>,
837 which is the standard name of the Bugzilla user in a
838 MySQL database.
839 </para>
840 </listitem>
841 <listitem><para id="x_255"><envar
842 role="rc-item-bugzilla">password</envar>: The MySQL
843 password for the user you configured above. This is
844 stored as plain text, so you should make sure that
845 unauthorised users cannot read the <filename
846 role="special">~/.hgrc</filename> file where you
847 store this information.
848 </para>
849 </listitem>
850 <listitem><para id="x_256"><envar role="rc-item-bugzilla">db</envar>:
851 The name of the Bugzilla database on the MySQL server.
852 The default value of this item is
853 <literal>bugs</literal>, which is the standard name of
854 the MySQL database where Bugzilla stores its data.
855 </para>
856 </listitem>
857 <listitem><para id="x_257"><envar
858 role="rc-item-bugzilla">notify</envar>: If you want
859 Bugzilla to send out a notification email to subscribers
860 after this hook has added a comment to a bug, you will
861 need this hook to run a command whenever it updates the
862 database. The command to run depends on where you have
863 installed Bugzilla, but it will typically look something
864 like this, if you have Bugzilla installed in <filename
865 class="directory">/var/www/html/bugzilla</filename>:
866 </para>
867 <programlisting>cd /var/www/html/bugzilla &amp;&amp;
868 ./processmail %s nobody@nowhere.com</programlisting>
869 </listitem>
870 <listitem><para id="x_258"> The Bugzilla
871 <literal>processmail</literal> program expects to be
872 given a bug ID (the hook replaces
873 <quote><literal>%s</literal></quote> with the bug ID)
874 and an email address. It also expects to be able to
875 write to some files in the directory that it runs in.
876 If Bugzilla and this hook are not installed on the same
877 machine, you will need to find a way to run
878 <literal>processmail</literal> on the server where
879 Bugzilla is installed.
880 </para>
881 </listitem></itemizedlist>
883 </sect3>
884 <sect3>
885 <title>Mapping committer names to Bugzilla user names</title>
887 <para id="x_259">By default, the <literal
888 role="hg-ext">bugzilla</literal> hook tries to use the
889 email address of a changeset's committer as the Bugzilla
890 user name with which to update a bug. If this does not suit
891 your needs, you can map committer email addresses to
892 Bugzilla user names using a <literal
893 role="rc-usermap">usermap</literal> section.
894 </para>
896 <para id="x_25a">Each item in the <literal
897 role="rc-usermap">usermap</literal> section contains an
898 email address on the left, and a Bugzilla user name on the
899 right.
900 </para>
901 <programlisting>[usermap]
902 jane.user@example.com = jane</programlisting>
903 <para id="x_25b">You can either keep the <literal
904 role="rc-usermap">usermap</literal> data in a normal
905 <filename role="special">~/.hgrc</filename>, or tell the
906 <literal role="hg-ext">bugzilla</literal> hook to read the
907 information from an external <filename>usermap</filename>
908 file. In the latter case, you can store
909 <filename>usermap</filename> data by itself in (for example)
910 a user-modifiable repository. This makes it possible to let
911 your users maintain their own <envar
912 role="rc-item-bugzilla">usermap</envar> entries. The main
913 <filename role="special">~/.hgrc</filename> file might look
914 like this:
915 </para>
916 <programlisting># regular hgrc file refers to external usermap file
917 [bugzilla]
918 usermap = /home/hg/repos/userdata/bugzilla-usermap.conf</programlisting>
919 <para id="x_25c">While the <filename>usermap</filename> file that it
920 refers to might look like this:
921 </para>
922 <programlisting># bugzilla-usermap.conf - inside a hg repository
923 [usermap] stephanie@example.com = steph</programlisting>
925 </sect3>
926 <sect3>
927 <title>Configuring the text that gets added to a bug</title>
929 <para id="x_25d">You can configure the text that this hook adds as a
930 comment; you specify it in the form of a Mercurial template.
931 Several <filename role="special">~/.hgrc</filename> entries
932 (still in the <literal role="rc-bugzilla">bugzilla</literal>
933 section) control this behavior.
934 </para>
935 <itemizedlist>
936 <listitem><para id="x_25e"><literal>strip</literal>: The number of
937 leading path elements to strip from a repository's path
938 name to construct a partial path for a URL. For example,
939 if the repositories on your server live under <filename
940 class="directory">/home/hg/repos</filename>, and you
941 have a repository whose path is <filename
942 class="directory">/home/hg/repos/app/tests</filename>,
943 then setting <literal>strip</literal> to
944 <literal>4</literal> will give a partial path of
945 <filename class="directory">app/tests</filename>. The
946 hook will make this partial path available when
947 expanding a template, as <literal>webroot</literal>.
948 </para>
949 </listitem>
950 <listitem><para id="x_25f"><literal>template</literal>: The text of the
951 template to use. In addition to the usual
952 changeset-related variables, this template can use
953 <literal>hgweb</literal> (the value of the
954 <literal>hgweb</literal> configuration item above) and
955 <literal>webroot</literal> (the path constructed using
956 <literal>strip</literal> above).
957 </para>
958 </listitem></itemizedlist>
960 <para id="x_260">In addition, you can add a <envar
961 role="rc-item-web">baseurl</envar> item to the <literal
962 role="rc-web">web</literal> section of your <filename
963 role="special">~/.hgrc</filename>. The <literal
964 role="hg-ext">bugzilla</literal> hook will make this
965 available when expanding a template, as the base string to
966 use when constructing a URL that will let users browse from
967 a Bugzilla comment to view a changeset. Example:
968 </para>
969 <programlisting>[web]
970 baseurl = http://hg.domain.com/</programlisting>
972 <para id="x_261">Here is an example set of <literal
973 role="hg-ext">bugzilla</literal> hook config information.
974 </para>
976 &ch10-bugzilla-config.lst;
978 </sect3>
979 <sect3>
980 <title>Testing and troubleshooting</title>
982 <para id="x_262">The most common problems with configuring the <literal
983 role="hg-ext">bugzilla</literal> hook relate to running
984 Bugzilla's <filename>processmail</filename> script and
985 mapping committer names to user names.
986 </para>
988 <para id="x_263">Recall from <xref
989 linkend="sec:hook:bugzilla:config"/> above that the user
990 that runs the Mercurial process on the server is also the
991 one that will run the <filename>processmail</filename>
992 script. The <filename>processmail</filename> script
993 sometimes causes Bugzilla to write to files in its
994 configuration directory, and Bugzilla's configuration files
995 are usually owned by the user that your web server runs
996 under.
997 </para>
999 <para id="x_264">You can cause <filename>processmail</filename> to be run
1000 with the suitable user's identity using the
1001 <command>sudo</command> command. Here is an example entry
1002 for a <filename>sudoers</filename> file.
1003 </para>
1004 <programlisting>hg_user = (httpd_user)
1005 NOPASSWD: /var/www/html/bugzilla/processmail-wrapper %s</programlisting>
1006 <para id="x_265">This allows the <literal>hg_user</literal> user to run a
1007 <filename>processmail-wrapper</filename> program under the
1008 identity of <literal>httpd_user</literal>.
1009 </para>
1011 <para id="x_266">This indirection through a wrapper script is necessary,
1012 because <filename>processmail</filename> expects to be run
1013 with its current directory set to wherever you installed
1014 Bugzilla; you can't specify that kind of constraint in a
1015 <filename>sudoers</filename> file. The contents of the
1016 wrapper script are simple:
1017 </para>
1018 <programlisting>#!/bin/sh
1019 cd `dirname $0` &amp;&amp; ./processmail "$1" nobody@example.com</programlisting>
1020 <para id="x_267">It doesn't seem to matter what email address you pass to
1021 <filename>processmail</filename>.
1022 </para>
1024 <para id="x_268">If your <literal role="rc-usermap">usermap</literal> is
1025 not set up correctly, users will see an error message from
1026 the <literal role="hg-ext">bugzilla</literal> hook when they
1027 push changes to the server. The error message will look
1028 like this:
1029 </para>
1030 <programlisting>cannot find bugzilla user id for john.q.public@example.com</programlisting>
1031 <para id="x_269">What this means is that the committer's address,
1032 <literal>john.q.public@example.com</literal>, is not a valid
1033 Bugzilla user name, nor does it have an entry in your
1034 <literal role="rc-usermap">usermap</literal> that maps it to
1035 a valid Bugzilla user name.
1036 </para>
1038 </sect3> </sect2>
1040 <sect2>
1041 <title><literal role="hg-ext">notify</literal>&emdash;send email
1042 notifications</title>
1044 <para id="x_26a">Although Mercurial's built-in web server provides RSS
1045 feeds of changes in every repository, many people prefer to
1046 receive change notifications via email. The <literal
1047 role="hg-ext">notify</literal> hook lets you send out
1048 notifications to a set of email addresses whenever changesets
1049 arrive that those subscribers are interested in.
1050 </para>
1052 <para id="x_26b">As with the <literal role="hg-ext">bugzilla</literal>
1053 hook, the <literal role="hg-ext">notify</literal> hook is
1054 template-driven, so you can customise the contents of the
1055 notification messages that it sends.
1056 </para>
1058 <para id="x_26c">By default, the <literal role="hg-ext">notify</literal>
1059 hook includes a diff of every changeset that it sends out; you
1060 can limit the size of the diff, or turn this feature off
1061 entirely. It is useful for letting subscribers review changes
1062 immediately, rather than clicking to follow a URL.
1063 </para>
1065 <sect3>
1066 <title>Configuring the <literal role="hg-ext">notify</literal>
1067 hook</title>
1069 <para id="x_26d">You can set up the <literal
1070 role="hg-ext">notify</literal> hook to send one email
1071 message per incoming changeset, or one per incoming group of
1072 changesets (all those that arrived in a single pull or
1073 push).
1074 </para>
1075 <programlisting>[hooks]
1076 # send one email per group of changes
1077 changegroup.notify = python:hgext.notify.hook
1078 # send one email per change
1079 incoming.notify = python:hgext.notify.hook</programlisting>
1081 <para id="x_26e">Configuration information for this hook lives in the
1082 <literal role="rc-notify">notify</literal> section of a
1083 <filename role="special">~/.hgrc</filename> file.
1084 </para>
1085 <itemizedlist>
1086 <listitem><para id="x_26f"><envar role="rc-item-notify">test</envar>:
1087 By default, this hook does not send out email at all;
1088 instead, it prints the message that it
1089 <emphasis>would</emphasis> send. Set this item to
1090 <literal>false</literal> to allow email to be sent. The
1091 reason that sending of email is turned off by default is
1092 that it takes several tries to configure this extension
1093 exactly as you would like, and it would be bad form to
1094 spam subscribers with a number of <quote>broken</quote>
1095 notifications while you debug your configuration.
1096 </para>
1097 </listitem>
1098 <listitem><para id="x_270"><envar role="rc-item-notify">config</envar>:
1099 The path to a configuration file that contains
1100 subscription information. This is kept separate from
1101 the main <filename role="special">~/.hgrc</filename> so
1102 that you can maintain it in a repository of its own.
1103 People can then clone that repository, update their
1104 subscriptions, and push the changes back to your server.
1105 </para>
1106 </listitem>
1107 <listitem><para id="x_271"><envar role="rc-item-notify">strip</envar>:
1108 The number of leading path separator characters to strip
1109 from a repository's path, when deciding whether a
1110 repository has subscribers. For example, if the
1111 repositories on your server live in <filename
1112 class="directory">/home/hg/repos</filename>, and
1113 <literal role="hg-ext">notify</literal> is considering a
1114 repository named <filename
1115 class="directory">/home/hg/repos/shared/test</filename>,
1116 setting <envar role="rc-item-notify">strip</envar> to
1117 <literal>4</literal> will cause <literal
1118 role="hg-ext">notify</literal> to trim the path it
1119 considers down to <filename
1120 class="directory">shared/test</filename>, and it will
1121 match subscribers against that.
1122 </para>
1123 </listitem>
1124 <listitem><para id="x_272"><envar
1125 role="rc-item-notify">template</envar>: The template
1126 text to use when sending messages. This specifies both
1127 the contents of the message header and its body.
1128 </para>
1129 </listitem>
1130 <listitem><para id="x_273"><envar
1131 role="rc-item-notify">maxdiff</envar>: The maximum
1132 number of lines of diff data to append to the end of a
1133 message. If a diff is longer than this, it is
1134 truncated. By default, this is set to 300. Set this to
1135 <literal>0</literal> to omit diffs from notification
1136 emails.
1137 </para>
1138 </listitem>
1139 <listitem><para id="x_274"><envar
1140 role="rc-item-notify">sources</envar>: A list of
1141 sources of changesets to consider. This lets you limit
1142 <literal role="hg-ext">notify</literal> to only sending
1143 out email about changes that remote users pushed into
1144 this repository via a server, for example. See
1145 <xref linkend="sec:hook:sources"/> for the sources you
1146 can specify here.
1147 </para>
1148 </listitem></itemizedlist>
1150 <para id="x_275">If you set the <envar role="rc-item-web">baseurl</envar>
1151 item in the <literal role="rc-web">web</literal> section,
1152 you can use it in a template; it will be available as
1153 <literal>webroot</literal>.
1154 </para>
1156 <para id="x_276">Here is an example set of <literal
1157 role="hg-ext">notify</literal> configuration information.
1158 </para>
1160 &ch10-notify-config.lst;
1162 <para id="x_277">This will produce a message that looks like the
1163 following:
1164 </para>
1166 &ch10-notify-config-mail.lst;
1168 </sect3>
1169 <sect3>
1170 <title>Testing and troubleshooting</title>
1172 <para id="x_278">Do not forget that by default, the <literal
1173 role="hg-ext">notify</literal> extension <emphasis>will not
1174 send any mail</emphasis> until you explicitly configure it to do so,
1175 by setting <envar role="rc-item-notify">test</envar> to
1176 <literal>false</literal>. Until you do that, it simply
1177 prints the message it <emphasis>would</emphasis> send.
1178 </para>
1180 </sect3>
1181 </sect2>
1182 </sect1>
1183 <sect1 id="sec:hook:ref">
1184 <title>Information for writers of hooks</title>
1186 <sect2>
1187 <title>In-process hook execution</title>
1189 <para id="x_279">An in-process hook is called with arguments of the
1190 following form:
1191 </para>
1192 <programlisting>def myhook(ui, repo, **kwargs): pass</programlisting>
1193 <para id="x_27a">The <literal>ui</literal> parameter is a <literal
1194 role="py-mod-mercurial.ui">ui</literal> object. The
1195 <literal>repo</literal> parameter is a <literal
1196 role="py-mod-mercurial.localrepo">localrepository</literal>
1197 object. The names and values of the
1198 <literal>**kwargs</literal> parameters depend on the hook
1199 being invoked, with the following common features:
1200 </para>
1201 <itemizedlist>
1202 <listitem><para id="x_27b">If a parameter is named
1203 <literal>node</literal> or <literal>parentN</literal>, it
1204 will contain a hexadecimal changeset ID. The empty string
1205 is used to represent <quote>null changeset ID</quote>
1206 instead of a string of zeroes.
1207 </para>
1208 </listitem>
1209 <listitem><para id="x_27c">If a parameter is named
1210 <literal>url</literal>, it will contain the URL of a
1211 remote repository, if that can be determined.
1212 </para>
1213 </listitem>
1214 <listitem><para id="x_27d">Boolean-valued parameters are represented as
1215 Python <literal>bool</literal> objects.
1216 </para>
1217 </listitem></itemizedlist>
1219 <para id="x_27e">An in-process hook is called without a change to the
1220 process's working directory (unlike external hooks, which are
1221 run in the root of the repository). It must not change the
1222 process's working directory, or it will cause any calls it
1223 makes into the Mercurial API to fail.
1224 </para>
1226 <para id="x_27f">If a hook returns a boolean <quote>false</quote> value, it
1227 is considered to have succeeded. If it returns a boolean
1228 <quote>true</quote> value or raises an exception, it is
1229 considered to have failed. A useful way to think of the
1230 calling convention is <quote>tell me if you fail</quote>.
1231 </para>
1233 <para id="x_280">Note that changeset IDs are passed into Python hooks as
1234 hexadecimal strings, not the binary hashes that Mercurial's
1235 APIs normally use. To convert a hash from hex to binary, use
1236 the <literal>bin</literal> function.
1237 </para>
1238 </sect2>
1240 <sect2>
1241 <title>External hook execution</title>
1243 <para id="x_281">An external hook is passed to the shell of the user
1244 running Mercurial. Features of that shell, such as variable
1245 substitution and command redirection, are available. The hook
1246 is run in the root directory of the repository (unlike
1247 in-process hooks, which are run in the same directory that
1248 Mercurial was run in).
1249 </para>
1251 <para id="x_282">Hook parameters are passed to the hook as environment
1252 variables. Each environment variable's name is converted in
1253 upper case and prefixed with the string
1254 <quote><literal>HG_</literal></quote>. For example, if the
1255 name of a parameter is <quote><literal>node</literal></quote>,
1256 the name of the environment variable representing that
1257 parameter will be <quote><literal>HG_NODE</literal></quote>.
1258 </para>
1260 <para id="x_283">A boolean parameter is represented as the string
1261 <quote><literal>1</literal></quote> for <quote>true</quote>,
1262 <quote><literal>0</literal></quote> for <quote>false</quote>.
1263 If an environment variable is named <envar>HG_NODE</envar>,
1264 <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it
1265 contains a changeset ID represented as a hexadecimal string.
1266 The empty string is used to represent <quote>null changeset
1267 ID</quote> instead of a string of zeroes. If an environment
1268 variable is named <envar>HG_URL</envar>, it will contain the
1269 URL of a remote repository, if that can be determined.
1270 </para>
1272 <para id="x_284">If a hook exits with a status of zero, it is considered to
1273 have succeeded. If it exits with a non-zero status, it is
1274 considered to have failed.
1275 </para>
1276 </sect2>
1278 <sect2>
1279 <title>Finding out where changesets come from</title>
1281 <para id="x_285">A hook that involves the transfer of changesets between a
1282 local repository and another may be able to find out
1283 information about the <quote>far side</quote>. Mercurial
1284 knows <emphasis>how</emphasis> changes are being transferred,
1285 and in many cases <emphasis>where</emphasis> they are being
1286 transferred to or from.
1287 </para>
1289 <sect3 id="sec:hook:sources">
1290 <title>Sources of changesets</title>
1292 <para id="x_286">Mercurial will tell a hook what means are, or were, used
1293 to transfer changesets between repositories. This is
1294 provided by Mercurial in a Python parameter named
1295 <literal>source</literal>, or an environment variable named
1296 <envar>HG_SOURCE</envar>.
1297 </para>
1299 <itemizedlist>
1300 <listitem><para id="x_287"><literal>serve</literal>: Changesets are
1301 transferred to or from a remote repository over http or
1302 ssh.
1303 </para>
1304 </listitem>
1305 <listitem><para id="x_288"><literal>pull</literal>: Changesets are
1306 being transferred via a pull from one repository into
1307 another.
1308 </para>
1309 </listitem>
1310 <listitem><para id="x_289"><literal>push</literal>: Changesets are
1311 being transferred via a push from one repository into
1312 another.
1313 </para>
1314 </listitem>
1315 <listitem><para id="x_28a"><literal>bundle</literal>: Changesets are
1316 being transferred to or from a bundle.
1317 </para>
1318 </listitem></itemizedlist>
1319 </sect3>
1321 <sect3 id="sec:hook:url">
1322 <title>Where changes are going&emdash;remote repository
1323 URLs</title>
1325 <para id="x_28b">When possible, Mercurial will tell a hook the location
1326 of the <quote>far side</quote> of an activity that transfers
1327 changeset data between repositories. This is provided by
1328 Mercurial in a Python parameter named
1329 <literal>url</literal>, or an environment variable named
1330 <envar>HG_URL</envar>.
1331 </para>
1333 <para id="x_28c">This information is not always known. If a hook is
1334 invoked in a repository that is being served via http or
1335 ssh, Mercurial cannot tell where the remote repository is,
1336 but it may know where the client is connecting from. In
1337 such cases, the URL will take one of the following forms:
1338 </para>
1339 <itemizedlist>
1340 <listitem><para id="x_28d"><literal>remote:ssh:1.2.3.4</literal>&emdash;remote
1341 ssh client, at the IP address
1342 <literal>1.2.3.4</literal>.
1343 </para>
1344 </listitem>
1345 <listitem><para id="x_28e"><literal>remote:http:1.2.3.4</literal>&emdash;remote
1346 http client, at the IP address
1347 <literal>1.2.3.4</literal>. If the client is using SSL,
1348 this will be of the form
1349 <literal>remote:https:1.2.3.4</literal>.
1350 </para>
1351 </listitem>
1352 <listitem><para id="x_28f">Empty&emdash;no information could be
1353 discovered about the remote client.
1354 </para>
1355 </listitem></itemizedlist>
1356 </sect3>
1357 </sect2>
1358 </sect1>
1359 <sect1>
1360 <title>Hook reference</title>
1362 <sect2 id="sec:hook:changegroup">
1363 <title><literal role="hook">changegroup</literal>&emdash;after
1364 remote changesets added</title>
1366 <para id="x_290">This hook is run after a group of pre-existing changesets
1367 has been added to the repository, for example via a <command
1368 role="hg-cmd">hg pull</command> or <command role="hg-cmd">hg
1369 unbundle</command>. This hook is run once per operation
1370 that added one or more changesets. This is in contrast to the
1371 <literal role="hook">incoming</literal> hook, which is run
1372 once per changeset, regardless of whether the changesets
1373 arrive in a group.
1374 </para>
1376 <para id="x_291">Some possible uses for this hook include kicking off an
1377 automated build or test of the added changesets, updating a
1378 bug database, or notifying subscribers that a repository
1379 contains new changes.
1380 </para>
1382 <para id="x_292">Parameters to this hook:
1383 </para>
1384 <itemizedlist>
1385 <listitem><para id="x_293"><literal>node</literal>: A changeset ID. The
1386 changeset ID of the first changeset in the group that was
1387 added. All changesets between this and
1388 <literal role="tag">tip</literal>, inclusive, were added by a single
1389 <command role="hg-cmd">hg pull</command>, <command
1390 role="hg-cmd">hg push</command> or <command
1391 role="hg-cmd">hg unbundle</command>.
1392 </para>
1393 </listitem>
1394 <listitem><para id="x_294"><literal>source</literal>: A
1395 string. The source of these changes. See <xref
1396 linkend="sec:hook:sources"/> for details.
1397 </para>
1398 </listitem>
1399 <listitem><para id="x_295"><literal>url</literal>: A URL. The
1400 location of the remote repository, if known. See <xref
1401 linkend="sec:hook:url"/> for more information.
1402 </para>
1403 </listitem></itemizedlist>
1405 <para id="x_296">See also: <literal
1406 role="hook">incoming</literal> (<xref
1407 linkend="sec:hook:incoming"/>), <literal
1408 role="hook">prechangegroup</literal> (<xref
1409 linkend="sec:hook:prechangegroup"/>), <literal
1410 role="hook">pretxnchangegroup</literal> (<xref
1411 linkend="sec:hook:pretxnchangegroup"/>)
1412 </para>
1413 </sect2>
1415 <sect2 id="sec:hook:commit">
1416 <title><literal role="hook">commit</literal>&emdash;after a new
1417 changeset is created</title>
1419 <para id="x_297">This hook is run after a new changeset has been created.
1420 </para>
1422 <para id="x_298">Parameters to this hook:
1423 </para>
1424 <itemizedlist>
1425 <listitem><para id="x_299"><literal>node</literal>: A changeset ID. The
1426 changeset ID of the newly committed changeset.
1427 </para>
1428 </listitem>
1429 <listitem><para id="x_29a"><literal>parent1</literal>: A changeset ID.
1430 The changeset ID of the first parent of the newly
1431 committed changeset.
1432 </para>
1433 </listitem>
1434 <listitem><para id="x_29b"><literal>parent2</literal>: A changeset ID.
1435 The changeset ID of the second parent of the newly
1436 committed changeset.
1437 </para>
1438 </listitem></itemizedlist>
1440 <para id="x_29c">See also: <literal
1441 role="hook">precommit</literal> (<xref
1442 linkend="sec:hook:precommit"/>), <literal
1443 role="hook">pretxncommit</literal> (<xref
1444 linkend="sec:hook:pretxncommit"/>)
1445 </para>
1446 </sect2>
1448 <sect2 id="sec:hook:incoming">
1449 <title><literal role="hook">incoming</literal>&emdash;after one
1450 remote changeset is added</title>
1452 <para id="x_29d">This hook is run after a pre-existing changeset has been
1453 added to the repository, for example via a <command
1454 role="hg-cmd">hg push</command>. If a group of changesets
1455 was added in a single operation, this hook is called once for
1456 each added changeset.
1457 </para>
1459 <para id="x_29e">You can use this hook for the same purposes as
1460 the <literal role="hook">changegroup</literal> hook (<xref
1461 linkend="sec:hook:changegroup"/>); it's simply more
1462 convenient sometimes to run a hook once per group of
1463 changesets, while other times it's handier once per changeset.
1464 </para>
1466 <para id="x_29f">Parameters to this hook:
1467 </para>
1468 <itemizedlist>
1469 <listitem><para id="x_2a0"><literal>node</literal>: A changeset ID. The
1470 ID of the newly added changeset.
1471 </para>
1472 </listitem>
1473 <listitem><para id="x_2a1"><literal>source</literal>: A
1474 string. The source of these changes. See <xref
1475 linkend="sec:hook:sources"/> for details.
1476 </para>
1477 </listitem>
1478 <listitem><para id="x_2a2"><literal>url</literal>: A URL. The
1479 location of the remote repository, if known. See <xref
1480 linkend="sec:hook:url"/> for more information.
1481 </para>
1482 </listitem></itemizedlist>
1484 <para id="x_2a3">See also: <literal
1485 role="hook">changegroup</literal> (<xref
1486 linkend="sec:hook:changegroup"/>) <literal
1487 role="hook">prechangegroup</literal> (<xref
1488 linkend="sec:hook:prechangegroup"/>), <literal
1489 role="hook">pretxnchangegroup</literal> (<xref
1490 linkend="sec:hook:pretxnchangegroup"/>)
1491 </para>
1492 </sect2>
1494 <sect2 id="sec:hook:outgoing">
1495 <title><literal role="hook">outgoing</literal>&emdash;after
1496 changesets are propagated</title>
1498 <para id="x_2a4">This hook is run after a group of changesets has been
1499 propagated out of this repository, for example by a <command
1500 role="hg-cmd">hg push</command> or <command role="hg-cmd">hg
1501 bundle</command> command.
1502 </para>
1504 <para id="x_2a5">One possible use for this hook is to notify administrators
1505 that changes have been pulled.
1506 </para>
1508 <para id="x_2a6">Parameters to this hook:
1509 </para>
1510 <itemizedlist>
1511 <listitem><para id="x_2a7"><literal>node</literal>: A changeset ID. The
1512 changeset ID of the first changeset of the group that was
1513 sent.
1514 </para>
1515 </listitem>
1516 <listitem><para id="x_2a8"><literal>source</literal>: A string. The
1517 source of the of the operation (see <xref
1518 linkend="sec:hook:sources"/>). If a remote
1519 client pulled changes from this repository,
1520 <literal>source</literal> will be
1521 <literal>serve</literal>. If the client that obtained
1522 changes from this repository was local,
1523 <literal>source</literal> will be
1524 <literal>bundle</literal>, <literal>pull</literal>, or
1525 <literal>push</literal>, depending on the operation the
1526 client performed.
1527 </para>
1528 </listitem>
1529 <listitem><para id="x_2a9"><literal>url</literal>: A URL. The
1530 location of the remote repository, if known. See <xref
1531 linkend="sec:hook:url"/> for more information.
1532 </para>
1533 </listitem></itemizedlist>
1535 <para id="x_2aa">See also: <literal
1536 role="hook">preoutgoing</literal> (<xref
1537 linkend="sec:hook:preoutgoing"/>)
1538 </para>
1539 </sect2>
1541 <sect2 id="sec:hook:prechangegroup">
1542 <title><literal
1543 role="hook">prechangegroup</literal>&emdash;before starting
1544 to add remote changesets</title>
1546 <para id="x_2ab">This controlling hook is run before Mercurial begins to
1547 add a group of changesets from another repository.
1548 </para>
1550 <para id="x_2ac">This hook does not have any information about the
1551 changesets to be added, because it is run before transmission
1552 of those changesets is allowed to begin. If this hook fails,
1553 the changesets will not be transmitted.
1554 </para>
1556 <para id="x_2ad">One use for this hook is to prevent external changes from
1557 being added to a repository. For example, you could use this
1558 to <quote>freeze</quote> a server-hosted branch temporarily or
1559 permanently so that users cannot push to it, while still
1560 allowing a local administrator to modify the repository.
1561 </para>
1563 <para id="x_2ae">Parameters to this hook:
1564 </para>
1565 <itemizedlist>
1566 <listitem><para id="x_2af"><literal>source</literal>: A string. The
1567 source of these changes. See <xref
1568 linkend="sec:hook:sources"/> for details.
1569 </para>
1570 </listitem>
1571 <listitem><para id="x_2b0"><literal>url</literal>: A URL. The
1572 location of the remote repository, if known. See <xref
1573 linkend="sec:hook:url"/> for more information.
1574 </para>
1575 </listitem></itemizedlist>
1577 <para id="x_2b1">See also: <literal
1578 role="hook">changegroup</literal> (<xref
1579 linkend="sec:hook:changegroup"/>), <literal
1580 role="hook">incoming</literal> (<xref
1581 linkend="sec:hook:incoming"/>), <literal
1582 role="hook">pretxnchangegroup</literal> (<xref
1583 linkend="sec:hook:pretxnchangegroup"/>)
1584 </para>
1585 </sect2>
1587 <sect2 id="sec:hook:precommit">
1588 <title><literal role="hook">precommit</literal>&emdash;before
1589 starting to commit a changeset</title>
1591 <para id="x_2b2">This hook is run before Mercurial begins to commit a new
1592 changeset. It is run before Mercurial has any of the metadata
1593 for the commit, such as the files to be committed, the commit
1594 message, or the commit date.
1595 </para>
1597 <para id="x_2b3">One use for this hook is to disable the ability to commit
1598 new changesets, while still allowing incoming changesets.
1599 Another is to run a build or test, and only allow the commit
1600 to begin if the build or test succeeds.
1601 </para>
1603 <para id="x_2b4">Parameters to this hook:
1604 </para>
1605 <itemizedlist>
1606 <listitem><para id="x_2b5"><literal>parent1</literal>: A changeset ID.
1607 The changeset ID of the first parent of the working
1608 directory.
1609 </para>
1610 </listitem>
1611 <listitem><para id="x_2b6"><literal>parent2</literal>: A changeset ID.
1612 The changeset ID of the second parent of the working
1613 directory.
1614 </para>
1615 </listitem></itemizedlist>
1616 <para id="x_2b7">If the commit proceeds, the parents of the working
1617 directory will become the parents of the new changeset.
1618 </para>
1620 <para id="x_2b8">See also: <literal role="hook">commit</literal>
1621 (<xref linkend="sec:hook:commit"/>), <literal
1622 role="hook">pretxncommit</literal> (<xref
1623 linkend="sec:hook:pretxncommit"/>)
1624 </para>
1625 </sect2>
1627 <sect2 id="sec:hook:preoutgoing">
1628 <title><literal role="hook">preoutgoing</literal>&emdash;before
1629 starting to propagate changesets</title>
1631 <para id="x_2b9">This hook is invoked before Mercurial knows the identities
1632 of the changesets to be transmitted.
1633 </para>
1635 <para id="x_2ba">One use for this hook is to prevent changes from being
1636 transmitted to another repository.
1637 </para>
1639 <para id="x_2bb">Parameters to this hook:
1640 </para>
1641 <itemizedlist>
1642 <listitem><para id="x_2bc"><literal>source</literal>: A
1643 string. The source of the operation that is attempting to
1644 obtain changes from this repository (see <xref
1645 linkend="sec:hook:sources"/>). See the documentation
1646 for the <literal>source</literal> parameter to the
1647 <literal role="hook">outgoing</literal> hook, in
1648 <xref linkend="sec:hook:outgoing"/>, for possible values
1649 of this parameter.
1650 </para>
1651 </listitem>
1652 <listitem><para id="x_2bd"><literal>url</literal>: A URL. The
1653 location of the remote repository, if known. See <xref
1654 linkend="sec:hook:url"/> for more information.
1655 </para>
1656 </listitem></itemizedlist>
1658 <para id="x_2be">See also: <literal
1659 role="hook">outgoing</literal> (<xref
1660 linkend="sec:hook:outgoing"/>)
1661 </para>
1662 </sect2>
1664 <sect2 id="sec:hook:pretag">
1665 <title><literal role="hook">pretag</literal>&emdash;before
1666 tagging a changeset</title>
1668 <para id="x_2bf">This controlling hook is run before a tag is created. If
1669 the hook succeeds, creation of the tag proceeds. If the hook
1670 fails, the tag is not created.
1671 </para>
1673 <para id="x_2c0">Parameters to this hook:
1674 </para>
1675 <itemizedlist>
1676 <listitem><para id="x_2c1"><literal>local</literal>: A boolean. Whether
1677 the tag is local to this repository instance (i.e. stored
1678 in <filename role="special">.hg/localtags</filename>) or
1679 managed by Mercurial (stored in <filename
1680 role="special">.hgtags</filename>).
1681 </para>
1682 </listitem>
1683 <listitem><para id="x_2c2"><literal>node</literal>: A changeset ID. The
1684 ID of the changeset to be tagged.
1685 </para>
1686 </listitem>
1687 <listitem><para id="x_2c3"><literal>tag</literal>: A string. The name of
1688 the tag to be created.
1689 </para>
1690 </listitem></itemizedlist>
1692 <para id="x_2c4">If the tag to be created is
1693 revision-controlled, the <literal
1694 role="hook">precommit</literal> and <literal
1695 role="hook">pretxncommit</literal> hooks (<xref
1696 linkend="sec:hook:commit"/> and <xref
1697 linkend="sec:hook:pretxncommit"/>) will also be run.
1698 </para>
1700 <para id="x_2c5">See also: <literal role="hook">tag</literal>
1701 (<xref linkend="sec:hook:tag"/>)
1702 </para>
1703 </sect2>
1705 <sect2 id="sec:hook:pretxnchangegroup">
1706 <title><literal
1707 role="hook">pretxnchangegroup</literal>&emdash;before
1708 completing addition of remote changesets</title>
1710 <para id="x_2c6">This controlling hook is run before a
1711 transaction&emdash;that manages the addition of a group of new
1712 changesets from outside the repository&emdash;completes. If
1713 the hook succeeds, the transaction completes, and all of the
1714 changesets become permanent within this repository. If the
1715 hook fails, the transaction is rolled back, and the data for
1716 the changesets is erased.
1717 </para>
1719 <para id="x_2c7">This hook can access the metadata associated with the
1720 almost-added changesets, but it should not do anything
1721 permanent with this data. It must also not modify the working
1722 directory.
1723 </para>
1725 <para id="x_2c8">While this hook is running, if other Mercurial processes
1726 access this repository, they will be able to see the
1727 almost-added changesets as if they are permanent. This may
1728 lead to race conditions if you do not take steps to avoid
1729 them.
1730 </para>
1732 <para id="x_2c9">This hook can be used to automatically vet a group of
1733 changesets. If the hook fails, all of the changesets are
1734 <quote>rejected</quote> when the transaction rolls back.
1735 </para>
1737 <para id="x_2ca">Parameters to this hook:
1738 </para>
1739 <itemizedlist>
1740 <listitem><para id="x_2cb"><literal>node</literal>: A changeset ID. The
1741 changeset ID of the first changeset in the group that was
1742 added. All changesets between this and
1743 <literal role="tag">tip</literal>,
1744 inclusive, were added by a single <command
1745 role="hg-cmd">hg pull</command>, <command
1746 role="hg-cmd">hg push</command> or <command
1747 role="hg-cmd">hg unbundle</command>.
1748 </para>
1749 </listitem>
1750 <listitem><para id="x_2cc"><literal>source</literal>: A
1751 string. The source of these changes. See <xref
1752 linkend="sec:hook:sources"/> for details.
1753 </para>
1754 </listitem>
1755 <listitem><para id="x_2cd"><literal>url</literal>: A URL. The
1756 location of the remote repository, if known. See <xref
1757 linkend="sec:hook:url"/> for more information.
1758 </para>
1759 </listitem></itemizedlist>
1761 <para id="x_2ce">See also: <literal
1762 role="hook">changegroup</literal> (<xref
1763 linkend="sec:hook:changegroup"/>), <literal
1764 role="hook">incoming</literal> (<xref
1765 linkend="sec:hook:incoming"/>), <literal
1766 role="hook">prechangegroup</literal> (<xref
1767 linkend="sec:hook:prechangegroup"/>)
1768 </para>
1769 </sect2>
1771 <sect2 id="sec:hook:pretxncommit">
1772 <title><literal role="hook">pretxncommit</literal>&emdash;before
1773 completing commit of new changeset</title>
1775 <para id="x_2cf">This controlling hook is run before a
1776 transaction&emdash;that manages a new commit&emdash;completes.
1777 If the hook succeeds, the transaction completes and the
1778 changeset becomes permanent within this repository. If the
1779 hook fails, the transaction is rolled back, and the commit
1780 data is erased.
1781 </para>
1783 <para id="x_2d0">This hook can access the metadata associated with the
1784 almost-new changeset, but it should not do anything permanent
1785 with this data. It must also not modify the working
1786 directory.
1787 </para>
1789 <para id="x_2d1">While this hook is running, if other Mercurial processes
1790 access this repository, they will be able to see the
1791 almost-new changeset as if it is permanent. This may lead to
1792 race conditions if you do not take steps to avoid them.
1793 </para>
1795 <para id="x_2d2">Parameters to this hook:</para>
1797 <itemizedlist>
1798 <listitem><para id="x_2d3"><literal>node</literal>: A changeset ID. The
1799 changeset ID of the newly committed changeset.
1800 </para>
1801 </listitem>
1802 <listitem><para id="x_2d4"><literal>parent1</literal>: A changeset ID.
1803 The changeset ID of the first parent of the newly
1804 committed changeset.
1805 </para>
1806 </listitem>
1807 <listitem><para id="x_2d5"><literal>parent2</literal>: A changeset ID.
1808 The changeset ID of the second parent of the newly
1809 committed changeset.
1810 </para>
1811 </listitem></itemizedlist>
1813 <para id="x_2d6">See also: <literal
1814 role="hook">precommit</literal> (<xref
1815 linkend="sec:hook:precommit"/>)
1816 </para>
1817 </sect2>
1819 <sect2 id="sec:hook:preupdate">
1820 <title><literal role="hook">preupdate</literal>&emdash;before
1821 updating or merging working directory</title>
1823 <para id="x_2d7">This controlling hook is run before an update
1824 or merge of the working directory begins. It is run only if
1825 Mercurial's normal pre-update checks determine that the update
1826 or merge can proceed. If the hook succeeds, the update or
1827 merge may proceed; if it fails, the update or merge does not
1828 start.
1829 </para>
1831 <para id="x_2d8">Parameters to this hook:
1832 </para>
1833 <itemizedlist>
1834 <listitem><para id="x_2d9"><literal>parent1</literal>: A
1835 changeset ID. The ID of the parent that the working
1836 directory is to be updated to. If the working directory
1837 is being merged, it will not change this parent.
1838 </para>
1839 </listitem>
1840 <listitem><para id="x_2da"><literal>parent2</literal>: A
1841 changeset ID. Only set if the working directory is being
1842 merged. The ID of the revision that the working directory
1843 is being merged with.
1844 </para>
1845 </listitem></itemizedlist>
1847 <para id="x_2db">See also: <literal role="hook">update</literal>
1848 (<xref linkend="sec:hook:update"/>)</para>
1849 </sect2>
1851 <sect2 id="sec:hook:tag">
1852 <title><literal role="hook">tag</literal>&emdash;after tagging a
1853 changeset</title>
1855 <para id="x_2dc">This hook is run after a tag has been created.
1856 </para>
1858 <para id="x_2dd">Parameters to this hook:
1859 </para>
1860 <itemizedlist>
1861 <listitem><para id="x_2de"><literal>local</literal>: A boolean. Whether
1862 the new tag is local to this repository instance (i.e.
1863 stored in <filename
1864 role="special">.hg/localtags</filename>) or managed by
1865 Mercurial (stored in <filename
1866 role="special">.hgtags</filename>).
1867 </para>
1868 </listitem>
1869 <listitem><para id="x_2df"><literal>node</literal>: A changeset ID. The
1870 ID of the changeset that was tagged.
1871 </para>
1872 </listitem>
1873 <listitem><para id="x_2e0"><literal>tag</literal>: A string. The name of
1874 the tag that was created.
1875 </para>
1876 </listitem></itemizedlist>
1878 <para id="x_2e1">If the created tag is revision-controlled, the <literal
1879 role="hook">commit</literal> hook (section <xref
1880 linkend="sec:hook:commit"/>) is run before this hook.
1881 </para>
1883 <para id="x_2e2">See also: <literal role="hook">pretag</literal>
1884 (<xref linkend="sec:hook:pretag"/>)
1885 </para>
1886 </sect2>
1888 <sect2 id="sec:hook:update">
1889 <title><literal role="hook">update</literal>&emdash;after
1890 updating or merging working directory</title>
1892 <para id="x_2e3">This hook is run after an update or merge of the working
1893 directory completes. Since a merge can fail (if the external
1894 <command>hgmerge</command> command fails to resolve conflicts
1895 in a file), this hook communicates whether the update or merge
1896 completed cleanly.
1897 </para>
1899 <itemizedlist>
1900 <listitem><para id="x_2e4"><literal>error</literal>: A boolean.
1901 Indicates whether the update or merge completed
1902 successfully.
1903 </para>
1904 </listitem>
1905 <listitem><para id="x_2e5"><literal>parent1</literal>: A changeset ID.
1906 The ID of the parent that the working directory was
1907 updated to. If the working directory was merged, it will
1908 not have changed this parent.
1909 </para>
1910 </listitem>
1911 <listitem><para id="x_2e6"><literal>parent2</literal>: A changeset ID.
1912 Only set if the working directory was merged. The ID of
1913 the revision that the working directory was merged with.
1914 </para>
1915 </listitem></itemizedlist>
1917 <para id="x_2e7">See also: <literal role="hook">preupdate</literal>
1918 (<xref linkend="sec:hook:preupdate"/>)
1919 </para>
1921 </sect2>
1922 </sect1>
1923 </chapter>
1925 <!--
1926 local variables:
1927 sgml-parent-document: ("00book.xml" "book" "chapter")
1928 end:
1929 -->