[issue2553] util.py gui() method incorrect on Mac OS X

Steve Streeting bugs at mercurial.selenic.com
Tue Dec 14 04:13:24 CST 2010


New submission from Steve Streeting <steve at torusknot.com>:

Mercurial 1.7+20101101

I recently discovered a problem in Mercurial on Mac OS X which was 
originally reported by one of my users of SourceTree: the method by which 
Mercurial uses to determine whether the OS has a GUI available (util.py's 
gui() method) doesn't work on Mac OS X if the user chose not to install X11 
when they installed Snow Leopard. This is because the test is:

return os.name == "nt" or os.name == "mac" or os.environ.get("DISPLAY")

os.name on Snow Leopard's default Python install returns 'posix' which 
obviously doesn't match, and if X11 is not installed, there is no DISPLAY 
env var, so this function returns False.

The problem arises when "gui=True" is specified in the merge tool 
configuration, which SourceTree was doing for completeness when configuring 
merge tools. On a Snow Leopard machine which no X11, this merge tool doesn't 
work, and hg resolve simply reports "tool <blah> requires a GUI", before re-
running the internal merge and failing with conflicts.

X11 is installed by default in the OS X setup so it's only if the user 
deselects it during install, *and* the merge tool sets the gui=True option, 
that this problem will arise.  

I have worked around this for now by setting gui=False in the merge tool 
options. It's not strictly correct, but it makes it work again for OS X 
users without X11. 

I would suggest that instead of the current os.name tests in gui(), that you 
replace them with platform.platform() - this begins with 'Darwin' on OS X.

----------
messages: 14654
nosy: sjstreeting
priority: bug
status: unread
title: util.py gui() method incorrect on Mac OS X

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue2553>
____________________________________________________


More information about the Mercurial-devel mailing list