hgbook

diff en/hook.tex @ 154:e7f48702d409

Check for illegal suffixes.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Mar 12 22:56:29 2007 -0700 (2007-03-12)
parents b727a63518d4 d12a199ed472
children 914babdc99c8
line diff
     1.1 --- a/en/hook.tex	Fri Jul 21 22:42:19 2006 -0700
     1.2 +++ b/en/hook.tex	Mon Mar 12 22:56:29 2007 -0700
     1.3 @@ -177,7 +177,7 @@
     1.4  (which contains pointers to the new manifest data).  Before the first
     1.5  write to each file, it stores a record of where the end of the file
     1.6  was in its transaction log.  If the transaction must be rolled back,
     1.7 -Mercurial simply truncates each file back to te size it was before the
     1.8 +Mercurial simply truncates each file back to the size it was before the
     1.9  transaction began.
    1.10  
    1.11  When Mercurial \emph{reads} metadata, it reads the changelog first,
    1.12 @@ -358,8 +358,8 @@
    1.13  number 1 (for ``true'') or 0 (for ``false'') as an environment
    1.14  variable for an external hook.  If a hook parameter is named
    1.15  \texttt{foo}, the keyword argument for a Python hook will also be
    1.16 -named \texttt{foo} Python, while the environment variable for an
    1.17 -external hook will be named \texttt{HG\_FOO}.
    1.18 +named \texttt{foo}, while the environment variable for an external
    1.19 +hook will be named \texttt{HG\_FOO}.
    1.20  
    1.21  \subsection{Hook return values and activity control}
    1.22  
    1.23 @@ -430,7 +430,532 @@
    1.24  doesn't care about by dropping them into a keyword argument dict, as
    1.25  with \texttt{**kwargs} above.
    1.26  
    1.27 -\section{Hook reference}
    1.28 +\section{Some hook examples}
    1.29 +
    1.30 +\subsection{Writing meaningful commit messages}
    1.31 +
    1.32 +It's hard to imagine a useful commit message being very short.  The
    1.33 +simple \hook{pretxncommit} hook of figure~\ref{ex:hook:msglen.run}
    1.34 +will prevent you from committing a changeset with a message that is
    1.35 +less than ten bytes long.
    1.36 +
    1.37 +\begin{figure}[ht]
    1.38 +  \interaction{hook.msglen.run}
    1.39 +  \caption{A hook that forbids overly short commit messages}
    1.40 +  \label{ex:hook:msglen.run}
    1.41 +\end{figure}
    1.42 +
    1.43 +\subsection{Checking for trailing whitespace}
    1.44 +
    1.45 +An interesting use of a commit-related hook is to help you to write
    1.46 +cleaner code.  A simple example of ``cleaner code'' is the dictum that
    1.47 +a change should not add any new lines of text that contain ``trailing
    1.48 +whitespace''.  Trailing whitespace is a series of space and tab
    1.49 +characters at the end of a line of text.  In most cases, trailing
    1.50 +whitespace is unnecessary, invisible noise, but it is occasionally
    1.51 +problematic, and people often prefer to get rid of it.
    1.52 +
    1.53 +You can use either the \hook{precommit} or \hook{pretxncommit} hook to
    1.54 +tell whether you have a trailing whitespace problem.  If you use the
    1.55 +\hook{precommit} hook, the hook will not know which files you are
    1.56 +committing, so it will have to check every modified file in the
    1.57 +repository for trailing white space.  If you want to commit a change
    1.58 +to just the file \filename{foo}, but the file \filename{bar} contains
    1.59 +trailing whitespace, doing a check in the \hook{precommit} hook will
    1.60 +prevent you from committing \filename{foo} due to the problem with
    1.61 +\filename{bar}.  This doesn't seem right.
    1.62 +
    1.63 +Should you choose the \hook{pretxncommit} hook, the check won't occur
    1.64 +until just before the transaction for the commit completes.  This will
    1.65 +allow you to check for problems only the exact files that are being
    1.66 +committed.  However, if you entered the commit message interactively
    1.67 +and the hook fails, the transaction will roll back; you'll have to
    1.68 +re-enter the commit message after you fix the trailing whitespace and
    1.69 +run \hgcmd{commit} again.
    1.70 +
    1.71 +\begin{figure}[ht]
    1.72 +  \interaction{hook.ws.simple}
    1.73 +  \caption{A simple hook that checks for trailing whitespace}
    1.74 +  \label{ex:hook:ws.simple}
    1.75 +\end{figure}
    1.76 +
    1.77 +Figure~\ref{ex:hook:ws.simple} introduces a simple \hook{pretxncommit}
    1.78 +hook that checks for trailing whitespace.  This hook is short, but not
    1.79 +very helpful.  It exits with an error status if a change adds a line
    1.80 +with trailing whitespace to any file, but does not print any
    1.81 +information that might help us to identify the offending file or
    1.82 +line.  It also has the nice property of not paying attention to
    1.83 +unmodified lines; only lines that introduce new trailing whitespace
    1.84 +cause problems.
    1.85 +
    1.86 +\begin{figure}[ht]
    1.87 +  \interaction{hook.ws.better}
    1.88 +  \caption{A better trailing whitespace hook}
    1.89 +  \label{ex:hook:ws.better}
    1.90 +\end{figure}
    1.91 +
    1.92 +The example of figure~\ref{ex:hook:ws.better} is much more complex,
    1.93 +but also more useful.  It parses a unified diff to see if any lines
    1.94 +add trailing whitespace, and prints the name of the file and the line
    1.95 +number of each such occurrence.  Even better, if the change adds
    1.96 +trailing whitespace, this hook saves the commit comment and prints the
    1.97 +name of the save file before exiting and telling Mercurial to roll the
    1.98 +transaction back, so you can use
    1.99 +\hgcmdargs{commit}{\hgopt{commit}{-l}~\emph{filename}} to reuse the
   1.100 +saved commit message once you've corrected the problem.
   1.101 +
   1.102 +As a final aside, note in figure~\ref{ex:hook:ws.better} the use of
   1.103 +\command{perl}'s in-place editing feature to get rid of trailing
   1.104 +whitespace from a file.  This is concise and useful enough that I will
   1.105 +reproduce it here.
   1.106 +\begin{codesample2}
   1.107 +  perl -pi -e 's,\\s+\$,,' filename
   1.108 +\end{codesample2}
   1.109 +
   1.110 +\section{Bundled hooks}
   1.111 +
   1.112 +Mercurial ships with several bundled hooks.  You can find them in the
   1.113 +\dirname{hgext} directory of a Mercurial source tree.  If you are
   1.114 +using a Mercurial binary package, the hooks will be located in the
   1.115 +\dirname{hgext} directory of wherever your package installer put
   1.116 +Mercurial.
   1.117 +
   1.118 +\subsection{\hgext{acl}---access control for parts of a repository}
   1.119 +
   1.120 +The \hgext{acl} extension lets you control which remote users are
   1.121 +allowed to push changesets to a networked server.  You can protect any
   1.122 +portion of a repository (including the entire repo), so that a
   1.123 +specific remote user can push changes that do not affect the protected
   1.124 +portion.
   1.125 +
   1.126 +This extension implements access control based on the identity of the
   1.127 +user performing a push, \emph{not} on who committed the changesets
   1.128 +they're pushing.  It makes sense to use this hook only if you have a
   1.129 +locked-down server environment that authenticates remote users, and
   1.130 +you want to be sure that only specific users are allowed to push
   1.131 +changes to that server.
   1.132 +
   1.133 +\subsubsection{Configuring the \hook{acl} hook}
   1.134 +
   1.135 +In order to manage incoming changesets, the \hgext{acl} hook must be
   1.136 +used as a \hook{pretxnchangegroup} hook.  This lets it see which files
   1.137 +are modified by each incoming changeset, and roll back a group of
   1.138 +changesets if they modify ``forbidden'' files.  Example:
   1.139 +\begin{codesample2}
   1.140 +  [hooks]
   1.141 +  pretxnchangegroup.acl = python:hgext.acl.hook
   1.142 +\end{codesample2}
   1.143 +
   1.144 +The \hgext{acl} extension is configured using three sections.  
   1.145 +
   1.146 +The \rcsection{acl} section has only one entry, \rcitem{acl}{sources},
   1.147 +which lists the sources of incoming changesets that the hook should
   1.148 +pay attention to.  You don't normally need to configure this section.
   1.149 +\begin{itemize}
   1.150 +\item[\rcitem{acl}{serve}] Control incoming changesets that are arriving
   1.151 +  from a remote repository over http or ssh.  This is the default
   1.152 +  value of \rcitem{acl}{sources}, and usually the only setting you'll
   1.153 +  need for this configuration item.
   1.154 +\item[\rcitem{acl}{pull}] Control incoming changesets that are
   1.155 +  arriving via a pull from a local repository.
   1.156 +\item[\rcitem{acl}{push}] Control incoming changesets that are
   1.157 +  arriving via a push from a local repository.
   1.158 +\item[\rcitem{acl}{bundle}] Control incoming changesets that are
   1.159 +  arriving from another repository via a bundle.
   1.160 +\end{itemize}
   1.161 +
   1.162 +The \rcsection{acl.allow} section controls the users that are allowed to
   1.163 +add changesets to the repository.  If this section is not present, all
   1.164 +users that are not explicitly denied are allowed.  If this section is
   1.165 +present, all users that are not explicitly allowed are denied (so an
   1.166 +empty section means that all users are denied).
   1.167 +
   1.168 +The \rcsection{acl.deny} section determines which users are denied
   1.169 +from adding changesets to the repository.  If this section is not
   1.170 +present or is empty, no users are denied.
   1.171 +
   1.172 +The syntaxes for the \rcsection{acl.allow} and \rcsection{acl.deny}
   1.173 +sections are identical.  On the left of each entry is a glob pattern
   1.174 +that matches files or directories, relative to the root of the
   1.175 +repository; on the right, a user name.
   1.176 +
   1.177 +In the following example, the user \texttt{docwriter} can only push
   1.178 +changes to the \dirname{docs} subtree of the repository, while
   1.179 +\texttt{intern} can push changes to any file or directory except
   1.180 +\dirname{source/sensitive}.
   1.181 +\begin{codesample2}
   1.182 +  [acl.allow]
   1.183 +  docs/** = docwriter
   1.184 +
   1.185 +  [acl.deny]
   1.186 +  source/sensitive/** = intern
   1.187 +\end{codesample2}
   1.188 +
   1.189 +\subsubsection{Testing and troubleshooting}
   1.190 +
   1.191 +If you want to test the \hgext{acl} hook, run it with Mercurial's
   1.192 +debugging output enabled.  Since you'll probably be running it on a
   1.193 +server where it's not convenient (or sometimes possible) to pass in
   1.194 +the \hggopt{--debug} option, don't forget that you can enable
   1.195 +debugging output in your \hgrc:
   1.196 +\begin{codesample2}
   1.197 +  [ui]
   1.198 +  debug = true
   1.199 +\end{codesample2}
   1.200 +With this enabled, the \hgext{acl} hook will print enough information
   1.201 +to let you figure out why it is allowing or forbidding pushes from
   1.202 +specific users.
   1.203 +
   1.204 +\subsection{\hgext{bugzilla}---integration with Bugzilla}
   1.205 +
   1.206 +The \hgext{bugzilla} extension adds a comment to a Bugzilla bug
   1.207 +whenever it finds a reference to that bug ID in a commit comment.  You
   1.208 +can install this hook on a shared server, so that any time a remote
   1.209 +user pushes changes to this server, the hook gets run.  
   1.210 +
   1.211 +It adds a comment to the bug that looks like this (you can configure
   1.212 +the contents of the comment---see below):
   1.213 +\begin{codesample2}
   1.214 +  Changeset aad8b264143a, made by Joe User <joe.user@domain.com> in
   1.215 +  the frobnitz repository, refers to this bug.
   1.216 +
   1.217 +  For complete details, see
   1.218 +  http://hg.domain.com/frobnitz?cmd=changeset;node=aad8b264143a
   1.219 +
   1.220 +  Changeset description:
   1.221 +        Fix bug 10483 by guarding against some NULL pointers
   1.222 +\end{codesample2}
   1.223 +The value of this hook is that it automates the process of updating a
   1.224 +bug any time a changeset refers to it.  If you configure the hook
   1.225 +properly, it makes it easy for people to browse straight from a
   1.226 +Bugzilla bug to a changeset that refers to that bug.
   1.227 +
   1.228 +You can use the code in this hook as a starting point for some more
   1.229 +exotic Bugzilla integration recipes.  Here are a few possibilities:
   1.230 +\begin{itemize}
   1.231 +\item Require that every changeset pushed to the server have a valid
   1.232 +  bug~ID in its commit comment.  In this case, you'd want to configure
   1.233 +  the hook as a \hook{pretxncommit} hook.  This would allow the hook
   1.234 +  to reject changes that didn't contain bug IDs.
   1.235 +\item Allow incoming changesets to automatically modify the
   1.236 +  \emph{state} of a bug, as well as simply adding a comment.  For
   1.237 +  example, the hook could recognise the string ``fixed bug 31337'' as
   1.238 +  indicating that it should update the state of bug 31337 to
   1.239 +  ``requires testing''.
   1.240 +\end{itemize}
   1.241 +
   1.242 +\subsubsection{Configuring the \hook{bugzilla} hook}
   1.243 +\label{sec:hook:bugzilla:config}
   1.244 +
   1.245 +You should configure this hook in your server's \hgrc\ as an
   1.246 +\hook{incoming} hook, for example as follows:
   1.247 +\begin{codesample2}
   1.248 +  [hooks]
   1.249 +  incoming.bugzilla = python:hgext.bugzilla.hook
   1.250 +\end{codesample2}
   1.251 +
   1.252 +Because of the specialised nature of this hook, and because Bugzilla
   1.253 +was not written with this kind of integration in mind, configuring
   1.254 +this hook is a somewhat involved process.
   1.255 +
   1.256 +Before you begin, you must install the MySQL bindings for Python on
   1.257 +the host(s) where you'll be running the hook.  If this is not
   1.258 +available as a binary package for your system, you can download it
   1.259 +from~\cite{web:mysql-python}.
   1.260 +
   1.261 +Configuration information for this hook lives in the
   1.262 +\rcsection{bugzilla} section of your \hgrc.
   1.263 +\begin{itemize}
   1.264 +\item[\rcitem{bugzilla}{version}] The version of Bugzilla installed on
   1.265 +  the server.  The database schema that Bugzilla uses changes
   1.266 +  occasionally, so this hook has to know exactly which schema to use.
   1.267 +  At the moment, the only version supported is \texttt{2.16}.
   1.268 +\item[\rcitem{bugzilla}{host}] The hostname of the MySQL server that
   1.269 +  stores your Bugzilla data.  The database must be configured to allow
   1.270 +  connections from whatever host you are running the \hook{bugzilla}
   1.271 +  hook on.
   1.272 +\item[\rcitem{bugzilla}{user}] The username with which to connect to
   1.273 +  the MySQL server.  The database must be configured to allow this
   1.274 +  user to connect from whatever host you are running the
   1.275 +  \hook{bugzilla} hook on.  This user must be able to access and
   1.276 +  modify Bugzilla tables.  The default value of this item is
   1.277 +  \texttt{bugs}, which is the standard name of the Bugzilla user in a
   1.278 +  MySQL database.
   1.279 +\item[\rcitem{bugzilla}{password}] The MySQL password for the user you
   1.280 +  configured above.  This is stored as plain text, so you should make
   1.281 +  sure that unauthorised users cannot read the \hgrc\ file where you
   1.282 +  store this information.
   1.283 +\item[\rcitem{bugzilla}{db}] The name of the Bugzilla database on the
   1.284 +  MySQL server.  The default value of this item is \texttt{bugs},
   1.285 +  which is the standard name of the MySQL database where Bugzilla
   1.286 +  stores its data.
   1.287 +\item[\rcitem{bugzilla}{notify}] If you want Bugzilla to send out a
   1.288 +  notification email to subscribers after this hook has added a
   1.289 +  comment to a bug, you will need this hook to run a command whenever
   1.290 +  it updates the database.  The command to run depends on where you
   1.291 +  have installed Bugzilla, but it will typically look something like
   1.292 +  this, if you have Bugzilla installed in
   1.293 +  \dirname{/var/www/html/bugzilla}:
   1.294 +  \begin{codesample4}
   1.295 +    cd /var/www/html/bugzilla && ./processmail %s nobody@nowhere.com
   1.296 +  \end{codesample4}
   1.297 +  The Bugzilla \texttt{processmail} program expects to be given a
   1.298 +  bug~ID (the hook replaces ``\texttt{\%s}'' with the bug~ID) and an
   1.299 +  email address.  It also expects to be able to write to some files in
   1.300 +  the directory that it runs in.  If Bugzilla and this hook are not
   1.301 +  installed on the same machine, you will need to find a way to run
   1.302 +  \texttt{processmail} on the server where Bugzilla is installed.
   1.303 +\end{itemize}
   1.304 +
   1.305 +\subsubsection{Mapping committer names to Bugzilla user names}
   1.306 +
   1.307 +By default, the \hgext{bugzilla} hook tries to use the email address
   1.308 +of a changeset's committer as the Bugzilla user name with which to
   1.309 +update a bug.  If this does not suit your needs, you can map committer
   1.310 +email addresses to Bugzilla user names using a \rcsection{usermap}
   1.311 +section.
   1.312 +
   1.313 +Each item in the \rcsection{usermap} section contains an email address
   1.314 +on the left, and a Bugzilla user name on the right.
   1.315 +\begin{codesample2}
   1.316 +  [usermap]
   1.317 +  jane.user@example.com = jane
   1.318 +\end{codesample2}
   1.319 +You can either keep the \rcsection{usermap} data in a normal \hgrc, or
   1.320 +tell the \hgext{bugzilla} hook to read the information from an
   1.321 +external \filename{usermap} file.  In the latter case, you can store
   1.322 +\filename{usermap} data by itself in (for example) a user-modifiable
   1.323 +repository.  This makes it possible to let your users maintain their
   1.324 +own \rcitem{bugzilla}{usermap} entries.  The main \hgrc\ file might
   1.325 +look like this:
   1.326 +\begin{codesample2}
   1.327 +  # regular hgrc file refers to external usermap file
   1.328 +  [bugzilla]
   1.329 +  usermap = /home/hg/repos/userdata/bugzilla-usermap.conf
   1.330 +\end{codesample2}
   1.331 +While the \filename{usermap} file that it refers to might look like
   1.332 +this:
   1.333 +\begin{codesample2}
   1.334 +  # bugzilla-usermap.conf - inside a hg repository
   1.335 +  [usermap]
   1.336 +  stephanie@example.com = steph
   1.337 +\end{codesample2}
   1.338 +
   1.339 +\subsubsection{Configuring the text that gets added to a bug}
   1.340 +
   1.341 +You can configure the text that this hook adds as a comment; you
   1.342 +specify it in the form of a Mercurial template.  Several \hgrc\
   1.343 +entries (still in the \rcsection{bugzilla} section) control this
   1.344 +behaviour.
   1.345 +\begin{itemize}
   1.346 +\item[\texttt{strip}] The number of leading path elements to strip
   1.347 +  from a repository's path name to construct a partial path for a URL.
   1.348 +  For example, if the repositories on your server live under
   1.349 +  \dirname{/home/hg/repos}, and you have a repository whose path is
   1.350 +  \dirname{/home/hg/repos/app/tests}, then setting \texttt{strip} to
   1.351 +  \texttt{4} will give a partial path of \dirname{app/tests}.  The
   1.352 +  hook will make this partial path available when expanding a
   1.353 +  template, as \texttt{webroot}.
   1.354 +\item[\texttt{template}] The text of the template to use.  In addition
   1.355 +  to the usual changeset-related variables, this template can use
   1.356 +  \texttt{hgweb} (the value of the \texttt{hgweb} configuration item
   1.357 +  above) and \texttt{webroot} (the path constructed using
   1.358 +  \texttt{strip} above).
   1.359 +\end{itemize}
   1.360 +
   1.361 +In addition, you can add a \rcitem{web}{baseurl} item to the
   1.362 +\rcsection{web} section of your \hgrc.  The \hgext{bugzilla} hook will
   1.363 +make this available when expanding a template, as the base string to
   1.364 +use when constructing a URL that will let users browse from a Bugzilla
   1.365 +comment to view a changeset.  Example:
   1.366 +\begin{codesample2}
   1.367 +  [web]
   1.368 +  baseurl = http://hg.domain.com/
   1.369 +\end{codesample2}
   1.370 +
   1.371 +Here is an example set of \hgext{bugzilla} hook config information.
   1.372 +\begin{codesample2}
   1.373 +  [bugzilla]
   1.374 +  host = bugzilla.example.com
   1.375 +  password = mypassword
   1.376 +  version = 2.16
   1.377 +  # server-side repos live in /home/hg/repos, so strip 4 leading
   1.378 +  # separators
   1.379 +  strip = 4
   1.380 +  hgweb = http://hg.example.com/
   1.381 +  usermap = /home/hg/repos/notify/bugzilla.conf
   1.382 +  template = Changeset \{node|short\}, made by \{author\} in the \{webroot\}
   1.383 +    repo, refers to this bug.\\nFor complete details, see 
   1.384 +    \{hgweb\}\{webroot\}?cmd=changeset;node=\{node|short\}\\nChangeset
   1.385 +    description:\\n\\t\{desc|tabindent\}
   1.386 +\end{codesample2}
   1.387 +
   1.388 +\subsubsection{Testing and troubleshooting}
   1.389 +
   1.390 +The most common problems with configuring the \hgext{bugzilla} hook
   1.391 +relate to running Bugzilla's \filename{processmail} script and mapping
   1.392 +committer names to user names.
   1.393 +
   1.394 +Recall from section~\ref{sec:hook:bugzilla:config} above that the user
   1.395 +that runs the Mercurial process on the server is also the one that
   1.396 +will run the \filename{processmail} script.  The
   1.397 +\filename{processmail} script sometimes causes Bugzilla to write to
   1.398 +files in its configuration directory, and Bugzilla's configuration
   1.399 +files are usually owned by the user that your web server runs under.
   1.400 +
   1.401 +You can cause \filename{processmail} to be run with the suitable
   1.402 +user's identity using the \command{sudo} command.  Here is an example
   1.403 +entry for a \filename{sudoers} file.
   1.404 +\begin{codesample2}
   1.405 +  hg_user = (httpd_user) NOPASSWD: /var/www/html/bugzilla/processmail-wrapper %s
   1.406 +\end{codesample2}
   1.407 +This allows the \texttt{hg\_user} user to run a
   1.408 +\filename{processmail-wrapper} program under the identity of
   1.409 +\texttt{httpd\_user}.
   1.410 +
   1.411 +This indirection through a wrapper script is necessary, because
   1.412 +\filename{processmail} expects to be run with its current directory
   1.413 +set to wherever you installed Bugzilla; you can't specify that kind of
   1.414 +constraint in a \filename{sudoers} file.  The contents of the wrapper
   1.415 +script are simple:
   1.416 +\begin{codesample2}
   1.417 +  #!/bin/sh
   1.418 +  cd `dirname $0` && ./processmail "$1" nobody@example.com
   1.419 +\end{codesample2}
   1.420 +It doesn't seem to matter what email address you pass to
   1.421 +\filename{processmail}.
   1.422 +
   1.423 +If your \rcsection{usermap} is not set up correctly, users will see an
   1.424 +error message from the \hgext{bugzilla} hook when they push changes
   1.425 +to the server.  The error message will look like this:
   1.426 +\begin{codesample2}
   1.427 +  cannot find bugzilla user id for john.q.public@example.com
   1.428 +\end{codesample2}
   1.429 +What this means is that the committer's address,
   1.430 +\texttt{john.q.public@example.com}, is not a valid Bugzilla user name,
   1.431 +nor does it have an entry in your \rcsection{usermap} that maps it to
   1.432 +a valid Bugzilla user name.
   1.433 +
   1.434 +\subsection{\hgext{notify}---send email notifications}
   1.435 +
   1.436 +Although Mercurial's built-in web server provides RSS feeds of changes
   1.437 +in every repository, many people prefer to receive change
   1.438 +notifications via email.  The \hgext{notify} hook lets you send out
   1.439 +notifications to a set of email addresses whenever changesets arrive
   1.440 +that those subscribers are interested in.
   1.441 +
   1.442 +As with the \hgext{bugzilla} hook, the \hgext{notify} hook is
   1.443 +template-driven, so you can customise the contents of the notification
   1.444 +messages that it sends.
   1.445 +
   1.446 +By default, the \hgext{notify} hook includes a diff of every changeset
   1.447 +that it sends out; you can limit the size of the diff, or turn this
   1.448 +feature off entirely.  It is useful for letting subscribers review
   1.449 +changes immediately, rather than clicking to follow a URL.
   1.450 +
   1.451 +\subsubsection{Configuring the \hgext{notify} hook}
   1.452 +
   1.453 +You can set up the \hgext{notify} hook to send one email message per
   1.454 +incoming changeset, or one per incoming group of changesets (all those
   1.455 +that arrived in a single pull or push).
   1.456 +\begin{codesample2}
   1.457 +  [hooks]
   1.458 +  # send one email per group of changes
   1.459 +  changegroup.notify = python:hgext.notify.hook
   1.460 +  # send one email per change
   1.461 +  incoming.notify = python:hgext.notify.hook
   1.462 +\end{codesample2}
   1.463 +
   1.464 +Configuration information for this hook lives in the
   1.465 +\rcsection{notify} section of a \hgrc\ file.
   1.466 +\begin{itemize}
   1.467 +\item[\rcitem{notify}{test}] By default, this hook does not send out
   1.468 +  email at all; instead, it prints the message that it \emph{would}
   1.469 +  send.  Set this item to \texttt{false} to allow email to be sent.
   1.470 +  The reason that sending of email is turned off by default is that it
   1.471 +  takes several tries to configure this extension exactly as you would
   1.472 +  like, and it would be bad form to spam subscribers with a number of
   1.473 +  ``broken'' notifications while you debug your configuration.
   1.474 +\item[\rcitem{notify}{config}] The path to a configuration file that
   1.475 +  contains subscription information.  This is kept separate from the
   1.476 +  main \hgrc\ so that you can maintain it in a repository of its own.
   1.477 +  People can then clone that repository, update their subscriptions,
   1.478 +  and push the changes back to your server.
   1.479 +\item[\rcitem{notify}{strip}] The number of leading path separator
   1.480 +  characters to strip from a repository's path, when deciding whether
   1.481 +  a repository has subscribers.  For example, if the repositories on
   1.482 +  your server live in \dirname{/home/hg/repos}, and \hgext{notify} is
   1.483 +  considering a repository named \dirname{/home/hg/repos/shared/test},
   1.484 +  setting \rcitem{notify}{strip} to \texttt{4} will cause
   1.485 +  \hgext{notify} to trim the path it considers down to
   1.486 +  \dirname{shared/test}, and it will match subscribers against that.
   1.487 +\item[\rcitem{notify}{template}] The template text to use when sending
   1.488 +  messages.  This specifies both the contents of the message header
   1.489 +  and its body.
   1.490 +\item[\rcitem{notify}{maxdiff}] The maximum number of lines of diff
   1.491 +  data to append to the end of a message.  If a diff is longer than
   1.492 +  this, it is truncated.  By default, this is set to 300.  Set this to
   1.493 +  \texttt{0} to omit diffs from notification emails.
   1.494 +\item[\rcitem{notify}{sources}] A list of sources of changesets to
   1.495 +  consider.  This lets you limit \hgext{notify} to only sending out
   1.496 +  email about changes that remote users pushed into this repository
   1.497 +  via a server, for example.  See section~\ref{sec:hook:sources} for
   1.498 +  the sources you can specify here.
   1.499 +\end{itemize}
   1.500 +
   1.501 +If you set the \rcitem{web}{baseurl} item in the \rcsection{web}
   1.502 +section, you can use it in a template; it will be available as
   1.503 +\texttt{webroot}.
   1.504 +
   1.505 +Here is an example set of \hgext{notify} configuration information.
   1.506 +\begin{codesample2}
   1.507 +  [notify]
   1.508 +  # really send email
   1.509 +  test = false
   1.510 +  # subscriber data lives in the notify repo
   1.511 +  config = /home/hg/repos/notify/notify.conf
   1.512 +  # repos live in /home/hg/repos on server, so strip 4 "/" chars
   1.513 +  strip = 4
   1.514 +  template = X-Hg-Repo: \{webroot\}\\n\\\\
   1.515 +    Subject: \{webroot\}: \{desc|firstline|strip\}\\n\\\\
   1.516 +    From: \{author\}\\n\\\\
   1.517 +    \\n\\\\
   1.518 +    changeset \{node|short\} in \{root\}\\n\\\\
   1.519 +    details: \{baseurl\}\{webroot\}?cmd=changeset;node=\{node|short\}\\n\\\\
   1.520 +    description:\\n\\\\
   1.521 +    \\t\{desc|tabindent|strip\}
   1.522 +
   1.523 +  [web]
   1.524 +  baseurl = http://hg.example.com/
   1.525 +\end{codesample2}
   1.526 +
   1.527 +This will produce a message that looks like the following:
   1.528 +\begin{codesample2}
   1.529 +  X-Hg-Repo: tests/slave
   1.530 +  Subject: tests/slave: Handle error case when slave has no buffers
   1.531 +  Date: Wed,  2 Aug 2006 15:25:46 -0700 (PDT)
   1.532 +
   1.533 +  changeset 3cba9bfe74b5 in /home/hg/repos/tests/slave
   1.534 +  details: http://hg.example.com/tests/slave?cmd=changeset;node=3cba9bfe74b5
   1.535 +  description:
   1.536 +          Handle error case when slave has no buffers
   1.537 +  diffs (54 lines):
   1.538 +
   1.539 +  diff -r 9d95df7cf2ad -r 3cba9bfe74b5 include/tests.h
   1.540 +  --- a/include/tests.h      Wed Aug 02 15:19:52 2006 -0700
   1.541 +  +++ b/include/tests.h      Wed Aug 02 15:25:26 2006 -0700
   1.542 +  @@ -212,6 +212,15 @@ static __inline__ void test_headers(void *h)
   1.543 +  [...snip...]
   1.544 +\end{codesample2}
   1.545 +
   1.546 +\subsubsection{Testing and troubleshooting}
   1.547 +
   1.548 +Do not forget that by default, the \hgext{notify} extension \emph{will
   1.549 +  not send any mail} until you explicitly configure it to do so, by
   1.550 +setting \rcitem{notify}{test} to \texttt{false}.  Until you do that,
   1.551 +it simply prints the message it \emph{would} send.
   1.552 +
   1.553 +\section{Information for writers of hooks}
   1.554  \label{sec:hook:ref}
   1.555  
   1.556  \subsection{In-process hook execution}
   1.557 @@ -450,26 +975,34 @@
   1.558    \texttt{parent\emph{N}}, it will contain a hexadecimal changeset ID.
   1.559    The empty string is used to represent ``null changeset ID'' instead
   1.560    of a string of zeroes.
   1.561 +\item If a parameter is named \texttt{url}, it will contain the URL of
   1.562 +  a remote repository, if that can be determined.
   1.563  \item Boolean-valued parameters are represented as Python
   1.564    \texttt{bool} objects.
   1.565  \end{itemize}
   1.566  
   1.567  An in-process hook is called without a change to the process's working
   1.568  directory (unlike external hooks, which are run in the root of the
   1.569 -repository).  It must not change the process's working directory.  If
   1.570 -it were to do so, it would probably cause calls to the Mercurial API,
   1.571 -or operations after the hook finishes, to fail.
   1.572 -
   1.573 -If a hook returns a boolean ``false'' value, it is considered to
   1.574 -have succeeded.  If it returns a boolean ``true'' value or raises an
   1.575 -exception, it is considered to have failed.
   1.576 +repository).  It must not change the process's working directory, or
   1.577 +it will cause any calls it makes into the Mercurial API to fail.
   1.578 +
   1.579 +If a hook returns a boolean ``false'' value, it is considered to have
   1.580 +succeeded.  If it returns a boolean ``true'' value or raises an
   1.581 +exception, it is considered to have failed.  A useful way to think of
   1.582 +the calling convention is ``tell me if you fail''.
   1.583 +
   1.584 +Note that changeset IDs are passed into Python hooks as hexadecimal
   1.585 +strings, not the binary hashes that Mercurial's APIs normally use.  To
   1.586 +convert a hash from hex to binary, use the
   1.587 +\pymodfunc{mercurial.node}{bin} function.
   1.588  
   1.589  \subsection{External hook execution}
   1.590  
   1.591 -An external hook is passed to the user's shell for execution, so
   1.592 -features of that shell, such as variable substitution and command
   1.593 +An external hook is passed to the shell of the user running Mercurial.
   1.594 +Features of that shell, such as variable substitution and command
   1.595  redirection, are available.  The hook is run in the root directory of
   1.596 -the repository.
   1.597 +the repository (unlike in-process hooks, which are run in the same
   1.598 +directory that Mercurial was run in).
   1.599  
   1.600  Hook parameters are passed to the hook as environment variables.  Each
   1.601  environment variable's name is converted in upper case and prefixed
   1.602 @@ -482,13 +1015,67 @@
   1.603  named \envar{HG\_NODE}, \envar{HG\_PARENT1} or \envar{HG\_PARENT2}, it
   1.604  contains a changeset ID represented as a hexadecimal string.  The
   1.605  empty string is used to represent ``null changeset ID'' instead of a
   1.606 -string of zeroes.
   1.607 +string of zeroes.  If an environment variable is named
   1.608 +\envar{HG\_URL}, it will contain the URL of a remote repository, if
   1.609 +that can be determined.
   1.610  
   1.611  If a hook exits with a status of zero, it is considered to have
   1.612  succeeded.  If it exits with a non-zero status, it is considered to
   1.613  have failed.
   1.614  
   1.615 -\subsection{The \hook{changegroup} hook}
   1.616 +\subsection{Finding out where changesets come from}
   1.617 +
   1.618 +A hook that involves the transfer of changesets between a local
   1.619 +repository and another may be able to find out information about the
   1.620 +``far side''.  Mercurial knows \emph{how} changes are being
   1.621 +transferred, and in many cases \emph{where} they are being transferred
   1.622 +to or from.
   1.623 +
   1.624 +\subsubsection{Sources of changesets}
   1.625 +\label{sec:hook:sources}
   1.626 +
   1.627 +Mercurial will tell a hook what means are, or were, used to transfer
   1.628 +changesets between repositories.  This is provided by Mercurial in a
   1.629 +Python parameter named \texttt{source}, or an environment variable named
   1.630 +\envar{HG\_SOURCE}.
   1.631 +
   1.632 +\begin{itemize}
   1.633 +\item[\texttt{serve}] Changesets are transferred to or from a remote
   1.634 +  repository over http or ssh.
   1.635 +\item[\texttt{pull}] Changesets are being transferred via a pull from
   1.636 +  one repository into another.
   1.637 +\item[\texttt{push}] Changesets are being transferred via a push from
   1.638 +  one repository into another.
   1.639 +\item[\texttt{bundle}] Changesets are being transferred to or from a
   1.640 +  bundle.
   1.641 +\end{itemize}
   1.642 +
   1.643 +\subsubsection{Where changes are going---remote repository URLs}
   1.644 +\label{sec:hook:url}
   1.645 +
   1.646 +When possible, Mercurial will tell a hook the location of the ``far
   1.647 +side'' of an activity that transfers changeset data between
   1.648 +repositories.  This is provided by Mercurial in a Python parameter
   1.649 +named \texttt{url}, or an environment variable named \envar{HG\_URL}.
   1.650 +
   1.651 +This information is not always known.  If a hook is invoked in a
   1.652 +repository that is being served via http or ssh, Mercurial cannot tell
   1.653 +where the remote repository is, but it may know where the client is
   1.654 +connecting from.  In such cases, the URL will take one of the
   1.655 +following forms:
   1.656 +\begin{itemize}
   1.657 +\item \texttt{remote:ssh:\emph{ip-address}}---remote ssh client, at
   1.658 +  the given IP address.
   1.659 +\item \texttt{remote:http:\emph{ip-address}}---remote http client, at
   1.660 +  the given IP address.  If the client is using SSL, this will be of
   1.661 +  the form \texttt{remote:https:\emph{ip-address}}.
   1.662 +\item Empty---no information could be discovered about the remote
   1.663 +  client.
   1.664 +\end{itemize}
   1.665 +
   1.666 +\section{Hook reference}
   1.667 +
   1.668 +\subsection{\hook{changegroup}---after remote changesets added}
   1.669  \label{sec:hook:changegroup}
   1.670  
   1.671  This hook is run after a group of pre-existing changesets has been
   1.672 @@ -508,13 +1095,17 @@
   1.673    changeset in the group that was added.  All changesets between this
   1.674    and \index{tags!\texttt{tip}}\texttt{tip}, inclusive, were added by
   1.675    a single \hgcmd{pull}, \hgcmd{push} or \hgcmd{unbundle}.
   1.676 +\item[\texttt{source}] A string.  The source of these changes.  See
   1.677 +  section~\ref{sec:hook:sources} for details.
   1.678 +\item[\texttt{url}] A URL.  The location of the remote repository, if
   1.679 +  known.  See section~\ref{sec:hook:url} for more information.
   1.680  \end{itemize}
   1.681  
   1.682  See also: \hook{incoming} (section~\ref{sec:hook:incoming}),
   1.683  \hook{prechangegroup} (section~\ref{sec:hook:prechangegroup}),
   1.684  \hook{pretxnchangegroup} (section~\ref{sec:hook:pretxnchangegroup})
   1.685  
   1.686 -\subsection{The \hook{commit} hook}
   1.687 +\subsection{\hook{commit}---after a new changeset is created}
   1.688  \label{sec:hook:commit}
   1.689  
   1.690  This hook is run after a new changeset has been created.
   1.691 @@ -532,7 +1123,7 @@
   1.692  See also: \hook{precommit} (section~\ref{sec:hook:precommit}),
   1.693  \hook{pretxncommit} (section~\ref{sec:hook:pretxncommit})
   1.694  
   1.695 -\subsection{The \hook{incoming} hook}
   1.696 +\subsection{\hook{incoming}---after one remote changeset is added}
   1.697  \label{sec:hook:incoming}
   1.698  
   1.699  This hook is run after a pre-existing changeset has been added to the
   1.700 @@ -542,18 +1133,22 @@
   1.701  
   1.702  You can use this hook for the same purposes as the \hook{changegroup}
   1.703  hook (section~\ref{sec:hook:changegroup}); it's simply more convenient
   1.704 -sometimes to run a hook once per group of changesets, while othher
   1.705 +sometimes to run a hook once per group of changesets, while other
   1.706  times it's handier once per changeset.
   1.707  
   1.708  Parameters to this hook:
   1.709  \begin{itemize}
   1.710  \item[\texttt{node}] A changeset ID.  The ID of the newly added
   1.711    changeset.
   1.712 +\item[\texttt{source}] A string.  The source of these changes.  See
   1.713 +  section~\ref{sec:hook:sources} for details.
   1.714 +\item[\texttt{url}] A URL.  The location of the remote repository, if
   1.715 +  known.  See section~\ref{sec:hook:url} for more information.
   1.716  \end{itemize}
   1.717  
   1.718  See also: \hook{changegroup} (section~\ref{sec:hook:changegroup}) \hook{prechangegroup} (section~\ref{sec:hook:prechangegroup}), \hook{pretxnchangegroup} (section~\ref{sec:hook:pretxnchangegroup})
   1.719  
   1.720 -\subsection{The \hook{outgoing} hook}
   1.721 +\subsection{\hook{outgoing}---after changesets are propagated}
   1.722  \label{sec:hook:outgoing}
   1.723  
   1.724  This hook is run after a group of changesets has been propagated out
   1.725 @@ -567,17 +1162,20 @@
   1.726  \begin{itemize}
   1.727  \item[\texttt{node}] A changeset ID.  The changeset ID of the first
   1.728    changeset of the group that was sent.
   1.729 -\item[\texttt{source}] A string.  The source of the of the operation.
   1.730 -  If a remote client pulled changes from this repository,
   1.731 -  \texttt{source} will be \texttt{serve}.  If the client that obtained
   1.732 -  changes from this repository was local, \texttt{source} will be
   1.733 -  \texttt{bundle}, \texttt{pull}, or \texttt{push}, depending on the
   1.734 -  operation the client performed.
   1.735 +\item[\texttt{source}] A string.  The source of the of the operation
   1.736 +  (see section~\ref{sec:hook:sources}).  If a remote client pulled
   1.737 +  changes from this repository, \texttt{source} will be
   1.738 +  \texttt{serve}.  If the client that obtained changes from this
   1.739 +  repository was local, \texttt{source} will be \texttt{bundle},
   1.740 +  \texttt{pull}, or \texttt{push}, depending on the operation the
   1.741 +  client performed.
   1.742 +\item[\texttt{url}] A URL.  The location of the remote repository, if
   1.743 +  known.  See section~\ref{sec:hook:url} for more information.
   1.744  \end{itemize}
   1.745  
   1.746  See also: \hook{preoutgoing} (section~\ref{sec:hook:preoutgoing})
   1.747  
   1.748 -\subsection{The \hook{prechangegroup} hook}
   1.749 +\subsection{\hook{prechangegroup}---before starting to add remote changesets}
   1.750  \label{sec:hook:prechangegroup}
   1.751  
   1.752  This controlling hook is run before Mercurial begins to add a group of
   1.753 @@ -589,16 +1187,24 @@
   1.754  transmitted.
   1.755  
   1.756  One use for this hook is to prevent external changes from being added
   1.757 -to a repository, for example to ``freeze'' a server-hosted branch
   1.758 -temporarily or permanently.
   1.759 -
   1.760 -This hook is not passed any parameters.
   1.761 +to a repository.  For example, you could use this to ``freeze'' a
   1.762 +server-hosted branch temporarily or permanently so that users cannot
   1.763 +push to it, while still allowing a local administrator to modify the
   1.764 +repository.
   1.765 +
   1.766 +Parameters to this hook:
   1.767 +\begin{itemize}
   1.768 +\item[\texttt{source}] A string.  The source of these changes.  See
   1.769 +  section~\ref{sec:hook:sources} for details.
   1.770 +\item[\texttt{url}] A URL.  The location of the remote repository, if
   1.771 +  known.  See section~\ref{sec:hook:url} for more information.
   1.772 +\end{itemize}
   1.773  
   1.774  See also: \hook{changegroup} (section~\ref{sec:hook:changegroup}),
   1.775  \hook{incoming} (section~\ref{sec:hook:incoming}), ,
   1.776  \hook{pretxnchangegroup} (section~\ref{sec:hook:pretxnchangegroup})
   1.777  
   1.778 -\subsection{The \hook{precommit} hook}
   1.779 +\subsection{\hook{precommit}---before starting to commit a changeset}
   1.780  \label{sec:hook:precommit}
   1.781  
   1.782  This hook is run before Mercurial begins to commit a new changeset.
   1.783 @@ -624,7 +1230,7 @@
   1.784  See also: \hook{commit} (section~\ref{sec:hook:commit}),
   1.785  \hook{pretxncommit} (section~\ref{sec:hook:pretxncommit})
   1.786  
   1.787 -\subsection{The \hook{preoutgoing} hook}
   1.788 +\subsection{\hook{preoutgoing}---before starting to propagate changesets}
   1.789  \label{sec:hook:preoutgoing}
   1.790  
   1.791  This hook is invoked before Mercurial knows the identities of the
   1.792 @@ -636,15 +1242,18 @@
   1.793  Parameters to this hook:
   1.794  \begin{itemize}
   1.795  \item[\texttt{source}] A string.  The source of the operation that is
   1.796 -  attempting to obtain changes from this repository.  See the
   1.797 -  documentation for the \texttt{source} parameter to the
   1.798 -  \hook{outgoing} hook, in section~\ref{sec:hook:outgoing}, for
   1.799 -  possible values of this parameter..
   1.800 +  attempting to obtain changes from this repository (see
   1.801 +  section~\ref{sec:hook:sources}).  See the documentation for the
   1.802 +  \texttt{source} parameter to the \hook{outgoing} hook, in
   1.803 +  section~\ref{sec:hook:outgoing}, for possible values of this
   1.804 +  parameter.
   1.805 +\item[\texttt{url}] A URL.  The location of the remote repository, if
   1.806 +  known.  See section~\ref{sec:hook:url} for more information.
   1.807  \end{itemize}
   1.808  
   1.809  See also: \hook{outgoing} (section~\ref{sec:hook:outgoing})
   1.810  
   1.811 -\subsection{The \hook{pretag} hook}
   1.812 +\subsection{\hook{pretag}---before tagging a changeset}
   1.813  \label{sec:hook:pretag}
   1.814  
   1.815  This controlling hook is run before a tag is created.  If the hook
   1.816 @@ -666,7 +1275,8 @@
   1.817  
   1.818  See also: \hook{tag} (section~\ref{sec:hook:tag})
   1.819  
   1.820 -\subsection{The \hook{pretxnchangegroup} hook}
   1.821 +\subsection{\hook{pretxnchangegroup}---before completing addition of
   1.822 +  remote changesets}
   1.823  \label{sec:hook:pretxnchangegroup}
   1.824  
   1.825  This controlling hook is run before a transaction---that manages the
   1.826 @@ -689,14 +1299,23 @@
   1.827  the hook fails, all of the changesets are ``rejected'' when the
   1.828  transaction rolls back.
   1.829  
   1.830 -Parameters to this hook are the same as for the \hook{changegroup}
   1.831 -hook; see section~\ref{sec:hook:changegroup} for details.
   1.832 +Parameters to this hook:
   1.833 +\begin{itemize}
   1.834 +\item[\texttt{node}] A changeset ID.  The changeset ID of the first
   1.835 +  changeset in the group that was added.  All changesets between this
   1.836 +  and \index{tags!\texttt{tip}}\texttt{tip}, inclusive, were added by
   1.837 +  a single \hgcmd{pull}, \hgcmd{push} or \hgcmd{unbundle}.
   1.838 +\item[\texttt{source}] A string.  The source of these changes.  See
   1.839 +  section~\ref{sec:hook:sources} for details.
   1.840 +\item[\texttt{url}] A URL.  The location of the remote repository, if
   1.841 +  known.  See section~\ref{sec:hook:url} for more information.
   1.842 +\end{itemize}
   1.843  
   1.844  See also: \hook{changegroup} (section~\ref{sec:hook:changegroup}),
   1.845  \hook{incoming} (section~\ref{sec:hook:incoming}),
   1.846  \hook{prechangegroup} (section~\ref{sec:hook:prechangegroup})
   1.847  
   1.848 -\subsection{The \hook{pretxncommit} hook}
   1.849 +\subsection{\hook{pretxncommit}---before completing commit of new changeset}
   1.850  \label{sec:hook:pretxncommit}
   1.851  
   1.852  This controlling hook is run before a transaction---that manages a new
   1.853 @@ -714,12 +1333,19 @@
   1.854  is permanent.  This may lead to race conditions if you do not take
   1.855  steps to avoid them.
   1.856  
   1.857 -Parameters to this hook are the same as for the \hook{commit} hook;
   1.858 -see section~\ref{sec:hook:commit} for details.
   1.859 +Parameters to this hook:
   1.860 +\begin{itemize}
   1.861 +\item[\texttt{node}] A changeset ID.  The changeset ID of the newly
   1.862 +  committed changeset.
   1.863 +\item[\texttt{parent1}] A changeset ID.  The changeset ID of the first
   1.864 +  parent of the newly committed changeset.
   1.865 +\item[\texttt{parent2}] A changeset ID.  The changeset ID of the second
   1.866 +  parent of the newly committed changeset.
   1.867 +\end{itemize}
   1.868  
   1.869  See also: \hook{precommit} (section~\ref{sec:hook:precommit})
   1.870  
   1.871 -\subsection{The \hook{preupdate} hook}
   1.872 +\subsection{\hook{preupdate}---before updating or merging working directory}
   1.873  \label{sec:hook:preupdate}
   1.874  
   1.875  This controlling hook is run before an update or merge of the working
   1.876 @@ -740,20 +1366,27 @@
   1.877  
   1.878  See also: \hook{update} (section~\ref{sec:hook:update})
   1.879  
   1.880 -\subsection{The \hook{tag} hook}
   1.881 +\subsection{\hook{tag}---after tagging a changeset}
   1.882  \label{sec:hook:tag}
   1.883  
   1.884  This hook is run after a tag has been created.
   1.885  
   1.886 -Parameters to this hook are the same as for the \hook{pretag} hook;
   1.887 -see section~\ref{sec:hook:pretag} for details.
   1.888 +Parameters to this hook:
   1.889 +\begin{itemize}
   1.890 +\item[\texttt{local}] A boolean.  Whether the new tag is local to this
   1.891 +  repository instance (i.e.~stored in \sfilename{.hg/tags}) or managed
   1.892 +  by Mercurial (stored in \sfilename{.hgtags}).
   1.893 +\item[\texttt{node}] A changeset ID.  The ID of the changeset that was
   1.894 +  tagged.
   1.895 +\item[\texttt{tag}] A string.  The name of the tag that was created.
   1.896 +\end{itemize}
   1.897  
   1.898  If the created tag is revision-controlled, the \hook{commit} hook
   1.899  (section~\ref{sec:hook:commit}) is run before this hook.
   1.900  
   1.901  See also: \hook{pretag} (section~\ref{sec:hook:pretag})
   1.902  
   1.903 -\subsection{The \hook{update} hook}
   1.904 +\subsection{\hook{update}---after updating or merging working directory}
   1.905  \label{sec:hook:update}
   1.906  
   1.907  This hook is run after an update or merge of the working directory