How to install Mercurial 1.0 on Cygwin



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-cygwin/

You should be redirected in 2 seconds.



Mercurial 1.0 has been released and I just posted, How to install Mercurial 1.0 on Ubuntu Gutsy (or Hardy). Here are instructions for installing Mercurial 1.0 on Cygwin.

Install Mercurial 1.0
  1. Install Python Easy Install
    $ cd /tmp
    $ wget http://peak.telecommunity.com/dist/ez_setup.py
    $ python ez_setup.py
  2. Install Mercurial 1.0
    $ easy_install -U mercurial
  3. Trying hg version, gives me a ImportError: Permission denied error. Apparently, there is a Eggs/Cygwin problem. To fix it, make the dll files executable:
    $ chmod +x /usr/lib/python2.5/site-packages/mercurial-1.0-py2.5-cygwin-1.5.25-i686.egg/mercurial/*.dll
Try hg version again:
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.

Install hgk extension
I'm not sure how to get hg view working in Cygwin. If anyone knows, please let me know.

4 comments:

Unknown said...

The Tcl/Tk in Cygwin doesn't like hgk (always sets window attributes to negative values so you can't see anything). I came across a recommendation to use freewrap (http://freewrap.sourceforge.net/) to convert hgk into an executable. This worked for me. Hopefully what I describe below (from memory) is accurate.

I downloaded freewrap641.zip and unzipped it in ~/bin (uncomment the lines in your ~/.bash_profile to add ~/bin to you path). I then created an update script to grab the latest hgk and run freewrap on it:
$ cat update_hgk.sh
#!/bin/sh

cd ~/bin &&\
wget -O hgk.tcl http://selenic.com/repo/index.cgi/hg-stable/raw-file/tip/contrib/hgk && \
chmod 755 hgk.tcl && \
freewrap hgk.tcl

Running this creates ~/bin/hgk.exe. Then all you need to do is ensure you have hgk enabled in ~/.hgrc:
[extensions]
hgext.hgk =

After those steps "hg view" works fine. Whenever you upgrade mercurial just remember to run the update_hgk.sh script to ensure your hgk executable is up-to-date.

sofeng said...

Jonathan,
Thanks for the tip! I will try it out.
-sofeng

Unknown said...

Oh yeah, one more thing. Depending on your env you may need to create a Windows hg "executable"; freewrap creates a Windows executable and it doesn't like calling the Cygwin hg python script. Coupled with the previous enabling of ~/bin, this did the trick for me:
$ cat ~/bin/hg.bat
@echo off
C:\cygwin\bin\bash.exe -c "/bin/hg %*"

Unknown said...

This really simplifies the whole thing:
Using mercurial on windows with cygwin

TortoiseHg-0.4-rc2 just works. Sure, you have to use "hgtk log" instead of "hg view", but with only one installation it works in Explorer, in Cygwin, and in Eclipse. The only downside is that I can't seem to find a way to use different merge tools when in Cygwin (prefer vi) and when using the Explorer integration (prefer GUI tool).

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.