mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
codemod: use pycompat.iswindows
This is done by: sed -i "s/pycompat\.osname == 'nt'/pycompat.iswindows/" **/*.py sed -i "s/pycompat\.osname != 'nt'/not pycompat.iswindows/" **/*.py sed -i 's/pycompat.osname == "nt"/pycompat.iswindows/' **/*.py Differential Revision: https://phab.mercurial-scm.org/D1034
This commit is contained in:
parent
7b62930cd9
commit
2ae56b14de
@ -103,7 +103,7 @@ def geturl(path):
|
||||
pass
|
||||
if os.path.isdir(path):
|
||||
path = os.path.normpath(os.path.abspath(path))
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
path = '/' + util.normpath(path)
|
||||
# Module URL is later compared with the repository URL returned
|
||||
# by svn API, which is UTF-8.
|
||||
@ -254,7 +254,7 @@ def issvnurl(ui, url):
|
||||
try:
|
||||
proto, path = url.split('://', 1)
|
||||
if proto == 'file':
|
||||
if (pycompat.osname == 'nt' and path[:1] == '/'
|
||||
if (pycompat.iswindows and path[:1] == '/'
|
||||
and path[1:2].isalpha() and path[2:6].lower() == '%3a/'):
|
||||
path = path[:2] + ':/' + path[6:]
|
||||
path = urlreq.url2pathname(path)
|
||||
|
@ -74,7 +74,7 @@ def _usercachedir(ui):
|
||||
path = ui.configpath(longname, 'usercache', None)
|
||||
if path:
|
||||
return path
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
appdata = encoding.environ.get('LOCALAPPDATA',\
|
||||
encoding.environ.get('APPDATA'))
|
||||
if appdata:
|
||||
|
@ -51,7 +51,7 @@ from mercurial import (
|
||||
testedwith = 'ships-with-hg-core'
|
||||
|
||||
def uisetup(ui):
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
# no fork on Windows, but we can create a detached process
|
||||
# https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863.aspx
|
||||
# No stdlib constant exists for this value
|
||||
|
@ -116,7 +116,7 @@ def extsetup(ui):
|
||||
schemes.update(dict(ui.configitems('schemes')))
|
||||
t = templater.engine(lambda x: x)
|
||||
for scheme, url in schemes.items():
|
||||
if (pycompat.osname == 'nt' and len(scheme) == 1 and scheme.isalpha()
|
||||
if (pycompat.iswindows and len(scheme) == 1 and scheme.isalpha()
|
||||
and os.path.exists('%s:\\' % scheme)):
|
||||
raise error.Abort(_('custom scheme %s:// conflicts with drive '
|
||||
'letter %s:\\\n') % (scheme, scheme.upper()))
|
||||
|
@ -190,7 +190,7 @@ def extsetup(ui):
|
||||
if _encoding.lower() in problematic_encodings.split():
|
||||
for f in funcs.split():
|
||||
wrapname(f, wrapper)
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
for f in winfuncs.split():
|
||||
wrapname(f, wrapper)
|
||||
wrapname("mercurial.util.listdir", wrapperforlistdir)
|
||||
|
@ -210,7 +210,7 @@ def _modesetup(ui):
|
||||
mode = ui.config('color', 'pagermode', mode)
|
||||
|
||||
realmode = mode
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
from . import win32
|
||||
|
||||
term = encoding.environ.get('TERM')
|
||||
@ -379,7 +379,7 @@ def colorlabel(ui, msg, label):
|
||||
return msg
|
||||
|
||||
w32effects = None
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
import ctypes
|
||||
|
||||
_kernel32 = ctypes.windll.kernel32
|
||||
|
@ -2072,7 +2072,7 @@ def debugssl(ui, repo, source=None, **opts):
|
||||
If the update succeeds, retry the original operation. Otherwise, the cause
|
||||
of the SSL error is likely another issue.
|
||||
'''
|
||||
if pycompat.osname != 'nt':
|
||||
if not pycompat.iswindows:
|
||||
raise error.Abort(_('certificate chain building is only possible on '
|
||||
'Windows'))
|
||||
|
||||
|
@ -266,7 +266,7 @@ def openlog(opt, default):
|
||||
class MercurialHTTPServer(_mixin, httpservermod.httpserver, object):
|
||||
|
||||
# SO_REUSEADDR has broken semantics on windows
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
allow_reuse_address = 0
|
||||
|
||||
def __init__(self, ui, app, addr, handler, **kwargs):
|
||||
|
@ -29,7 +29,7 @@ except NameError:
|
||||
unicode = str
|
||||
|
||||
_languages = None
|
||||
if (pycompat.osname == 'nt'
|
||||
if (pycompat.iswindows
|
||||
and 'LANGUAGE' not in encoding.environ
|
||||
and 'LC_ALL' not in encoding.environ
|
||||
and 'LC_MESSAGES' not in encoding.environ
|
||||
|
@ -64,7 +64,7 @@ def listdir(path, stat=False, skip=None):
|
||||
result.append((fn, _mode_to_kind(st.st_mode)))
|
||||
return result
|
||||
|
||||
if pycompat.osname != 'nt':
|
||||
if not pycompat.iswindows:
|
||||
posixfile = open
|
||||
|
||||
_SCM_RIGHTS = 0x01
|
||||
|
@ -15,7 +15,7 @@ from . import (
|
||||
util,
|
||||
)
|
||||
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
from . import scmwindows as scmplatform
|
||||
else:
|
||||
from . import scmposix as scmplatform
|
||||
|
@ -41,7 +41,7 @@ from . import (
|
||||
vfs,
|
||||
)
|
||||
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
from . import scmwindows as scmplatform
|
||||
else:
|
||||
from . import scmposix as scmplatform
|
||||
@ -291,7 +291,7 @@ def checkportabilityalert(ui):
|
||||
val = ui.config('ui', 'portablefilenames')
|
||||
lval = val.lower()
|
||||
bval = util.parsebool(val)
|
||||
abort = pycompat.osname == 'nt' or lval == 'abort'
|
||||
abort = pycompat.iswindows or lval == 'abort'
|
||||
warn = bval or lval == 'warn'
|
||||
if bval is None and not (warn or abort or lval == 'ignore'):
|
||||
raise error.ConfigError(
|
||||
|
@ -477,7 +477,7 @@ def wrapsocket(sock, keyfile, certfile, ui, serverhostname=None):
|
||||
'for more info)\n'))
|
||||
|
||||
elif (e.reason == 'CERTIFICATE_VERIFY_FAILED' and
|
||||
pycompat.osname == 'nt'):
|
||||
pycompat.iswindows):
|
||||
|
||||
ui.warn(_('(the full certificate chain may not be available '
|
||||
'locally; see "hg help debugssl")\n'))
|
||||
@ -717,7 +717,7 @@ def _defaultcacerts(ui):
|
||||
# because we'll get a certificate verification error later and the lack
|
||||
# of loaded CA certificates will be the reason why.
|
||||
# Assertion: this code is only called if certificates are being verified.
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
if not _canloaddefaultcerts:
|
||||
ui.warn(_('(unable to load Windows CA certificates; see '
|
||||
'https://mercurial-scm.org/wiki/SecureConnections for '
|
||||
@ -749,7 +749,7 @@ def _defaultcacerts(ui):
|
||||
# / is writable on Windows. Out of an abundance of caution make sure
|
||||
# we're not on Windows because paths from _systemcacerts could be installed
|
||||
# by non-admin users.
|
||||
assert pycompat.osname != 'nt'
|
||||
assert not pycompat.iswindows
|
||||
|
||||
# Try to find CA certificates in well-known locations. We print a warning
|
||||
# when using a found file because we don't want too much silent magic
|
||||
|
@ -1347,7 +1347,7 @@ class gitsubrepo(abstractsubrepo):
|
||||
if e.errno != errno.ENOENT:
|
||||
raise error.Abort(genericerror % (
|
||||
self._path, encoding.strtolocal(e.strerror)))
|
||||
elif pycompat.osname == 'nt':
|
||||
elif pycompat.iswindows:
|
||||
try:
|
||||
self._gitexecutable = 'git.cmd'
|
||||
out, err = self._gitnodir(['--version'])
|
||||
|
@ -1041,7 +1041,7 @@ class ui(object):
|
||||
# gracefully and tell the user about their broken pager.
|
||||
shell = any(c in command for c in "|&;<>()$`\\\"' \t\n*?[#~=%")
|
||||
|
||||
if pycompat.osname == 'nt' and not shell:
|
||||
if pycompat.iswindows and not shell:
|
||||
# Window's built-in `more` cannot be invoked with shell=False, but
|
||||
# its `more.com` can. Hide this implementation detail from the
|
||||
# user so we can also get sane bad PAGER behavior. MSYS has
|
||||
|
@ -92,7 +92,7 @@ def isatty(fp):
|
||||
if isatty(stdout):
|
||||
stdout = os.fdopen(stdout.fileno(), pycompat.sysstr('wb'), 1)
|
||||
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
from . import windows as platform
|
||||
stdout = platform.winstdout(stdout)
|
||||
else:
|
||||
@ -1348,7 +1348,7 @@ def checkwinfilename(path):
|
||||
return _("filename ends with '%s', which is not allowed "
|
||||
"on Windows") % t
|
||||
|
||||
if pycompat.osname == 'nt':
|
||||
if pycompat.iswindows:
|
||||
checkosfilename = checkwinfilename
|
||||
timer = time.clock
|
||||
else:
|
||||
@ -1572,7 +1572,7 @@ def gui():
|
||||
# pure build; use a safe default
|
||||
return True
|
||||
else:
|
||||
return pycompat.osname == "nt" or encoding.environ.get("DISPLAY")
|
||||
return pycompat.iswindows or encoding.environ.get("DISPLAY")
|
||||
|
||||
def mktempcopy(name, emptyok=False, createmode=None):
|
||||
"""Create a temporary file with the same contents from name
|
||||
|
@ -543,7 +543,7 @@ class backgroundfilecloser(object):
|
||||
|
||||
# Only Windows/NTFS has slow file closing. So only enable by default
|
||||
# on that platform. But allow to be enabled elsewhere for testing.
|
||||
defaultenabled = pycompat.osname == 'nt'
|
||||
defaultenabled = pycompat.iswindows
|
||||
enabled = ui.configbool('worker', 'backgroundclose', defaultenabled)
|
||||
|
||||
if not enabled:
|
||||
|
@ -203,7 +203,7 @@ def _posixexitstatus(code):
|
||||
elif os.WIFSIGNALED(code):
|
||||
return -os.WTERMSIG(code)
|
||||
|
||||
if pycompat.osname != 'nt':
|
||||
if not pycompat.iswindows:
|
||||
_platformworker = _posixworker
|
||||
_exitstatus = _posixexitstatus
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user