Online Book Reader

Home Category

Mercurial_ The Definitive Guide - Bryan O'Sullivan [81]

By Root 929 0
the string 1 for true, 0 for false. If an environment variable is named HG_NODE, HG_PARENT1, or HG_PARENT2, it contains a changeset ID represented as a hexadecimal string. The empty string is used to represent “null changeset ID” instead of a string of zeros. If an environment variable is named HG_URL, it will contain the URL of a remote repository, if that can be determined.

If a hook exits with a status of zero, it is considered to have succeeded. If it exits with a non-zero status, it is considered to have failed.

Finding Out Where Changesets Come From

A hook that involves the transfer of changesets between a local repository and another may be able to find out information about the “far side.” Mercurial knows how changes are being transferred, and in many cases where they are being transferred to or from.

Sources of changesets

Mercurial will tell a hook what means are, or were, used to transfer changesets between repositories. This is provided by Mercurial in a Python parameter named source, or an environment variable named HG_SOURCE.

serve: Changesets are transferred to or from a remote repository over http or ssh.

pull: Changesets are being transferred via a pull from one repository into another.

push: Changesets are being transferred via a push from one repository into another.

bundle: Changesets are being transferred to or from a bundle.

Where changes are going—remote repository URLs

When possible, Mercurial will tell a hook the location of the “far side” of an activity that transfers changeset data between repositories. This is provided by Mercurial in a Python parameter named url, or an environment variable named HG_URL.

This information is not always known. If a hook is invoked in a repository that is being served via http or ssh, Mercurial cannot tell where the remote repository is, but it may know where the client is connecting from. In such cases, the URL will take one of the following forms:

remote:ssh:1.2.3.4—remote ssh client, at the IP address 1.2.3.4.

remote:http:1.2.3.4—remote http client, at the IP address 1.2.3.4. If the client is using SSL, this will be of the form remote:https:1.2.3.4.

Empty—no information could be discovered about the remote client.

Hook Reference

changegroup—After Remote Changesets Added

This hook is run after a group of pre-existing changesets has been added to the repository, for example via hg pull or hg unbundle. This hook is run once per operation that added one or more changesets. This is in contrast to the incoming hook, which is run once per changeset, regardless of whether the changesets arrived in a group.

Some possible uses for this hook include kicking off an automated build or test of the added changesets, updating a bug database, or notifying subscribers that a repository contains new changes.

Parameters to this hook:

node: A changeset ID. The changeset ID of the first changeset in the group that was added. All changesets between this and tip, inclusive, were added by a single hg pull, hg push, or hg unbundle.

source: A string. The source of these changes. See Sources of changesets for details.

url: A URL. The location of the remote repository, if known. See Where changes are going—remote repository URLs for more information.

See also: incoming (incoming—After One Remote Changeset Is Added), prechangegroup (prechangegroup—Before Starting to Add Remote Changesets), pretxnchangegroup (pretxnchangegroup—Before Completing Addition of Remote Changesets)

commit—After a New Changeset Is Created

This hook is run after a new changeset has been created.

Parameters to this hook:

node: A changeset ID. The changeset ID of the newly committed changeset.

parent1: A changeset ID. The changeset ID of the first parent of the newly committed changeset.

parent2: A changeset ID. The changeset ID of the second parent of the newly committed changeset.

See also: precommit (precommit—Before Starting to Commit a Changeset), pretxncommit (pretxncommit—Before Completing Commit of New Changeset)

incoming—After

Return Main Page Previous Page Next Page

®Online Book Reader