comparison mercurial/util.py @ 13734:16118b4859a1

util: add Mac-specific check whether we're in a GUI session (issue2553) The previous test assumed that 'os.name' was "mac" on Mac OS X. This is not the case; 'mac' was classic Mac OS, whereas Mac OS X has 'os.name' be 'posix'. Please note that this change will break Mercurial on hypothetical non-Mac OS X deployments of Darwin. Credit to Brodie Rao for thinking of CGSessionCopyCurrentDictionary() and Kevin Bullock for testing.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 23 Mar 2011 09:43:34 +0100
parents d724a69309e0
children bc7b5d1c1999
comparison
equal deleted inserted replaced
13733:4e2690a764c1 13734:16118b4859a1
767 function if need.''' 767 function if need.'''
768 return path.split(os.sep) 768 return path.split(os.sep)
769 769
770 def gui(): 770 def gui():
771 '''Are we running in a GUI?''' 771 '''Are we running in a GUI?'''
772 return os.name == "nt" or os.name == "mac" or os.environ.get("DISPLAY") 772 if sys.platform == 'darwin':
773 if 'SSH_CONNECTION' in os.environ:
774 # handle SSH access to a box where the user is logged in
775 return False
776 elif getattr(osutil, 'isgui', None):
777 # check if a CoreGraphics session is available
778 return osutil.isgui()
779 else:
780 # pure build; use a safe default
781 return True
782 else:
783 return os.name == "nt" or os.environ.get("DISPLAY")
773 784
774 def mktempcopy(name, emptyok=False, createmode=None): 785 def mktempcopy(name, emptyok=False, createmode=None):
775 """Create a temporary file with the same contents from name 786 """Create a temporary file with the same contents from name
776 787
777 The permission bits are copied from the original file. 788 The permission bits are copied from the original file.