Slion.net>Dev>VersionControlSystem>MercurialHome

Mercurial

Please visit the home of Mercurial on selenic.com.

Usage

Mercurial command line tool is named after mercury chemical element symbol hg. Unless otherwise specified commands should be run from the root of you repository or would be repository.

Create a new repository

To create a new repository in your current folder just run:

hg init

Create a bundle

You can create a bundle or single file archive from an existing repository or parts of it.

hg bundle --base null project.hg

See also CreateBundleOfAllChanges.

Create a repository from a bundle

To create a repository from a bundle you will need to run the following commands:

hg init
hg unbundle project.hg
hg update

Delete a commit

To delete the revision 447 from your history simply run:

hg strip -r 447

Use with care. You need to enable the mq extension to use strip, see this article.

To delete the tip you should be able to run:

hg strip -r tip

Revisions specification

There are multiple ways to specify a revision. See the excellent revisions documentation.

You can notably use the keyword 'tip' to refer to the latest revision.

Convert Extension

The ConverExtension is really convenient to create a Mercurial repository from an existing subversion depot for instance.

It also generate a .hg/shamap file to record the version that were imported from the original depot into your Mercurial conversion, thus you can resume convert where you left it and basically keep in sync with a foreign repository.

I recommend keeping your default branch to sync the foreign depot and do you development on named branches.

Import and Export

Import and Export are convenient ways to share and apply patches between unrelated repository for instance.

See export and import documentations.

Configuration on Linux

Run the following command to create or edit a configuration file for the current user:

nano $HOME/.hgrc

Basic configuration file could look like that:

[ui]
username=sl

[web]
cacerts=

A username must be specified if you want to commit changes. Specifying an empty cacerts basically disables SSL certificate verification.