[PATCH] util: add Mac-specific check whether we're in a GUI session (issue2553)
Mads Kiilerich
mads at kiilerich.com
Wed Mar 23 10:00:10 UTC 2011
On 03/23/2011 09:46 AM, Dan Villiom Podlaski Christiansen wrote:
> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen<danchr at gmail.com>
> # Date 1300869814 -3600
> # Node ID 6dda7d7ae77e570d6f5d3ad1a6ac50dcf839cc37
> # Parent 0489f917af50e4818fb101aa4d065cc109a8631e
> 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.
...
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -769,7 +769,18 @@ def splitpath(path):
>
> def gui():
> '''Are we running in a GUI?'''
> - return os.name == "nt" or os.name == "mac" or os.environ.get("DISPLAY")
> + if sys.platform == 'darwin':
> + if 'SSH_CONNECTION' in os.environ:
> + # handle SSH access to a box where the user is logged in
> + return False
Hardcore Mac users don't use X and forwarding over ssh?
> + elif getattr(osutil, 'isgui', None):
> + # check if a CoreGraphics session is available
> + return osutil.isgui()
> + else:
> + # pure build; use a safe default
> + return True
(It would perhaps be a bit cleaner to put a stub in osutil.py.)
/Mads
More information about the Mercurial-devel
mailing list