Mercurial

From Dogtag
Jump to: navigation, search

Installation

On Fedora:

$ dnf install mercurial git-remote-hg

On Debian:

$ apt install mercurial mercurial-git

Authentication

For Mozilla, request an SSH access, for example:

Then add the following entries into ~/.ssh/config:

Host hg.mozilla.org
  User <email>

Host reviewboard-hg.mozilla.org
  User <email>

See Configuring Authentication.

Configuration

The configuration file is located at ~/.hgrc.

Cloning a repository

$ hg clone <repository>

Committing Changes

$ hg commit

Displaying the logs

$ hg log | less

Creating a Patch

$ hg export tip > bug-nnnnn.patch

Applying a patch

$ hg import <patch>

Reverting changes

$ hg revert --all

Reverting a commit

$ hg rollback

Cleaning Up Working Directory

$ hg pull
$ hg update -r <branch> -C
$ hg purge

Pulling Changes

$ hg pull
$ hg update

Pushing Changes

$ hg push <SSH URL>

Branches

To list branches:

$ hg branches

To check the current branch:

$ hg identify -b

To checkout a branch:

$ hg checkout <name>

Tags

To list tags:

$ hg tags

To create a tag:

$ hg tag <name>

To checkout a tag:

$ hg checkout <name>

Migration

To migrate from Mercurial to Git:

$ git push <new repo> refs/remotes/<old repo>/*:refs/heads/*
$ git push <new repo> refs/tags/*:refs/tags/*
$ git push <new repo> :HEAD

References