Get “hg view” to work in Mac OS X

by gldnspud on February 6, 2008

I finally wanted to make hg view work.

When I downloaded a Mac OS X installer for Mercurial I noticed that the hgk extension (invoked by hg view) didn't work out of the box. No big deal right away.

Today I wanted to use it though!

Here's how to get it to work:

  1. Download and install a new version of Mercurial using the link above.

  2. Clone the Mercurial repository, then update it to the revision that you had just installed, and finally copy the hgk script to your personal bin directory:

    $ hg clone http://selenic.com/hg hg-upstream
    $ hg up -r b7f44f01a632
    $ cp hg-upstream/contrib/hgk ~/bin
    

    You could also copy it to your system-wide bin directory:

    $ sudo cp hg-upstream/contrib/hgk /usr/local/bin
    
  3. Edit your ~/.hgrc file to turn on the extension and point it to the location of your hgk script:

    [extensions]
    hgk=
    
    [hgk]
    path=/Users/myusername/bin/hgk
    

    (If you copied it to your system-wide bin directory, use /usr/local/bin/hgk for the path value.)

{ 13 comments }

igorekk February 7, 2008 at 1:29 am

When i installed Mercurial to my MacBook with Leo, i reviece error:
2.5.1 (r251:54863, Oct 5 2007, 21:08:09)
[GCC 4.0.1 (Apple Inc. build 5465)]
Traceback (most recent call last):
File “”, line 1, in
File “/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py”,
line 441, in getdefaultlocale
return _parse_localename(localename)
File “/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py”, line 373, in _parse_localename
raise ValueError, ‘unknown locale: %s’ % localename
ValueError: unknown locale: UTF-8

Solution:
Add 2 lines to ~/.profile
export LC_ALL=en_EN.UTF-8
export LANG=en_EN.UTF-8

gldnspud February 7, 2008 at 8:43 am

@igorekk:

Thanks for the comment and solution! Thankfully, it worked out of the box for me but I’m sure others will appreciate your help.

When I inspect LANG I get “en_US.UTF-8″ but LC_ALL is unset on my system. I can’t find right off hand where it’s being set though :) Not in any of my dot files and not in anything at the top level of /etc.

Indy March 8, 2008 at 12:25 pm

Thanks for this post. Worked nicely for me.

Just getting my head around Mercurial. I’ve been using Subversion for a while so it is a bit of a mindshift. Lack of a GUI is a serious issue for me.

Ray March 16, 2008 at 2:17 pm

Thanks, it’s working great!

Rich April 26, 2008 at 6:10 am

Thanks for that walkthrough, was really useful!

emilian May 13, 2008 at 11:10 pm

@igorekk : thanks for the fix, I could have wasted quite some time figuring that out !

troy June 17, 2008 at 1:09 am

I’m receiving a similar error:

Traceback (most recent call last):
File “/usr/local/bin/hg”, line 18, in
mercurial.util.set_binary(fp)
File “/Library/Python/2.5/site-packages/mercurial/demandimport.py”, line 74, in __getattribute__
self._load()
File “/Library/Python/2.5/site-packages/mercurial/demandimport.py”, line 46, in _load
mod = _origimport(head, globals, locals)
File “/Library/Python/2.5/site-packages/mercurial/util.py”, line 33, in
_encoding = locale.getlocale()[1]
File “/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py”, line 460, in getlocale
return _parse_localename(localename)
File “/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py”, line 373, in _parse_localename
raise ValueError, ‘unknown locale: %s’ % localename
ValueError: unknown locale: UTF-8

I’ve tried adding the following 2 lines to ~/.profile
export LC_ALL=en_EN.UTF-8
export LANG=en_EN.UTF-8

but this hasn’t helped. Can anyone offer any tips or suggestions?

troy June 17, 2008 at 9:08 am
Sai July 2, 2008 at 8:36 pm

Got it working. Thanks to this entry.

Gary July 29, 2008 at 8:03 am

The walk through looks great, but it doesn’t work for me. I am running Mac OS X v 10.5.4.

I cannot find the directory hg-upstream in my directory hierarchy. Nor can I find any file named “hgk”.

There is a file, hgk.py (as well as hgk.pyc and hgk.pyo) in /Library/Python/2.5/site-packages/hgext/. When I set the path to this directory, I get a permissions denied error on /Library/Python/2.5/site-packages/hgext/hgk.py.

I would like to get hgk to work with Netbeans, but I have been testing the configuration using commands under bash.

Any suggestions?

Humberto DiĆ³genes December 19, 2008 at 12:34 pm

I did the same thing to “convert-repo” and `hg convert` started working. Thanks!

Arthur Lutz December 31, 2008 at 6:11 am

You can also try out hgview as an nice alternative to “hg view”, quicker, nicer UI, a few extra functionnalities : http://www.logilab.org/project/hgview

Xiao May 14, 2010 at 8:50 am

Thanks for the tip. It works nicely.

Comments on this entry are closed.

Previous post:

Next post: