# FindHg

Finds the Mercurial command-line client executable (`hg`) and provides a command for extracting information from a Mercurial working copy:

    find_package(Hg [<version>] [...])

## Result Variables

This module defines the following variables:

`Hg_FOUND`

  Added in version 3.3.

  Boolean indicating whether the (requested version of) Mercurial client was found.

`Hg_VERSION`

  Added in version 4.2.

  The version of Mercurial found.

## Cache Variables

The following cache variables may also be set:

`HG_EXECUTABLE`

  Absolute path to the Mercurial command-line client (`hg`).

## Commands

This module provides the following command when Mercurial client (`hg`) is found:

Hg_WC_INFO

  Added in version 3.1.

  Extracts information of a Mercurial working copy:

      Hg_WC_INFO(<dir> <var-prefix>)

  This command defines the following variables if running Mercurial client on working copy located at a given location `<dir>` succeeds; otherwise a `SEND_ERROR` message is generated:

  `<var-prefix>_WC_CHANGESET`

    Current changeset.

  `<var-prefix>_WC_REVISION`

    Current revision.

## Deprecated Variables

The following variables are provided for backward compatibility:

`HG_FOUND`

  Deprecated since version 4.2: Use `Hg_FOUND`, which has the same value.

  Boolean indicating whether the (requested version of) Mercurial client was found.

`HG_VERSION_STRING`

  Deprecated since version 4.2: Use `Hg_VERSION`, which has the same value.

  The version of Mercurial found.

## Examples

Finding the Mercurial client and retrieving information about the current project's working copy:

    find_package(Hg)
    if(Hg_FOUND)
      Hg_WC_INFO(${PROJECT_SOURCE_DIR} Project)
      message("Current revision is ${Project_WC_REVISION}")
      message("Current changeset is ${Project_WC_CHANGESET}")
    endif()