How to install Mercurial 1.0 on Ubuntu Hardy



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2008/04/how-to-install-mercurial-10-on-ubuntu/

You should be redirected in 2 seconds.



Mercurial 1.0 is out! Mercurial is a next generation "fast, lightweight source control management system" boasting conversions by notable projects NetBeans, OpenJDK, Globulation2, Xine, Mozilla, grml, and OpenSolaris.

From the release notes, version 1.0 has improvements for copying, renaming, removing, and merging. I want to use the most robust version possible, so I decided to upgrade. Ubuntu Gutsy's Mercurial version is 0.9.4, and even Hardy will only have 0.9.5. Luckily, Mercurial 1.0 is easy-installable. That makes it easy to install:


Install Mercurial 1.0
  1. If you don't already have Mercurial 0.9.4 installed, I'd suggest installing it because it will setup /etc/mercurial for using Mercurial extenstions.
    sudo apt-get install mercurial
  2. Install Python Easy Install, build tools, and Python header files.
    sudo apt-get install python-setuptools python-dev build-essential
  3. Install Mercurial 1.0
    sudo easy_install -U mercurial
That was easy! Test it out by typing hg version.
Mercurial Distributed SCM (version 1.0)

Copyright (C) 2005-2008 Matt Mackall  and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Upgrade to 1.0.1
Update 6/2/2008: Mercurial 1.0.1 has been released as a bugfix version. You can upgrade from 1.0 to 1.0.1 using Easy Install:
sudo easy_install -U mercurial

Install hgk extension
If you try the hg view command, you will get a sh: hgk: not found error. To fix this, I copied the hgk executable from the contrib directory in the source package to a directory in my path:
  1. Download and unpack the Mercurial source package.
    cd /tmp
    wget http://www.selenic.com/mercurial/release/mercurial-1.0.tar.gz
    tar zxvf mercurial-1.0.tar.gz
  2. Copy hgk somewhere on your path. E.g.:
    cp mercurial-1.0/contrib/hgk ~/bin
Note, if you get a /usr/bin/env: wish: No such file or directory error, it means you need to install the Tk package:
sudo apt-get install tk8.5

Other Notes
  • hbisect warning
    Per the Upgrade Notes, bisect is now a built-in command and the hbisect extension should not be used. If you get a extension 'hgext/hbisect' overrides commands: bisect warning, remove the hbisect= line from your configuration file (located at /etc/mercurial/hgrc.d/hgext.rc or ~/.hgrc).

  • Where are the files located?
    The hgext and mercurial files should be located at /usr/lib/python2.5/site-packages/mercurial-1.0-py2.5-linux-*.egg

  • Python.h error during easy_install
    If you got the following error while trying to run easy_install, it probably means you don't have the "python-dev" package installed. $ sudo apt-get install python-dev.
    Searching for mercurial
    Reading http://cheeseshop.python.org/pypi/mercurial/
    Couldn't find index page for 'mercurial' (maybe misspelled?)
    Scanning index of all packages (this may take a while)
    Reading http://cheeseshop.python.org/pypi/
    Reading http://cheeseshop.python.org/pypi/Mercurial/1.0
    Reading http://www.selenic.com/mercurial
    Best match: mercurial 1.0
    Downloading http://www.selenic.com/mercurial/release/mercurial-1.0.tar.gz
    Processing mercurial-1.0.tar.gz
    Running mercurial-1.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-MfmZhU/mercurial-1.0/egg-dist-tmp-JDYH6V
    mercurial/mpatch.c:23:20: error: Python.h: No such file or directory
    mercurial/mpatch.c:64: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    mercurial/mpatch.c: In function 'lalloc':
    mercurial/mpatch.c:92: warning: implicit declaration of function 'PyErr_Occurred'
    mercurial/mpatch.c:93: warning: implicit declaration of function 'PyErr_NoMemory'
    mercurial/mpatch.c: In function 'decode':
    mercurial/mpatch.c:265: warning: implicit declaration of function 'PyErr_SetString'
    mercurial/mpatch.c:265: error: 'mpatch_Error' undeclared (first use in this function)
    mercurial/mpatch.c:265: error: (Each undeclared identifier is reported only once
    mercurial/mpatch.c:265: error: for each function it appears in.)
    mercurial/mpatch.c: In function 'calcsize':
    mercurial/mpatch.c:283: error: 'mpatch_Error' undeclared (first use in this function)
    mercurial/mpatch.c: In function 'apply':
    mercurial/mpatch.c:306: error: 'mpatch_Error' undeclared (first use in this function)
    mercurial/mpatch.c: At top level:
    mercurial/mpatch.c:322: error: expected ')' before '*' token
    mercurial/mpatch.c:344: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    mercurial/mpatch.c:392: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    mercurial/mpatch.c:432: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'methods'
    mercurial/mpatch.c:439: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'initmpatch'
    error: Setup script exited with error: command 'gcc' failed with exit status 1
  • Couldn't find a setup script Error:
    If you get the following error when trying to run sudo easy_install -U mercurial, it could mean that there is a "mercurial" directory in your current working directory. Change to a different directory and run the command again.
    Processing mercurial
    error: Couldn't find a setup script in mercurial

3 comments:

Anonymous said...

Thanks for your blog. It's helped me to rid of intrusive
*** failed to import extension hgext.hbisect: No module named hbisect

Anonymous said...

Won't this confuse the package manager?
I've just installed Mercurial 1.0.1 on Ubuntu Hardy from Debian Unstable repo. I think it is a better way.

sofeng said...

romikt,
thanks for the comment. you're probably right-- Easy Install is like a package manager so the two will probably have some conflicts. I just found this the easiest way to have to most up to date Mercurial.

About

This is my *OLD* blog. I've copied all of my posts and comments over to my NEW blog at:

http://www.saltycrane.com/blog/.

Please go there for my updated posts. I will leave this blog up for a short time, but eventually plan to delete it. Thanks for reading.