Swift Software Group

How to install and configure TortoiseHg on Mac

I finally got fed up with SourceTree and installed TortoiseHg on my Mac development machine. Read on:

Xcode Configuration

For best results make sure you have the latest XCode and Command Line Tools installed (XCode 5 and Command Line Tools September 2013 at the time of this writing). You can get them from the Apple Developer Downloads site.

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

1. Install / Update Ruby

ruby -v

should return something like:

ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]

You can skip the rest of this section if you have Ruby already installed.

Install the Ruby Version Manager and Ruby

curl -L https://get.rvm.io | bash -s stable --ruby
source /Users/yourname/.rvm/scripts/rvm

2. Install Homebrew

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Follow the instructions in the script. The installation will take a few minutes.

Verify your brew installation

brew doctor

This returned a few problems for me, but the output will vary depending on the existing system configuration.

Warning: An outdated version of Git was detected in your PATH.
Git 1.7.10 or newer is required to perform checkouts over HTTPS from GitHub.
Please upgrade: brew upgrade git

Warning: /Library/Frameworks/Mono.framework detected
This can be picked up by CMake's build system and likely cause the build to
fail. You may need to move this file out of the way to compile CMake.

Warning: You have MacPorts or Fink installed:
    /Users/yourname/.rvm/bin/port, /opt/local/bin/port

This can cause trouble. You don't have to uninstall them, but you may want to
temporarily move them out of the way, e.g.

    sudo mv /opt/local ~/macports

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. 

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
    echo export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile

Warning: Your Xcode (x.y.z) is outdated
Please install Xcode a.b.c

The issues will depend on your specific installation. Use your best judgement about what to fix and what to ignore. Fixing one by one:

Warning: You have MacPorts or Fink installed

sudo mv /opt/local ~/macports

Warning: /usr/bin occurs before /usr/local/bin

export PATH=/usr/local/bin:$PATH
echo export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile

Warning: An outdated version of Git was detected in your PATH.

brew upgrade git

or if you do not have Git at all:

brew install git

Warning: Your Xcode (x.y.z) is outdated

You can ignore this one.

Warning: /Library/Frameworks/Mono.framework detected

You can ignore this one.

3. Install Python packages

I had Python already installed before Homebrew, so I had to amend PYTHONPATH like so:

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH  
echo export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH" >> ~/.bash_profile

Then install PyQt (this also installs qt and sip):

brew install pyqt

Install QScintilla

brew install qscintilla2

Install Python Package Mananger (pip)

sudo easy_install pip

Install Pygments, iniparse and Mercurial Python packages. If you have Mercurial already, this will update it to the latest version.

sudo pip install -U Pygments iniparse Mercurial

4. Install TortoiseHg

Clone TortoiseHg repository using Mercurial:

hg clone http://bitbucket.org/tortoisehg/thg/ ~/Tools/TortoiseHg
cd ~/Tools/TortoiseHg/
hg update stable

Quick test. You should see TortoiseHg Workbench running:

./thg log

5. Install TortoiseHg Mac App

Clone thg-mac-app repository

hg clone https://bitbucket.org/skrysmanski/thg-mac-app ~/Tools/thg-mac-app

Set the TORTOISEHG_PATH variable

cp -p ~/Tools/thg-mac-app/tortoisehg-path.sh ~/

Edit ~/tortoisehg-path.sh so it points to ~/Tools/TortoiseHg. This is what ~/tortoisehg-path.sh looks like after the change:


export TORTOISEHG_PATH=~/Tools/TortoiseHg

Install TortoiseHg.app

Option + Drag the TortoiseHg.app from ~/Tools/thg-mac-app to your Applications folder.