hgbook
view en/ch09-hook.xml @ 700:d2aacc06e562
Add more paragraph IDs
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sun May 03 20:27:28 2009 -0700 (2009-05-03) |
parents | ef53d025f410 |
children | 477d6a3e5023 |
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.ch09-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 &ch09-check_whitespace.py.lst;
574 <para id="x_236">The above version is much more complex, but also more
575 useful. It parses a unified diff to see if any lines add
576 trailing whitespace, and prints the name of the file and the
577 line number of each such occurrence. Even better, if the
578 change adds trailing whitespace, this hook saves the commit
579 comment and prints the name of the save file before exiting
580 and telling Mercurial to roll the transaction back, so you can
581 use the <option role="hg-opt-commit">-l filename</option>
582 option to <command role="hg-cmd">hg commit</command> to reuse
583 the saved commit message once you've corrected the problem.
584 </para>
586 &interaction.ch09-hook.ws.better;
588 <para id="x_237">As a final aside, note in the example above the use of
589 <command>perl</command>'s in-place editing feature to get rid
590 of trailing whitespace from a file. This is concise and
591 useful enough that I will reproduce it here.
592 </para>
593 <programlisting>perl -pi -e 's,\s+$,,' filename</programlisting>
595 </sect2>
596 </sect1>
597 <sect1>
598 <title>Bundled hooks</title>
600 <para id="x_238">Mercurial ships with several bundled hooks. You can find
601 them in the <filename class="directory">hgext</filename>
602 directory of a Mercurial source tree. If you are using a
603 Mercurial binary package, the hooks will be located in the
604 <filename class="directory">hgext</filename> directory of
605 wherever your package installer put Mercurial.
606 </para>
608 <sect2>
609 <title><literal role="hg-ext">acl</literal>&emdash;access
610 control for parts of a repository</title>
612 <para id="x_239">The <literal role="hg-ext">acl</literal> extension lets
613 you control which remote users are allowed to push changesets
614 to a networked server. You can protect any portion of a
615 repository (including the entire repo), so that a specific
616 remote user can push changes that do not affect the protected
617 portion.
618 </para>
620 <para id="x_23a">This extension implements access control based on the
621 identity of the user performing a push,
622 <emphasis>not</emphasis> on who committed the changesets
623 they're pushing. It makes sense to use this hook only if you
624 have a locked-down server environment that authenticates
625 remote users, and you want to be sure that only specific users
626 are allowed to push changes to that server.
627 </para>
629 <sect3>
630 <title>Configuring the <literal role="hook">acl</literal>
631 hook</title>
633 <para id="x_23b">In order to manage incoming changesets, the <literal
634 role="hg-ext">acl</literal> hook must be used as a
635 <literal role="hook">pretxnchangegroup</literal> hook. This
636 lets it see which files are modified by each incoming
637 changeset, and roll back a group of changesets if they
638 modify <quote>forbidden</quote> files. Example:
639 </para>
640 <programlisting>[hooks]
641 pretxnchangegroup.acl = python:hgext.acl.hook</programlisting>
643 <para id="x_23c">The <literal role="hg-ext">acl</literal> extension is
644 configured using three sections.
645 </para>
647 <para id="x_23d">The <literal role="rc-acl">acl</literal> section has
648 only one entry, <envar role="rc-item-acl">sources</envar>,
649 which lists the sources of incoming changesets that the hook
650 should pay attention to. You don't normally need to
651 configure this section.
652 </para>
653 <itemizedlist>
654 <listitem><para id="x_23e"><envar role="rc-item-acl">serve</envar>:
655 Control incoming changesets that are arriving from a
656 remote repository over http or ssh. This is the default
657 value of <envar role="rc-item-acl">sources</envar>, and
658 usually the only setting you'll need for this
659 configuration item.
660 </para>
661 </listitem>
662 <listitem><para id="x_23f"><envar role="rc-item-acl">pull</envar>:
663 Control incoming changesets that are arriving via a pull
664 from a local repository.
665 </para>
666 </listitem>
667 <listitem><para id="x_240"><envar role="rc-item-acl">push</envar>:
668 Control incoming changesets that are arriving via a push
669 from a local repository.
670 </para>
671 </listitem>
672 <listitem><para id="x_241"><envar role="rc-item-acl">bundle</envar>:
673 Control incoming changesets that are arriving from
674 another repository via a bundle.
675 </para>
676 </listitem></itemizedlist>
678 <para id="x_242">The <literal role="rc-acl.allow">acl.allow</literal>
679 section controls the users that are allowed to add
680 changesets to the repository. If this section is not
681 present, all users that are not explicitly denied are
682 allowed. If this section is present, all users that are not
683 explicitly allowed are denied (so an empty section means
684 that all users are denied).
685 </para>
687 <para id="x_243">The <literal role="rc-acl.deny">acl.deny</literal>
688 section determines which users are denied from adding
689 changesets to the repository. If this section is not
690 present or is empty, no users are denied.
691 </para>
693 <para id="x_244">The syntaxes for the <literal
694 role="rc-acl.allow">acl.allow</literal> and <literal
695 role="rc-acl.deny">acl.deny</literal> sections are
696 identical. On the left of each entry is a glob pattern that
697 matches files or directories, relative to the root of the
698 repository; on the right, a user name.
699 </para>
701 <para id="x_245">In the following example, the user
702 <literal>docwriter</literal> can only push changes to the
703 <filename class="directory">docs</filename> subtree of the
704 repository, while <literal>intern</literal> can push changes
705 to any file or directory except <filename
706 class="directory">source/sensitive</filename>.
707 </para>
708 <programlisting>[acl.allow]
709 docs/** = docwriter
710 [acl.deny]
711 source/sensitive/** = intern</programlisting>
713 </sect3>
714 <sect3>
715 <title>Testing and troubleshooting</title>
717 <para id="x_246">If you want to test the <literal
718 role="hg-ext">acl</literal> hook, run it with Mercurial's
719 debugging output enabled. Since you'll probably be running
720 it on a server where it's not convenient (or sometimes
721 possible) to pass in the <option
722 role="hg-opt-global">--debug</option> option, don't forget
723 that you can enable debugging output in your <filename
724 role="special">~/.hgrc</filename>:
725 </para>
726 <programlisting>[ui]
727 debug = true</programlisting>
728 <para id="x_247">With this enabled, the <literal
729 role="hg-ext">acl</literal> hook will print enough
730 information to let you figure out why it is allowing or
731 forbidding pushes from specific users.
732 </para>
734 </sect3> </sect2>
736 <sect2>
737 <title><literal
738 role="hg-ext">bugzilla</literal>&emdash;integration with
739 Bugzilla</title>
741 <para id="x_248">The <literal role="hg-ext">bugzilla</literal> extension
742 adds a comment to a Bugzilla bug whenever it finds a reference
743 to that bug ID in a commit comment. You can install this hook
744 on a shared server, so that any time a remote user pushes
745 changes to this server, the hook gets run.
746 </para>
748 <para id="x_249">It adds a comment to the bug that looks like this (you can
749 configure the contents of the comment&emdash;see below):
750 </para>
751 <programlisting>Changeset aad8b264143a, made by Joe User
752 <joe.user@domain.com> in the frobnitz repository, refers
753 to this bug. For complete details, see
754 http://hg.domain.com/frobnitz?cmd=changeset;node=aad8b264143a
755 Changeset description: Fix bug 10483 by guarding against some
756 NULL pointers</programlisting>
757 <para id="x_24a">The value of this hook is that it automates the process of
758 updating a bug any time a changeset refers to it. If you
759 configure the hook properly, it makes it easy for people to
760 browse straight from a Bugzilla bug to a changeset that refers
761 to that bug.
762 </para>
764 <para id="x_24b">You can use the code in this hook as a starting point for
765 some more exotic Bugzilla integration recipes. Here are a few
766 possibilities:
767 </para>
768 <itemizedlist>
769 <listitem><para id="x_24c">Require that every changeset pushed to the
770 server have a valid bug ID in its commit comment. In this
771 case, you'd want to configure the hook as a <literal
772 role="hook">pretxncommit</literal> hook. This would
773 allow the hook to reject changes that didn't contain bug
774 IDs.
775 </para>
776 </listitem>
777 <listitem><para id="x_24d">Allow incoming changesets to automatically
778 modify the <emphasis>state</emphasis> of a bug, as well as
779 simply adding a comment. For example, the hook could
780 recognise the string <quote>fixed bug 31337</quote> as
781 indicating that it should update the state of bug 31337 to
782 <quote>requires testing</quote>.
783 </para>
784 </listitem></itemizedlist>
786 <sect3 id="sec:hook:bugzilla:config">
787 <title>Configuring the <literal role="hook">bugzilla</literal>
788 hook</title>
790 <para id="x_24e">You should configure this hook in your server's
791 <filename role="special">~/.hgrc</filename> as an <literal
792 role="hook">incoming</literal> hook, for example as
793 follows:
794 </para>
795 <programlisting>[hooks]
796 incoming.bugzilla = python:hgext.bugzilla.hook</programlisting>
798 <para id="x_24f">Because of the specialised nature of this hook, and
799 because Bugzilla was not written with this kind of
800 integration in mind, configuring this hook is a somewhat
801 involved process.
802 </para>
804 <para id="x_250">Before you begin, you must install the MySQL bindings
805 for Python on the host(s) where you'll be running the hook.
806 If this is not available as a binary package for your
807 system, you can download it from
808 <citation>web:mysql-python</citation>.
809 </para>
811 <para id="x_251">Configuration information for this hook lives in the
812 <literal role="rc-bugzilla">bugzilla</literal> section of
813 your <filename role="special">~/.hgrc</filename>.
814 </para>
815 <itemizedlist>
816 <listitem><para id="x_252"><envar
817 role="rc-item-bugzilla">version</envar>: The version
818 of Bugzilla installed on the server. The database
819 schema that Bugzilla uses changes occasionally, so this
820 hook has to know exactly which schema to use. At the
821 moment, the only version supported is
822 <literal>2.16</literal>.
823 </para>
824 </listitem>
825 <listitem><para id="x_253"><envar role="rc-item-bugzilla">host</envar>:
826 The hostname of the MySQL server that stores your
827 Bugzilla data. The database must be configured to allow
828 connections from whatever host you are running the
829 <literal role="hook">bugzilla</literal> hook on.
830 </para>
831 </listitem>
832 <listitem><para id="x_254"><envar role="rc-item-bugzilla">user</envar>:
833 The username with which to connect to the MySQL server.
834 The database must be configured to allow this user to
835 connect from whatever host you are running the <literal
836 role="hook">bugzilla</literal> hook on. This user
837 must be able to access and modify Bugzilla tables. The
838 default value of this item is <literal>bugs</literal>,
839 which is the standard name of the Bugzilla user in a
840 MySQL database.
841 </para>
842 </listitem>
843 <listitem><para id="x_255"><envar
844 role="rc-item-bugzilla">password</envar>: The MySQL
845 password for the user you configured above. This is
846 stored as plain text, so you should make sure that
847 unauthorised users cannot read the <filename
848 role="special">~/.hgrc</filename> file where you
849 store this information.
850 </para>
851 </listitem>
852 <listitem><para id="x_256"><envar role="rc-item-bugzilla">db</envar>:
853 The name of the Bugzilla database on the MySQL server.
854 The default value of this item is
855 <literal>bugs</literal>, which is the standard name of
856 the MySQL database where Bugzilla stores its data.
857 </para>
858 </listitem>
859 <listitem><para id="x_257"><envar
860 role="rc-item-bugzilla">notify</envar>: If you want
861 Bugzilla to send out a notification email to subscribers
862 after this hook has added a comment to a bug, you will
863 need this hook to run a command whenever it updates the
864 database. The command to run depends on where you have
865 installed Bugzilla, but it will typically look something
866 like this, if you have Bugzilla installed in <filename
867 class="directory">/var/www/html/bugzilla</filename>:
868 </para>
869 <programlisting>cd /var/www/html/bugzilla &&
870 ./processmail %s nobody@nowhere.com</programlisting>
871 </listitem>
872 <listitem><para id="x_258"> The Bugzilla
873 <literal>processmail</literal> program expects to be
874 given a bug ID (the hook replaces
875 <quote><literal>%s</literal></quote> with the bug ID)
876 and an email address. It also expects to be able to
877 write to some files in the directory that it runs in.
878 If Bugzilla and this hook are not installed on the same
879 machine, you will need to find a way to run
880 <literal>processmail</literal> on the server where
881 Bugzilla is installed.
882 </para>
883 </listitem></itemizedlist>
885 </sect3>
886 <sect3>
887 <title>Mapping committer names to Bugzilla user names</title>
889 <para id="x_259">By default, the <literal
890 role="hg-ext">bugzilla</literal> hook tries to use the
891 email address of a changeset's committer as the Bugzilla
892 user name with which to update a bug. If this does not suit
893 your needs, you can map committer email addresses to
894 Bugzilla user names using a <literal
895 role="rc-usermap">usermap</literal> section.
896 </para>
898 <para id="x_25a">Each item in the <literal
899 role="rc-usermap">usermap</literal> section contains an
900 email address on the left, and a Bugzilla user name on the
901 right.
902 </para>
903 <programlisting>[usermap]
904 jane.user@example.com = jane</programlisting>
905 <para id="x_25b">You can either keep the <literal
906 role="rc-usermap">usermap</literal> data in a normal
907 <filename role="special">~/.hgrc</filename>, or tell the
908 <literal role="hg-ext">bugzilla</literal> hook to read the
909 information from an external <filename>usermap</filename>
910 file. In the latter case, you can store
911 <filename>usermap</filename> data by itself in (for example)
912 a user-modifiable repository. This makes it possible to let
913 your users maintain their own <envar
914 role="rc-item-bugzilla">usermap</envar> entries. The main
915 <filename role="special">~/.hgrc</filename> file might look
916 like this:
917 </para>
918 <programlisting># regular hgrc file refers to external usermap file
919 [bugzilla]
920 usermap = /home/hg/repos/userdata/bugzilla-usermap.conf</programlisting>
921 <para id="x_25c">While the <filename>usermap</filename> file that it
922 refers to might look like this:
923 </para>
924 <programlisting># bugzilla-usermap.conf - inside a hg repository
925 [usermap] stephanie@example.com = steph</programlisting>
927 </sect3>
928 <sect3>
929 <title>Configuring the text that gets added to a bug</title>
931 <para id="x_25d">You can configure the text that this hook adds as a
932 comment; you specify it in the form of a Mercurial template.
933 Several <filename role="special">~/.hgrc</filename> entries
934 (still in the <literal role="rc-bugzilla">bugzilla</literal>
935 section) control this behavior.
936 </para>
937 <itemizedlist>
938 <listitem><para id="x_25e"><literal>strip</literal>: The number of
939 leading path elements to strip from a repository's path
940 name to construct a partial path for a URL. For example,
941 if the repositories on your server live under <filename
942 class="directory">/home/hg/repos</filename>, and you
943 have a repository whose path is <filename
944 class="directory">/home/hg/repos/app/tests</filename>,
945 then setting <literal>strip</literal> to
946 <literal>4</literal> will give a partial path of
947 <filename class="directory">app/tests</filename>. The
948 hook will make this partial path available when
949 expanding a template, as <literal>webroot</literal>.
950 </para>
951 </listitem>
952 <listitem><para id="x_25f"><literal>template</literal>: The text of the
953 template to use. In addition to the usual
954 changeset-related variables, this template can use
955 <literal>hgweb</literal> (the value of the
956 <literal>hgweb</literal> configuration item above) and
957 <literal>webroot</literal> (the path constructed using
958 <literal>strip</literal> above).
959 </para>
960 </listitem></itemizedlist>
962 <para id="x_260">In addition, you can add a <envar
963 role="rc-item-web">baseurl</envar> item to the <literal
964 role="rc-web">web</literal> section of your <filename
965 role="special">~/.hgrc</filename>. The <literal
966 role="hg-ext">bugzilla</literal> hook will make this
967 available when expanding a template, as the base string to
968 use when constructing a URL that will let users browse from
969 a Bugzilla comment to view a changeset. Example:
970 </para>
971 <programlisting>[web]
972 baseurl = http://hg.domain.com/</programlisting>
974 <para id="x_261">Here is an example set of <literal
975 role="hg-ext">bugzilla</literal> hook config information.
976 </para>
978 &ch10-bugzilla-config.lst;
980 </sect3>
981 <sect3>
982 <title>Testing and troubleshooting</title>
984 <para id="x_262">The most common problems with configuring the <literal
985 role="hg-ext">bugzilla</literal> hook relate to running
986 Bugzilla's <filename>processmail</filename> script and
987 mapping committer names to user names.
988 </para>
990 <para id="x_263">Recall from <xref
991 linkend="sec:hook:bugzilla:config"/> above that the user
992 that runs the Mercurial process on the server is also the
993 one that will run the <filename>processmail</filename>
994 script. The <filename>processmail</filename> script
995 sometimes causes Bugzilla to write to files in its
996 configuration directory, and Bugzilla's configuration files
997 are usually owned by the user that your web server runs
998 under.
999 </para>
1001 <para id="x_264">You can cause <filename>processmail</filename> to be run
1002 with the suitable user's identity using the
1003 <command>sudo</command> command. Here is an example entry
1004 for a <filename>sudoers</filename> file.
1005 </para>
1006 <programlisting>hg_user = (httpd_user)
1007 NOPASSWD: /var/www/html/bugzilla/processmail-wrapper %s</programlisting>
1008 <para id="x_265">This allows the <literal>hg_user</literal> user to run a
1009 <filename>processmail-wrapper</filename> program under the
1010 identity of <literal>httpd_user</literal>.
1011 </para>
1013 <para id="x_266">This indirection through a wrapper script is necessary,
1014 because <filename>processmail</filename> expects to be run
1015 with its current directory set to wherever you installed
1016 Bugzilla; you can't specify that kind of constraint in a
1017 <filename>sudoers</filename> file. The contents of the
1018 wrapper script are simple:
1019 </para>
1020 <programlisting>#!/bin/sh
1021 cd `dirname $0` && ./processmail "$1" nobody@example.com</programlisting>
1022 <para id="x_267">It doesn't seem to matter what email address you pass to
1023 <filename>processmail</filename>.
1024 </para>
1026 <para id="x_268">If your <literal role="rc-usermap">usermap</literal> is
1027 not set up correctly, users will see an error message from
1028 the <literal role="hg-ext">bugzilla</literal> hook when they
1029 push changes to the server. The error message will look
1030 like this:
1031 </para>
1032 <programlisting>cannot find bugzilla user id for john.q.public@example.com</programlisting>
1033 <para id="x_269">What this means is that the committer's address,
1034 <literal>john.q.public@example.com</literal>, is not a valid
1035 Bugzilla user name, nor does it have an entry in your
1036 <literal role="rc-usermap">usermap</literal> that maps it to
1037 a valid Bugzilla user name.
1038 </para>
1040 </sect3> </sect2>
1042 <sect2>
1043 <title><literal role="hg-ext">notify</literal>&emdash;send email
1044 notifications</title>
1046 <para id="x_26a">Although Mercurial's built-in web server provides RSS
1047 feeds of changes in every repository, many people prefer to
1048 receive change notifications via email. The <literal
1049 role="hg-ext">notify</literal> hook lets you send out
1050 notifications to a set of email addresses whenever changesets
1051 arrive that those subscribers are interested in.
1052 </para>
1054 <para id="x_26b">As with the <literal role="hg-ext">bugzilla</literal>
1055 hook, the <literal role="hg-ext">notify</literal> hook is
1056 template-driven, so you can customise the contents of the
1057 notification messages that it sends.
1058 </para>
1060 <para id="x_26c">By default, the <literal role="hg-ext">notify</literal>
1061 hook includes a diff of every changeset that it sends out; you
1062 can limit the size of the diff, or turn this feature off
1063 entirely. It is useful for letting subscribers review changes
1064 immediately, rather than clicking to follow a URL.
1065 </para>
1067 <sect3>
1068 <title>Configuring the <literal role="hg-ext">notify</literal>
1069 hook</title>
1071 <para id="x_26d">You can set up the <literal
1072 role="hg-ext">notify</literal> hook to send one email
1073 message per incoming changeset, or one per incoming group of
1074 changesets (all those that arrived in a single pull or
1075 push).
1076 </para>
1077 <programlisting>[hooks]
1078 # send one email per group of changes
1079 changegroup.notify = python:hgext.notify.hook
1080 # send one email per change
1081 incoming.notify = python:hgext.notify.hook</programlisting>
1083 <para id="x_26e">Configuration information for this hook lives in the
1084 <literal role="rc-notify">notify</literal> section of a
1085 <filename role="special">~/.hgrc</filename> file.
1086 </para>
1087 <itemizedlist>
1088 <listitem><para id="x_26f"><envar role="rc-item-notify">test</envar>:
1089 By default, this hook does not send out email at all;
1090 instead, it prints the message that it
1091 <emphasis>would</emphasis> send. Set this item to
1092 <literal>false</literal> to allow email to be sent. The
1093 reason that sending of email is turned off by default is
1094 that it takes several tries to configure this extension
1095 exactly as you would like, and it would be bad form to
1096 spam subscribers with a number of <quote>broken</quote>
1097 notifications while you debug your configuration.
1098 </para>
1099 </listitem>
1100 <listitem><para id="x_270"><envar role="rc-item-notify">config</envar>:
1101 The path to a configuration file that contains
1102 subscription information. This is kept separate from
1103 the main <filename role="special">~/.hgrc</filename> so
1104 that you can maintain it in a repository of its own.
1105 People can then clone that repository, update their
1106 subscriptions, and push the changes back to your server.
1107 </para>
1108 </listitem>
1109 <listitem><para id="x_271"><envar role="rc-item-notify">strip</envar>:
1110 The number of leading path separator characters to strip
1111 from a repository's path, when deciding whether a
1112 repository has subscribers. For example, if the
1113 repositories on your server live in <filename
1114 class="directory">/home/hg/repos</filename>, and
1115 <literal role="hg-ext">notify</literal> is considering a
1116 repository named <filename
1117 class="directory">/home/hg/repos/shared/test</filename>,
1118 setting <envar role="rc-item-notify">strip</envar> to
1119 <literal>4</literal> will cause <literal
1120 role="hg-ext">notify</literal> to trim the path it
1121 considers down to <filename
1122 class="directory">shared/test</filename>, and it will
1123 match subscribers against that.
1124 </para>
1125 </listitem>
1126 <listitem><para id="x_272"><envar
1127 role="rc-item-notify">template</envar>: The template
1128 text to use when sending messages. This specifies both
1129 the contents of the message header and its body.
1130 </para>
1131 </listitem>
1132 <listitem><para id="x_273"><envar
1133 role="rc-item-notify">maxdiff</envar>: The maximum
1134 number of lines of diff data to append to the end of a
1135 message. If a diff is longer than this, it is
1136 truncated. By default, this is set to 300. Set this to
1137 <literal>0</literal> to omit diffs from notification
1138 emails.
1139 </para>
1140 </listitem>
1141 <listitem><para id="x_274"><envar
1142 role="rc-item-notify">sources</envar>: A list of
1143 sources of changesets to consider. This lets you limit
1144 <literal role="hg-ext">notify</literal> to only sending
1145 out email about changes that remote users pushed into
1146 this repository via a server, for example. See
1147 <xref linkend="sec:hook:sources"/> for the sources you
1148 can specify here.
1149 </para>
1150 </listitem></itemizedlist>
1152 <para id="x_275">If you set the <envar role="rc-item-web">baseurl</envar>
1153 item in the <literal role="rc-web">web</literal> section,
1154 you can use it in a template; it will be available as
1155 <literal>webroot</literal>.
1156 </para>
1158 <para id="x_276">Here is an example set of <literal
1159 role="hg-ext">notify</literal> configuration information.
1160 </para>
1162 &ch10-notify-config.lst;
1164 <para id="x_277">This will produce a message that looks like the
1165 following:
1166 </para>
1168 &ch10-notify-config-mail.lst;
1170 </sect3>
1171 <sect3>
1172 <title>Testing and troubleshooting</title>
1174 <para id="x_278">Do not forget that by default, the <literal
1175 role="hg-ext">notify</literal> extension <emphasis>will not
1176 send any mail</emphasis> until you explicitly configure it to do so,
1177 by setting <envar role="rc-item-notify">test</envar> to
1178 <literal>false</literal>. Until you do that, it simply
1179 prints the message it <emphasis>would</emphasis> send.
1180 </para>
1182 </sect3>
1183 </sect2>
1184 </sect1>
1185 <sect1 id="sec:hook:ref">
1186 <title>Information for writers of hooks</title>
1188 <sect2>
1189 <title>In-process hook execution</title>
1191 <para id="x_279">An in-process hook is called with arguments of the
1192 following form:
1193 </para>
1194 <programlisting>def myhook(ui, repo, **kwargs): pass</programlisting>
1195 <para id="x_27a">The <literal>ui</literal> parameter is a <literal
1196 role="py-mod-mercurial.ui">ui</literal> object. The
1197 <literal>repo</literal> parameter is a <literal
1198 role="py-mod-mercurial.localrepo">localrepository</literal>
1199 object. The names and values of the
1200 <literal>**kwargs</literal> parameters depend on the hook
1201 being invoked, with the following common features:
1202 </para>
1203 <itemizedlist>
1204 <listitem><para id="x_27b">If a parameter is named
1205 <literal>node</literal> or <literal>parentN</literal>, it
1206 will contain a hexadecimal changeset ID. The empty string
1207 is used to represent <quote>null changeset ID</quote>
1208 instead of a string of zeroes.
1209 </para>
1210 </listitem>
1211 <listitem><para id="x_27c">If a parameter is named
1212 <literal>url</literal>, it will contain the URL of a
1213 remote repository, if that can be determined.
1214 </para>
1215 </listitem>
1216 <listitem><para id="x_27d">Boolean-valued parameters are represented as
1217 Python <literal>bool</literal> objects.
1218 </para>
1219 </listitem></itemizedlist>
1221 <para id="x_27e">An in-process hook is called without a change to the
1222 process's working directory (unlike external hooks, which are
1223 run in the root of the repository). It must not change the
1224 process's working directory, or it will cause any calls it
1225 makes into the Mercurial API to fail.
1226 </para>
1228 <para id="x_27f">If a hook returns a boolean <quote>false</quote> value, it
1229 is considered to have succeeded. If it returns a boolean
1230 <quote>true</quote> value or raises an exception, it is
1231 considered to have failed. A useful way to think of the
1232 calling convention is <quote>tell me if you fail</quote>.
1233 </para>
1235 <para id="x_280">Note that changeset IDs are passed into Python hooks as
1236 hexadecimal strings, not the binary hashes that Mercurial's
1237 APIs normally use. To convert a hash from hex to binary, use
1238 the <literal>bin</literal> function.
1239 </para>
1240 </sect2>
1242 <sect2>
1243 <title>External hook execution</title>
1245 <para id="x_281">An external hook is passed to the shell of the user
1246 running Mercurial. Features of that shell, such as variable
1247 substitution and command redirection, are available. The hook
1248 is run in the root directory of the repository (unlike
1249 in-process hooks, which are run in the same directory that
1250 Mercurial was run in).
1251 </para>
1253 <para id="x_282">Hook parameters are passed to the hook as environment
1254 variables. Each environment variable's name is converted in
1255 upper case and prefixed with the string
1256 <quote><literal>HG_</literal></quote>. For example, if the
1257 name of a parameter is <quote><literal>node</literal></quote>,
1258 the name of the environment variable representing that
1259 parameter will be <quote><literal>HG_NODE</literal></quote>.
1260 </para>
1262 <para id="x_283">A boolean parameter is represented as the string
1263 <quote><literal>1</literal></quote> for <quote>true</quote>,
1264 <quote><literal>0</literal></quote> for <quote>false</quote>.
1265 If an environment variable is named <envar>HG_NODE</envar>,
1266 <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it
1267 contains a changeset ID represented as a hexadecimal string.
1268 The empty string is used to represent <quote>null changeset
1269 ID</quote> instead of a string of zeroes. If an environment
1270 variable is named <envar>HG_URL</envar>, it will contain the
1271 URL of a remote repository, if that can be determined.
1272 </para>
1274 <para id="x_284">If a hook exits with a status of zero, it is considered to
1275 have succeeded. If it exits with a non-zero status, it is
1276 considered to have failed.
1277 </para>
1278 </sect2>
1280 <sect2>
1281 <title>Finding out where changesets come from</title>
1283 <para id="x_285">A hook that involves the transfer of changesets between a
1284 local repository and another may be able to find out
1285 information about the <quote>far side</quote>. Mercurial
1286 knows <emphasis>how</emphasis> changes are being transferred,
1287 and in many cases <emphasis>where</emphasis> they are being
1288 transferred to or from.
1289 </para>
1291 <sect3 id="sec:hook:sources">
1292 <title>Sources of changesets</title>
1294 <para id="x_286">Mercurial will tell a hook what means are, or were, used
1295 to transfer changesets between repositories. This is
1296 provided by Mercurial in a Python parameter named
1297 <literal>source</literal>, or an environment variable named
1298 <envar>HG_SOURCE</envar>.
1299 </para>
1301 <itemizedlist>
1302 <listitem><para id="x_287"><literal>serve</literal>: Changesets are
1303 transferred to or from a remote repository over http or
1304 ssh.
1305 </para>
1306 </listitem>
1307 <listitem><para id="x_288"><literal>pull</literal>: Changesets are
1308 being transferred via a pull from one repository into
1309 another.
1310 </para>
1311 </listitem>
1312 <listitem><para id="x_289"><literal>push</literal>: Changesets are
1313 being transferred via a push from one repository into
1314 another.
1315 </para>
1316 </listitem>
1317 <listitem><para id="x_28a"><literal>bundle</literal>: Changesets are
1318 being transferred to or from a bundle.
1319 </para>
1320 </listitem></itemizedlist>
1321 </sect3>
1323 <sect3 id="sec:hook:url">
1324 <title>Where changes are going&emdash;remote repository
1325 URLs</title>
1327 <para id="x_28b">When possible, Mercurial will tell a hook the location
1328 of the <quote>far side</quote> of an activity that transfers
1329 changeset data between repositories. This is provided by
1330 Mercurial in a Python parameter named
1331 <literal>url</literal>, or an environment variable named
1332 <envar>HG_URL</envar>.
1333 </para>
1335 <para id="x_28c">This information is not always known. If a hook is
1336 invoked in a repository that is being served via http or
1337 ssh, Mercurial cannot tell where the remote repository is,
1338 but it may know where the client is connecting from. In
1339 such cases, the URL will take one of the following forms:
1340 </para>
1341 <itemizedlist>
1342 <listitem><para id="x_28d"><literal>remote:ssh:1.2.3.4</literal>&emdash;remote
1343 ssh client, at the IP address
1344 <literal>1.2.3.4</literal>.
1345 </para>
1346 </listitem>
1347 <listitem><para id="x_28e"><literal>remote:http:1.2.3.4</literal>&emdash;remote
1348 http client, at the IP address
1349 <literal>1.2.3.4</literal>. If the client is using SSL,
1350 this will be of the form
1351 <literal>remote:https:1.2.3.4</literal>.
1352 </para>
1353 </listitem>
1354 <listitem><para id="x_28f">Empty&emdash;no information could be
1355 discovered about the remote client.
1356 </para>
1357 </listitem></itemizedlist>
1358 </sect3>
1359 </sect2>
1360 </sect1>
1361 <sect1>
1362 <title>Hook reference</title>
1364 <sect2 id="sec:hook:changegroup">
1365 <title><literal role="hook">changegroup</literal>&emdash;after
1366 remote changesets added</title>
1368 <para id="x_290">This hook is run after a group of pre-existing changesets
1369 has been added to the repository, for example via a <command
1370 role="hg-cmd">hg pull</command> or <command role="hg-cmd">hg
1371 unbundle</command>. This hook is run once per operation
1372 that added one or more changesets. This is in contrast to the
1373 <literal role="hook">incoming</literal> hook, which is run
1374 once per changeset, regardless of whether the changesets
1375 arrive in a group.
1376 </para>
1378 <para id="x_291">Some possible uses for this hook include kicking off an
1379 automated build or test of the added changesets, updating a
1380 bug database, or notifying subscribers that a repository
1381 contains new changes.
1382 </para>
1384 <para id="x_292">Parameters to this hook:
1385 </para>
1386 <itemizedlist>
1387 <listitem><para id="x_293"><literal>node</literal>: A changeset ID. The
1388 changeset ID of the first changeset in the group that was
1389 added. All changesets between this and
1390 <literal role="tag">tip</literal>, inclusive, were added by a single
1391 <command role="hg-cmd">hg pull</command>, <command
1392 role="hg-cmd">hg push</command> or <command
1393 role="hg-cmd">hg unbundle</command>.
1394 </para>
1395 </listitem>
1396 <listitem><para id="x_294"><literal>source</literal>: A
1397 string. The source of these changes. See <xref
1398 linkend="sec:hook:sources"/> for details.
1399 </para>
1400 </listitem>
1401 <listitem><para id="x_295"><literal>url</literal>: A URL. The
1402 location of the remote repository, if known. See <xref
1403 linkend="sec:hook:url"/> for more information.
1404 </para>
1405 </listitem></itemizedlist>
1407 <para id="x_296">See also: <literal
1408 role="hook">incoming</literal> (<xref
1409 linkend="sec:hook:incoming"/>), <literal
1410 role="hook">prechangegroup</literal> (<xref
1411 linkend="sec:hook:prechangegroup"/>), <literal
1412 role="hook">pretxnchangegroup</literal> (<xref
1413 linkend="sec:hook:pretxnchangegroup"/>)
1414 </para>
1415 </sect2>
1417 <sect2 id="sec:hook:commit">
1418 <title><literal role="hook">commit</literal>&emdash;after a new
1419 changeset is created</title>
1421 <para id="x_297">This hook is run after a new changeset has been created.
1422 </para>
1424 <para id="x_298">Parameters to this hook:
1425 </para>
1426 <itemizedlist>
1427 <listitem><para id="x_299"><literal>node</literal>: A changeset ID. The
1428 changeset ID of the newly committed changeset.
1429 </para>
1430 </listitem>
1431 <listitem><para id="x_29a"><literal>parent1</literal>: A changeset ID.
1432 The changeset ID of the first parent of the newly
1433 committed changeset.
1434 </para>
1435 </listitem>
1436 <listitem><para id="x_29b"><literal>parent2</literal>: A changeset ID.
1437 The changeset ID of the second parent of the newly
1438 committed changeset.
1439 </para>
1440 </listitem></itemizedlist>
1442 <para id="x_29c">See also: <literal
1443 role="hook">precommit</literal> (<xref
1444 linkend="sec:hook:precommit"/>), <literal
1445 role="hook">pretxncommit</literal> (<xref
1446 linkend="sec:hook:pretxncommit"/>)
1447 </para>
1448 </sect2>
1450 <sect2 id="sec:hook:incoming">
1451 <title><literal role="hook">incoming</literal>&emdash;after one
1452 remote changeset is added</title>
1454 <para id="x_29d">This hook is run after a pre-existing changeset has been
1455 added to the repository, for example via a <command
1456 role="hg-cmd">hg push</command>. If a group of changesets
1457 was added in a single operation, this hook is called once for
1458 each added changeset.
1459 </para>
1461 <para id="x_29e">You can use this hook for the same purposes as
1462 the <literal role="hook">changegroup</literal> hook (<xref
1463 linkend="sec:hook:changegroup"/>); it's simply more
1464 convenient sometimes to run a hook once per group of
1465 changesets, while other times it's handier once per changeset.
1466 </para>
1468 <para id="x_29f">Parameters to this hook:
1469 </para>
1470 <itemizedlist>
1471 <listitem><para id="x_2a0"><literal>node</literal>: A changeset ID. The
1472 ID of the newly added changeset.
1473 </para>
1474 </listitem>
1475 <listitem><para id="x_2a1"><literal>source</literal>: A
1476 string. The source of these changes. See <xref
1477 linkend="sec:hook:sources"/> for details.
1478 </para>
1479 </listitem>
1480 <listitem><para id="x_2a2"><literal>url</literal>: A URL. The
1481 location of the remote repository, if known. See <xref
1482 linkend="sec:hook:url"/> for more information.
1483 </para>
1484 </listitem></itemizedlist>
1486 <para id="x_2a3">See also: <literal
1487 role="hook">changegroup</literal> (<xref
1488 linkend="sec:hook:changegroup"/>) <literal
1489 role="hook">prechangegroup</literal> (<xref
1490 linkend="sec:hook:prechangegroup"/>), <literal
1491 role="hook">pretxnchangegroup</literal> (<xref
1492 linkend="sec:hook:pretxnchangegroup"/>)
1493 </para>
1494 </sect2>
1496 <sect2 id="sec:hook:outgoing">
1497 <title><literal role="hook">outgoing</literal>&emdash;after
1498 changesets are propagated</title>
1500 <para id="x_2a4">This hook is run after a group of changesets has been
1501 propagated out of this repository, for example by a <command
1502 role="hg-cmd">hg push</command> or <command role="hg-cmd">hg
1503 bundle</command> command.
1504 </para>
1506 <para id="x_2a5">One possible use for this hook is to notify administrators
1507 that changes have been pulled.
1508 </para>
1510 <para id="x_2a6">Parameters to this hook:
1511 </para>
1512 <itemizedlist>
1513 <listitem><para id="x_2a7"><literal>node</literal>: A changeset ID. The
1514 changeset ID of the first changeset of the group that was
1515 sent.
1516 </para>
1517 </listitem>
1518 <listitem><para id="x_2a8"><literal>source</literal>: A string. The
1519 source of the of the operation (see <xref
1520 linkend="sec:hook:sources"/>). If a remote
1521 client pulled changes from this repository,
1522 <literal>source</literal> will be
1523 <literal>serve</literal>. If the client that obtained
1524 changes from this repository was local,
1525 <literal>source</literal> will be
1526 <literal>bundle</literal>, <literal>pull</literal>, or
1527 <literal>push</literal>, depending on the operation the
1528 client performed.
1529 </para>
1530 </listitem>
1531 <listitem><para id="x_2a9"><literal>url</literal>: A URL. The
1532 location of the remote repository, if known. See <xref
1533 linkend="sec:hook:url"/> for more information.
1534 </para>
1535 </listitem></itemizedlist>
1537 <para id="x_2aa">See also: <literal
1538 role="hook">preoutgoing</literal> (<xref
1539 linkend="sec:hook:preoutgoing"/>)
1540 </para>
1541 </sect2>
1543 <sect2 id="sec:hook:prechangegroup">
1544 <title><literal
1545 role="hook">prechangegroup</literal>&emdash;before starting
1546 to add remote changesets</title>
1548 <para id="x_2ab">This controlling hook is run before Mercurial begins to
1549 add a group of changesets from another repository.
1550 </para>
1552 <para id="x_2ac">This hook does not have any information about the
1553 changesets to be added, because it is run before transmission
1554 of those changesets is allowed to begin. If this hook fails,
1555 the changesets will not be transmitted.
1556 </para>
1558 <para id="x_2ad">One use for this hook is to prevent external changes from
1559 being added to a repository. For example, you could use this
1560 to <quote>freeze</quote> a server-hosted branch temporarily or
1561 permanently so that users cannot push to it, while still
1562 allowing a local administrator to modify the repository.
1563 </para>
1565 <para id="x_2ae">Parameters to this hook:
1566 </para>
1567 <itemizedlist>
1568 <listitem><para id="x_2af"><literal>source</literal>: A string. The
1569 source of these changes. See <xref
1570 linkend="sec:hook:sources"/> for details.
1571 </para>
1572 </listitem>
1573 <listitem><para id="x_2b0"><literal>url</literal>: A URL. The
1574 location of the remote repository, if known. See <xref
1575 linkend="sec:hook:url"/> for more information.
1576 </para>
1577 </listitem></itemizedlist>
1579 <para id="x_2b1">See also: <literal
1580 role="hook">changegroup</literal> (<xref
1581 linkend="sec:hook:changegroup"/>), <literal
1582 role="hook">incoming</literal> (<xref
1583 linkend="sec:hook:incoming"/>), <literal
1584 role="hook">pretxnchangegroup</literal> (<xref
1585 linkend="sec:hook:pretxnchangegroup"/>)
1586 </para>
1587 </sect2>
1589 <sect2 id="sec:hook:precommit">
1590 <title><literal role="hook">precommit</literal>&emdash;before
1591 starting to commit a changeset</title>
1593 <para id="x_2b2">This hook is run before Mercurial begins to commit a new
1594 changeset. It is run before Mercurial has any of the metadata
1595 for the commit, such as the files to be committed, the commit
1596 message, or the commit date.
1597 </para>
1599 <para id="x_2b3">One use for this hook is to disable the ability to commit
1600 new changesets, while still allowing incoming changesets.
1601 Another is to run a build or test, and only allow the commit
1602 to begin if the build or test succeeds.
1603 </para>
1605 <para id="x_2b4">Parameters to this hook:
1606 </para>
1607 <itemizedlist>
1608 <listitem><para id="x_2b5"><literal>parent1</literal>: A changeset ID.
1609 The changeset ID of the first parent of the working
1610 directory.
1611 </para>
1612 </listitem>
1613 <listitem><para id="x_2b6"><literal>parent2</literal>: A changeset ID.
1614 The changeset ID of the second parent of the working
1615 directory.
1616 </para>
1617 </listitem></itemizedlist>
1618 <para id="x_2b7">If the commit proceeds, the parents of the working
1619 directory will become the parents of the new changeset.
1620 </para>
1622 <para id="x_2b8">See also: <literal role="hook">commit</literal>
1623 (<xref linkend="sec:hook:commit"/>), <literal
1624 role="hook">pretxncommit</literal> (<xref
1625 linkend="sec:hook:pretxncommit"/>)
1626 </para>
1627 </sect2>
1629 <sect2 id="sec:hook:preoutgoing">
1630 <title><literal role="hook">preoutgoing</literal>&emdash;before
1631 starting to propagate changesets</title>
1633 <para id="x_2b9">This hook is invoked before Mercurial knows the identities
1634 of the changesets to be transmitted.
1635 </para>
1637 <para id="x_2ba">One use for this hook is to prevent changes from being
1638 transmitted to another repository.
1639 </para>
1641 <para id="x_2bb">Parameters to this hook:
1642 </para>
1643 <itemizedlist>
1644 <listitem><para id="x_2bc"><literal>source</literal>: A
1645 string. The source of the operation that is attempting to
1646 obtain changes from this repository (see <xref
1647 linkend="sec:hook:sources"/>). See the documentation
1648 for the <literal>source</literal> parameter to the
1649 <literal role="hook">outgoing</literal> hook, in
1650 <xref linkend="sec:hook:outgoing"/>, for possible values
1651 of this parameter.
1652 </para>
1653 </listitem>
1654 <listitem><para id="x_2bd"><literal>url</literal>: A URL. The
1655 location of the remote repository, if known. See <xref
1656 linkend="sec:hook:url"/> for more information.
1657 </para>
1658 </listitem></itemizedlist>
1660 <para id="x_2be">See also: <literal
1661 role="hook">outgoing</literal> (<xref
1662 linkend="sec:hook:outgoing"/>)
1663 </para>
1664 </sect2>
1666 <sect2 id="sec:hook:pretag">
1667 <title><literal role="hook">pretag</literal>&emdash;before
1668 tagging a changeset</title>
1670 <para id="x_2bf">This controlling hook is run before a tag is created. If
1671 the hook succeeds, creation of the tag proceeds. If the hook
1672 fails, the tag is not created.
1673 </para>
1675 <para id="x_2c0">Parameters to this hook:
1676 </para>
1677 <itemizedlist>
1678 <listitem><para id="x_2c1"><literal>local</literal>: A boolean. Whether
1679 the tag is local to this repository instance (i.e. stored
1680 in <filename role="special">.hg/localtags</filename>) or
1681 managed by Mercurial (stored in <filename
1682 role="special">.hgtags</filename>).
1683 </para>
1684 </listitem>
1685 <listitem><para id="x_2c2"><literal>node</literal>: A changeset ID. The
1686 ID of the changeset to be tagged.
1687 </para>
1688 </listitem>
1689 <listitem><para id="x_2c3"><literal>tag</literal>: A string. The name of
1690 the tag to be created.
1691 </para>
1692 </listitem></itemizedlist>
1694 <para id="x_2c4">If the tag to be created is
1695 revision-controlled, the <literal
1696 role="hook">precommit</literal> and <literal
1697 role="hook">pretxncommit</literal> hooks (<xref
1698 linkend="sec:hook:commit"/> and <xref
1699 linkend="sec:hook:pretxncommit"/>) will also be run.
1700 </para>
1702 <para id="x_2c5">See also: <literal role="hook">tag</literal>
1703 (<xref linkend="sec:hook:tag"/>)
1704 </para>
1705 </sect2>
1707 <sect2 id="sec:hook:pretxnchangegroup">
1708 <title><literal
1709 role="hook">pretxnchangegroup</literal>&emdash;before
1710 completing addition of remote changesets</title>
1712 <para id="x_2c6">This controlling hook is run before a
1713 transaction&emdash;that manages the addition of a group of new
1714 changesets from outside the repository&emdash;completes. If
1715 the hook succeeds, the transaction completes, and all of the
1716 changesets become permanent within this repository. If the
1717 hook fails, the transaction is rolled back, and the data for
1718 the changesets is erased.
1719 </para>
1721 <para id="x_2c7">This hook can access the metadata associated with the
1722 almost-added changesets, but it should not do anything
1723 permanent with this data. It must also not modify the working
1724 directory.
1725 </para>
1727 <para id="x_2c8">While this hook is running, if other Mercurial processes
1728 access this repository, they will be able to see the
1729 almost-added changesets as if they are permanent. This may
1730 lead to race conditions if you do not take steps to avoid
1731 them.
1732 </para>
1734 <para id="x_2c9">This hook can be used to automatically vet a group of
1735 changesets. If the hook fails, all of the changesets are
1736 <quote>rejected</quote> when the transaction rolls back.
1737 </para>
1739 <para id="x_2ca">Parameters to this hook:
1740 </para>
1741 <itemizedlist>
1742 <listitem><para id="x_2cb"><literal>node</literal>: A changeset ID. The
1743 changeset ID of the first changeset in the group that was
1744 added. All changesets between this and
1745 <literal role="tag">tip</literal>,
1746 inclusive, were added by a single <command
1747 role="hg-cmd">hg pull</command>, <command
1748 role="hg-cmd">hg push</command> or <command
1749 role="hg-cmd">hg unbundle</command>.
1750 </para>
1751 </listitem>
1752 <listitem><para id="x_2cc"><literal>source</literal>: A
1753 string. The source of these changes. See <xref
1754 linkend="sec:hook:sources"/> for details.
1755 </para>
1756 </listitem>
1757 <listitem><para id="x_2cd"><literal>url</literal>: A URL. The
1758 location of the remote repository, if known. See <xref
1759 linkend="sec:hook:url"/> for more information.
1760 </para>
1761 </listitem></itemizedlist>
1763 <para id="x_2ce">See also: <literal
1764 role="hook">changegroup</literal> (<xref
1765 linkend="sec:hook:changegroup"/>), <literal
1766 role="hook">incoming</literal> (<xref
1767 linkend="sec:hook:incoming"/>), <literal
1768 role="hook">prechangegroup</literal> (<xref
1769 linkend="sec:hook:prechangegroup"/>)
1770 </para>
1771 </sect2>
1773 <sect2 id="sec:hook:pretxncommit">
1774 <title><literal role="hook">pretxncommit</literal>&emdash;before
1775 completing commit of new changeset</title>
1777 <para id="x_2cf">This controlling hook is run before a
1778 transaction&emdash;that manages a new commit&emdash;completes.
1779 If the hook succeeds, the transaction completes and the
1780 changeset becomes permanent within this repository. If the
1781 hook fails, the transaction is rolled back, and the commit
1782 data is erased.
1783 </para>
1785 <para id="x_2d0">This hook can access the metadata associated with the
1786 almost-new changeset, but it should not do anything permanent
1787 with this data. It must also not modify the working
1788 directory.
1789 </para>
1791 <para id="x_2d1">While this hook is running, if other Mercurial processes
1792 access this repository, they will be able to see the
1793 almost-new changeset as if it is permanent. This may lead to
1794 race conditions if you do not take steps to avoid them.
1795 </para>
1797 <para id="x_2d2">Parameters to this hook:</para>
1799 <itemizedlist>
1800 <listitem><para id="x_2d3"><literal>node</literal>: A changeset ID. The
1801 changeset ID of the newly committed changeset.
1802 </para>
1803 </listitem>
1804 <listitem><para id="x_2d4"><literal>parent1</literal>: A changeset ID.
1805 The changeset ID of the first parent of the newly
1806 committed changeset.
1807 </para>
1808 </listitem>
1809 <listitem><para id="x_2d5"><literal>parent2</literal>: A changeset ID.
1810 The changeset ID of the second parent of the newly
1811 committed changeset.
1812 </para>
1813 </listitem></itemizedlist>
1815 <para id="x_2d6">See also: <literal
1816 role="hook">precommit</literal> (<xref
1817 linkend="sec:hook:precommit"/>)
1818 </para>
1819 </sect2>
1821 <sect2 id="sec:hook:preupdate">
1822 <title><literal role="hook">preupdate</literal>&emdash;before
1823 updating or merging working directory</title>
1825 <para id="x_2d7">This controlling hook is run before an update
1826 or merge of the working directory begins. It is run only if
1827 Mercurial's normal pre-update checks determine that the update
1828 or merge can proceed. If the hook succeeds, the update or
1829 merge may proceed; if it fails, the update or merge does not
1830 start.
1831 </para>
1833 <para id="x_2d8">Parameters to this hook:
1834 </para>
1835 <itemizedlist>
1836 <listitem><para id="x_2d9"><literal>parent1</literal>: A
1837 changeset ID. The ID of the parent that the working
1838 directory is to be updated to. If the working directory
1839 is being merged, it will not change this parent.
1840 </para>
1841 </listitem>
1842 <listitem><para id="x_2da"><literal>parent2</literal>: A
1843 changeset ID. Only set if the working directory is being
1844 merged. The ID of the revision that the working directory
1845 is being merged with.
1846 </para>
1847 </listitem></itemizedlist>
1849 <para id="x_2db">See also: <literal role="hook">update</literal>
1850 (<xref linkend="sec:hook:update"/>)</para>
1851 </sect2>
1853 <sect2 id="sec:hook:tag">
1854 <title><literal role="hook">tag</literal>&emdash;after tagging a
1855 changeset</title>
1857 <para id="x_2dc">This hook is run after a tag has been created.
1858 </para>
1860 <para id="x_2dd">Parameters to this hook:
1861 </para>
1862 <itemizedlist>
1863 <listitem><para id="x_2de"><literal>local</literal>: A boolean. Whether
1864 the new tag is local to this repository instance (i.e.
1865 stored in <filename
1866 role="special">.hg/localtags</filename>) or managed by
1867 Mercurial (stored in <filename
1868 role="special">.hgtags</filename>).
1869 </para>
1870 </listitem>
1871 <listitem><para id="x_2df"><literal>node</literal>: A changeset ID. The
1872 ID of the changeset that was tagged.
1873 </para>
1874 </listitem>
1875 <listitem><para id="x_2e0"><literal>tag</literal>: A string. The name of
1876 the tag that was created.
1877 </para>
1878 </listitem></itemizedlist>
1880 <para id="x_2e1">If the created tag is revision-controlled, the <literal
1881 role="hook">commit</literal> hook (section <xref
1882 linkend="sec:hook:commit"/>) is run before this hook.
1883 </para>
1885 <para id="x_2e2">See also: <literal role="hook">pretag</literal>
1886 (<xref linkend="sec:hook:pretag"/>)
1887 </para>
1888 </sect2>
1890 <sect2 id="sec:hook:update">
1891 <title><literal role="hook">update</literal>&emdash;after
1892 updating or merging working directory</title>
1894 <para id="x_2e3">This hook is run after an update or merge of the working
1895 directory completes. Since a merge can fail (if the external
1896 <command>hgmerge</command> command fails to resolve conflicts
1897 in a file), this hook communicates whether the update or merge
1898 completed cleanly.
1899 </para>
1901 <itemizedlist>
1902 <listitem><para id="x_2e4"><literal>error</literal>: A boolean.
1903 Indicates whether the update or merge completed
1904 successfully.
1905 </para>
1906 </listitem>
1907 <listitem><para id="x_2e5"><literal>parent1</literal>: A changeset ID.
1908 The ID of the parent that the working directory was
1909 updated to. If the working directory was merged, it will
1910 not have changed this parent.
1911 </para>
1912 </listitem>
1913 <listitem><para id="x_2e6"><literal>parent2</literal>: A changeset ID.
1914 Only set if the working directory was merged. The ID of
1915 the revision that the working directory was merged with.
1916 </para>
1917 </listitem></itemizedlist>
1919 <para id="x_2e7">See also: <literal role="hook">preupdate</literal>
1920 (<xref linkend="sec:hook:preupdate"/>)
1921 </para>
1923 </sect2>
1924 </sect1>
1925 </chapter>
1927 <!--
1928 local variables:
1929 sgml-parent-document: ("00book.xml" "book" "chapter")
1930 end:
1931 -->