Get “hg view” to work in Mac OS X

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.)

Tags: , ,

8 Responses to “Get “hg view” to work in Mac OS X”

  1. igorekk Says:

    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

  2. gldnspud Says:

    @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.

  3. Indy Says:

    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.

  4. Ray Says:

    Thanks, it’s working great!

  5. Rich Says:

    Thanks for that walkthrough, was really useful!

  6. emilian Says:

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

  7. troy Says:

    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?

  8. troy Says:

    I found my answer here:

    http://henrik.nyh.se/2007/10/displaying-utf-8-correctly-in-leopard-terminal

Leave a Reply