Installing Mercurial

This guide will focus on the command-line Mercurial client hg, but there are GUI-based Mercurial clients available for many platforms. Here is a list of other Mercurial clients.

Windows

  • Install TortoiseHg to get both GUI and command line tools installed.

Linux (Debian-based)

$ sudo apt-get install mercurial

or

$ sudo add-apt-repository ppa:mercurial-ppa/releases

$ sudo apt-get update

$ sudo apt-get install mercurial

That way, you will install the latest stable version of Mercurial and such version will be updated on an automatic basis.

More info: Mercurial PPA Packagers: Releases

Linux (Fedora-based)

# yum install mercurial

Mac OS X Simple Install

A simple Mercurial installer is available on the Mercurial web site. Download and open this file, once unzipped you'll find a folder with a Mercurial .mpkg file, double click this file and follow the instructions to install.

Mac OS X MacPorts Install

Developers may find it preferable to use MacPorts to install Mercurial. While more complicated for a simple install, having MacPorts makes it easier to install additional packages that you may find useful, such as Mercurial's Keyring Extension for simple password management or other developer tools for working with the test suites, etc. If you choose to go this route, do not install from the installer above and follow the instructions below instead, otherwise skip to “Configuring Mercurial for use with W3C specs”.

  • install XCode. It helps if you're using a fairly new OS X version (e.g. 10.6 Snow Leopard or 10.7 Lion) and XCode. XCode is available in the App Store.
  • install MacPorts (OSX 10.6) (OSX 10.7) (see Installing MacPorts for other installs). You do not need to install X11. If you already have MacPorts installed, be sure to update it by entering this command into a Terminal window:
sudo port selfupdate

You may be prompted to enter your password (as with any “sudo” command).

If you get an error message like:

sudo: port: command not found

Then you haven't successfully installed MacPorts. See above instructions to:

  • download the MacPorts installer
  • open it (e.g. if you're on OS X 10.7 Lion, open the file “MacPorts-2.0.3.pkg” inside the volume “MacPorts-2.0.3”)
  • click all the obvious default install buttons, enter your password if requested and wait for the install to finish (should take less than a minute).

The MacPorts installer will run a program to determine if it can be installed.

If you get an error alert like:

+----------------------------------------------------+
| MacPorts-2.0.3 can't be installed on this          |
| computer.                                          |
|                                                    |
| Xcode is not installed, or was installed with UNIX |
| Development (10.5+) or Command Line Support        |
| (10.4) deselected.                                 |
|                                          ((Close)) |
+----------------------------------------------------+

Then go back and make sure you've installed XCode. If you have installed XCode, make sure you've updated it to the latest version. You may need to check the XCode page in the Apple Mac App store - if you see a button to “Update” or “Upgrade”, click it.

Now retry installing MacPorts again.

  • open a *new* Terminal window. You can also quit/reopen your Terminal application.

Now you should be ready to install Mercurial:

  • Install Mercurial by entering this command into a Terminal window:
sudo port install mercurial

If you get an error message like:

sudo: port: command not found

Then open a *new* Terminal window and try the command again:

sudo port install mercurial

You will be asked for your “Password:” - enter it.

You should then see a bunch of messages like:

Computing dependencies for mercurial
--->  Dependencies to be installed: curl-ca-bundle perl5 perl5.12 gdbm gettext expat libiconv gperf ncurses ncursesw python27 bzip2 db46 libedit openssl zlib python_select sqlite3
--->  Fetching archive for expat
--->  Attempting to fetch expat-2.0.1_1.darwin_11.x86_64.tbz2 from http://packages.macports.org/expat
--->  Fetching expat
--->  Attempting to fetch expat-2.0.1.tar.gz from http://lil.fr.distfiles.macports.org/expat
--->  Verifying checksum(s) for expat
--->  Extracting expat
--->  Configuring expat
--->  Building expat
--->  Staging expat into destroot
--->  Installing expat @2.0.1_1
--->  Activating expat @2.0.1_1
--->  Cleaning expat
--->  Fetching archive for gperf
...

In order to supply all the packages Mercurial depends on, MacPorts may install or upgrade a number of additional packages prior to installing Mercurial.

You may get an alert dialog that says something like:

+-----------------------------------------------+
| To open "javac," you need a Java runtime.     |
| Would you like to install one now?            |
|                                               |
|                         (Not Now) ((Install)) |
+-----------------------------------------------+

Click (Not Now).

Note: Mercurial DOES NOT depend on Java. No idea why MacPorts makes you jump through this hoop. Java is no longer distributed with OS X Lion by default, if you need to install it (which you shouldn't), it can be downloaded from here.

Avoid installing Java as it is the #1 source of exploits and commercially available exploit kits. See http://tantek.com/2010/300/b1/disable-java-now for details/citations.

After clicking (Not Now), you might also get messages like this:

To make python 2.7 the default (i.e. the version you get when you run
'python'), please run:
    	sudo port select --set python python27

This is not necessary unless you want to use the MacPorts Python 2.7 environment when invoking Python from the command line. Mercurial will automatically use the MacPorts Python 2.7 environment regardless of which Python version is in your path.

Note: Mercurial is a Python application. Although OS X has Python pre-instaled, MacPorts will install its own version of Python into /opt/local/bin so that it can manage dependencies between packages. This will not interfere with your normal Python installation. Currently, on OS X Mercurial will use Python version 2.7. Note that if you install any extensions to Mercurial via MacPorts, you'll need to use the py27- version of the extension.

Congratulations, you've installed the command-line hg tool on your Mac!

Verify this with the command line:

hg --version

You should see something like:

Mercurial Distributed SCM (version 3.2)
(see http://mercurial.selenic.com for more information)

As long as the version number you see is 2.1 or higher, you have a new enough version of Mercurial.

Mercurial Updates

Mercurial updates frequently, you can upgrade to the latest version of Mercurial at any time by entering the following commands:

sudo port selfupdate

You might be asked for your “Password:” again here to sudo. Enter it and press return.

You should then see messages like:

--->  Updating MacPorts base sources using rsync
MacPorts base version 2.0.3 installed,
MacPorts base version 2.0.3 downloaded.
--->  Updating the ports tree
--->  MacPorts base is already the latest version

The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated

Ignore it (unless you want to upgrade all the packages installed on your system by MacPorts).

Now do:

sudo port upgrade mercurial

If you already have the latest version of Mercurial, you should not get any messages, just another terminal prompt. If a newer version of Mercurial, or any other packages it depends on, is available, you will see installation messages similar to what you saw during the initial install, but perhaps “cleaning” a previous version:

--->  Computing dependencies for mercurial
--->  Fetching archive for mercurial
--->  Attempting to fetch mercurial-2.2.1_0.darwin_11.x86_64.tbz2 from http://packages.macports.org/mercurial
--->  Fetching distfiles for mercurial
--->  Attempting to fetch mercurial-2.2.1.tar.gz from http://distfiles.macports.org/mercurial
--->  Verifying checksum(s) for mercurial
--->  Extracting mercurial
--->  Applying patches to mercurial
--->  Configuring mercurial
--->  Building mercurial
--->  Staging mercurial into destroot
--->  Installing mercurial @2.2.1_0
--->  Cleaning mercurial
--->  Computing dependencies for mercurial
--->  Deactivating mercurial @2.0.1_0
--->  Cleaning mercurial
--->  Activating mercurial @2.2.1_0
--->  Cleaning mercurial
--->  Updating database of binaries: 100.0%
--->  Scanning binaries for linking errors: 100.0%
--->  No broken files found.

If newer packages are installed, you can remove the old ones that are no longer needed by entering:

sudo port uninstall outdated

You might see some packages deactivated/cleaned/uninstalled like this:

--->  Deactivating cvs @1.11.23_0
--->  Cleaning cvs
--->  Uninstalling cvs @1.11.23_0
--->  Cleaning cvs

Check the version of Mercurial you now have with the command line:

hg --version

You should see something like:

Mercurial Distributed SCM (version 2.2.1)
(see http://mercurial.selenic.com for more information)

As long as the version number you see is 2.1 or higher, you have a new enough version of Mercurial.

Return to hg setup

 
tools/hg/install.txt · Last modified: 2014/12/09 15:48 (external edit)
Recent changes RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki