This is done by:
sed -i "s/pycompat\.sysplatform == 'darwin'/pycompat.isdarwin/" **/*.py
Plus a manual change to sslutil.py which involves indentation change that
cannot be done by sed.
( )
spectral |
hg-reviewers |
This is done by:
sed -i "s/pycompat\.sysplatform == 'darwin'/pycompat.isdarwin/" **/*.py
Plus a manual change to sslutil.py which involves indentation change that
cannot be done by sed.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/fsmonitor/__init__.py (2 lines) | |||
M | hgext/largefiles/lfutil.py (2 lines) | |||
M | mercurial/cffi/osutil.py (2 lines) | |||
M | mercurial/posix.py (2 lines) | |||
M | mercurial/scmposix.py (2 lines) | |||
M | mercurial/sslutil.py (6 lines) | |||
M | mercurial/util.py (2 lines) |
# only override the dirstate when Watchman is available for the repo | # only override the dirstate when Watchman is available for the repo | ||||
if util.safehasattr(self, '_fsmonitorstate'): | if util.safehasattr(self, '_fsmonitorstate'): | ||||
makedirstate(self, ds) | makedirstate(self, ds) | ||||
return ds | return ds | ||||
def extsetup(ui): | def extsetup(ui): | ||||
extensions.wrapfilecache( | extensions.wrapfilecache( | ||||
localrepo.localrepository, 'dirstate', wrapdirstate) | localrepo.localrepository, 'dirstate', wrapdirstate) | ||||
if pycompat.sysplatform == 'darwin': | if pycompat.isdarwin: | ||||
# An assist for avoiding the dangling-symlink fsevents bug | # An assist for avoiding the dangling-symlink fsevents bug | ||||
extensions.wrapfunction(os, 'symlink', wrapsymlink) | extensions.wrapfunction(os, 'symlink', wrapsymlink) | ||||
extensions.wrapfunction(merge, 'update', wrapupdate) | extensions.wrapfunction(merge, 'update', wrapupdate) | ||||
def wrapsymlink(orig, source, link_name): | def wrapsymlink(orig, source, link_name): | ||||
''' if we create a dangling symlink, also touch the parent dir | ''' if we create a dangling symlink, also touch the parent dir | ||||
to encourage fsevents notifications to work more correctly ''' | to encourage fsevents notifications to work more correctly ''' |
path = ui.configpath(longname, 'usercache', None) | path = ui.configpath(longname, 'usercache', None) | ||||
if path: | if path: | ||||
return path | return path | ||||
if pycompat.iswindows: | if pycompat.iswindows: | ||||
appdata = encoding.environ.get('LOCALAPPDATA',\ | appdata = encoding.environ.get('LOCALAPPDATA',\ | ||||
encoding.environ.get('APPDATA')) | encoding.environ.get('APPDATA')) | ||||
if appdata: | if appdata: | ||||
return os.path.join(appdata, longname) | return os.path.join(appdata, longname) | ||||
elif pycompat.sysplatform == 'darwin': | elif pycompat.isdarwin: | ||||
home = encoding.environ.get('HOME') | home = encoding.environ.get('HOME') | ||||
if home: | if home: | ||||
return os.path.join(home, 'Library', 'Caches', longname) | return os.path.join(home, 'Library', 'Caches', longname) | ||||
elif pycompat.isposix: | elif pycompat.isposix: | ||||
path = encoding.environ.get('XDG_CACHE_HOME') | path = encoding.environ.get('XDG_CACHE_HOME') | ||||
if path: | if path: | ||||
return os.path.join(path, longname) | return os.path.join(path, longname) | ||||
home = encoding.environ.get('HOME') | home = encoding.environ.get('HOME') |
import stat as statmod | import stat as statmod | ||||
from ..pure.osutil import * | from ..pure.osutil import * | ||||
from .. import ( | from .. import ( | ||||
pycompat, | pycompat, | ||||
) | ) | ||||
if pycompat.sysplatform == 'darwin': | if pycompat.isdarwin: | ||||
from . import _osutil | from . import _osutil | ||||
ffi = _osutil.ffi | ffi = _osutil.ffi | ||||
lib = _osutil.lib | lib = _osutil.lib | ||||
listdir_batch_size = 4096 | listdir_batch_size = 4096 | ||||
# tweakable number, only affects performance, which chunks | # tweakable number, only affects performance, which chunks | ||||
# of bytes do we get back from getattrlistbulk | # of bytes do we get back from getattrlistbulk |
def normcase(path): | def normcase(path): | ||||
return path.lower() | return path.lower() | ||||
# what normcase does to ASCII strings | # what normcase does to ASCII strings | ||||
normcasespec = encoding.normcasespecs.lower | normcasespec = encoding.normcasespecs.lower | ||||
# fallback normcase function for non-ASCII strings | # fallback normcase function for non-ASCII strings | ||||
normcasefallback = normcase | normcasefallback = normcase | ||||
if pycompat.sysplatform == 'darwin': | if pycompat.isdarwin: | ||||
def normcase(path): | def normcase(path): | ||||
''' | ''' | ||||
Normalize a filename for OS X-compatible comparison: | Normalize a filename for OS X-compatible comparison: | ||||
- escape-encode invalid characters | - escape-encode invalid characters | ||||
- decompose to NFD | - decompose to NFD | ||||
- lowercase | - lowercase | ||||
- omit ignored characters [200c-200f, 202a-202e, 206a-206f,feff] | - omit ignored characters [200c-200f, 202a-202e, 206a-206f,feff] |
if p != '/': | if p != '/': | ||||
path.extend(_rcfiles(os.path.join(p, root))) | path.extend(_rcfiles(os.path.join(p, root))) | ||||
path.extend(_rcfiles('/' + root)) | path.extend(_rcfiles('/' + root)) | ||||
return path | return path | ||||
def userrcpath(): | def userrcpath(): | ||||
if pycompat.sysplatform == 'plan9': | if pycompat.sysplatform == 'plan9': | ||||
return [encoding.environ['home'] + '/lib/hgrc'] | return [encoding.environ['home'] + '/lib/hgrc'] | ||||
elif pycompat.sysplatform == 'darwin': | elif pycompat.isdarwin: | ||||
return [os.path.expanduser('~/.hgrc')] | return [os.path.expanduser('~/.hgrc')] | ||||
else: | else: | ||||
confighome = encoding.environ.get('XDG_CONFIG_HOME') | confighome = encoding.environ.get('XDG_CONFIG_HOME') | ||||
if confighome is None or not os.path.isabs(confighome): | if confighome is None or not os.path.isabs(confighome): | ||||
confighome = os.path.expanduser('~/.config') | confighome = os.path.expanduser('~/.config') | ||||
return [os.path.expanduser('~/.hgrc'), | return [os.path.expanduser('~/.hgrc'), | ||||
os.path.join(confighome, 'hg', 'hgrc')] | os.path.join(confighome, 'hg', 'hgrc')] |
def _plainapplepython(): | def _plainapplepython(): | ||||
"""return true if this seems to be a pure Apple Python that | """return true if this seems to be a pure Apple Python that | ||||
* is unfrozen and presumably has the whole mercurial module in the file | * is unfrozen and presumably has the whole mercurial module in the file | ||||
system | system | ||||
* presumably is an Apple Python that uses Apple OpenSSL which has patches | * presumably is an Apple Python that uses Apple OpenSSL which has patches | ||||
for using system certificate store CAs in addition to the provided | for using system certificate store CAs in addition to the provided | ||||
cacerts file | cacerts file | ||||
""" | """ | ||||
if (pycompat.sysplatform != 'darwin' or | if (not pycompat.isdarwin or util.mainfrozen() or | ||||
util.mainfrozen() or not pycompat.sysexecutable): | not pycompat.sysexecutable): | ||||
return False | return False | ||||
exe = os.path.realpath(pycompat.sysexecutable).lower() | exe = os.path.realpath(pycompat.sysexecutable).lower() | ||||
return (exe.startswith('/usr/bin/python') or | return (exe.startswith('/usr/bin/python') or | ||||
exe.startswith('/system/library/frameworks/python.framework/')) | exe.startswith('/system/library/frameworks/python.framework/')) | ||||
_systemcacertpaths = [ | _systemcacertpaths = [ | ||||
# RHEL, CentOS, and Fedora | # RHEL, CentOS, and Fedora | ||||
'/etc/pki/tls/certs/ca-bundle.trust.crt', | '/etc/pki/tls/certs/ca-bundle.trust.crt', | ||||
if _plainapplepython(): | if _plainapplepython(): | ||||
dummycert = os.path.join( | dummycert = os.path.join( | ||||
os.path.dirname(pycompat.fsencode(__file__)), 'dummycert.pem') | os.path.dirname(pycompat.fsencode(__file__)), 'dummycert.pem') | ||||
if os.path.exists(dummycert): | if os.path.exists(dummycert): | ||||
return dummycert | return dummycert | ||||
# The Apple OpenSSL trick isn't available to us. If Python isn't able to | # The Apple OpenSSL trick isn't available to us. If Python isn't able to | ||||
# load system certs, we're out of luck. | # load system certs, we're out of luck. | ||||
if pycompat.sysplatform == 'darwin': | if pycompat.isdarwin: | ||||
# FUTURE Consider looking for Homebrew or MacPorts installed certs | # FUTURE Consider looking for Homebrew or MacPorts installed certs | ||||
# files. Also consider exporting the keychain certs to a file during | # files. Also consider exporting the keychain certs to a file during | ||||
# Mercurial install. | # Mercurial install. | ||||
if not _canloaddefaultcerts: | if not _canloaddefaultcerts: | ||||
ui.warn(_('(unable to load CA certificates; see ' | ui.warn(_('(unable to load CA certificates; see ' | ||||
'https://mercurial-scm.org/wiki/SecureConnections for ' | 'https://mercurial-scm.org/wiki/SecureConnections for ' | ||||
'how to configure Mercurial to avoid this message)\n')) | 'how to configure Mercurial to avoid this message)\n')) | ||||
return None | return None |
Note that this function does not use os.altsep because this is | Note that this function does not use os.altsep because this is | ||||
an alternative of simple "xxx.split(os.sep)". | an alternative of simple "xxx.split(os.sep)". | ||||
It is recommended to use os.path.normpath() before using this | It is recommended to use os.path.normpath() before using this | ||||
function if need.''' | function if need.''' | ||||
return path.split(pycompat.ossep) | return path.split(pycompat.ossep) | ||||
def gui(): | def gui(): | ||||
'''Are we running in a GUI?''' | '''Are we running in a GUI?''' | ||||
if pycompat.sysplatform == 'darwin': | if pycompat.isdarwin: | ||||
if 'SSH_CONNECTION' in encoding.environ: | if 'SSH_CONNECTION' in encoding.environ: | ||||
# handle SSH access to a box where the user is logged in | # handle SSH access to a box where the user is logged in | ||||
return False | return False | ||||
elif getattr(osutil, 'isgui', None): | elif getattr(osutil, 'isgui', None): | ||||
# check if a CoreGraphics session is available | # check if a CoreGraphics session is available | ||||
return osutil.isgui() | return osutil.isgui() | ||||
else: | else: | ||||
# pure build; use a safe default | # pure build; use a safe default |