##// END OF EJS Templates
codemod: use pycompat.iswindows...
Jun Wu -
r34646:75979c8d default
parent child Browse files
Show More
@@ -103,7 +103,7 def geturl(path):
103 pass
103 pass
104 if os.path.isdir(path):
104 if os.path.isdir(path):
105 path = os.path.normpath(os.path.abspath(path))
105 path = os.path.normpath(os.path.abspath(path))
106 if pycompat.osname == 'nt':
106 if pycompat.iswindows:
107 path = '/' + util.normpath(path)
107 path = '/' + util.normpath(path)
108 # Module URL is later compared with the repository URL returned
108 # Module URL is later compared with the repository URL returned
109 # by svn API, which is UTF-8.
109 # by svn API, which is UTF-8.
@@ -254,7 +254,7 def issvnurl(ui, url):
254 try:
254 try:
255 proto, path = url.split('://', 1)
255 proto, path = url.split('://', 1)
256 if proto == 'file':
256 if proto == 'file':
257 if (pycompat.osname == 'nt' and path[:1] == '/'
257 if (pycompat.iswindows and path[:1] == '/'
258 and path[1:2].isalpha() and path[2:6].lower() == '%3a/'):
258 and path[1:2].isalpha() and path[2:6].lower() == '%3a/'):
259 path = path[:2] + ':/' + path[6:]
259 path = path[:2] + ':/' + path[6:]
260 path = urlreq.url2pathname(path)
260 path = urlreq.url2pathname(path)
@@ -74,7 +74,7 def _usercachedir(ui):
74 path = ui.configpath(longname, 'usercache', None)
74 path = ui.configpath(longname, 'usercache', None)
75 if path:
75 if path:
76 return path
76 return path
77 if pycompat.osname == 'nt':
77 if pycompat.iswindows:
78 appdata = encoding.environ.get('LOCALAPPDATA',\
78 appdata = encoding.environ.get('LOCALAPPDATA',\
79 encoding.environ.get('APPDATA'))
79 encoding.environ.get('APPDATA'))
80 if appdata:
80 if appdata:
@@ -51,7 +51,7 from mercurial import (
51 testedwith = 'ships-with-hg-core'
51 testedwith = 'ships-with-hg-core'
52
52
53 def uisetup(ui):
53 def uisetup(ui):
54 if pycompat.osname == 'nt':
54 if pycompat.iswindows:
55 # no fork on Windows, but we can create a detached process
55 # no fork on Windows, but we can create a detached process
56 # https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863.aspx
56 # https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863.aspx
57 # No stdlib constant exists for this value
57 # No stdlib constant exists for this value
@@ -116,7 +116,7 def extsetup(ui):
116 schemes.update(dict(ui.configitems('schemes')))
116 schemes.update(dict(ui.configitems('schemes')))
117 t = templater.engine(lambda x: x)
117 t = templater.engine(lambda x: x)
118 for scheme, url in schemes.items():
118 for scheme, url in schemes.items():
119 if (pycompat.osname == 'nt' and len(scheme) == 1 and scheme.isalpha()
119 if (pycompat.iswindows and len(scheme) == 1 and scheme.isalpha()
120 and os.path.exists('%s:\\' % scheme)):
120 and os.path.exists('%s:\\' % scheme)):
121 raise error.Abort(_('custom scheme %s:// conflicts with drive '
121 raise error.Abort(_('custom scheme %s:// conflicts with drive '
122 'letter %s:\\\n') % (scheme, scheme.upper()))
122 'letter %s:\\\n') % (scheme, scheme.upper()))
@@ -190,7 +190,7 def extsetup(ui):
190 if _encoding.lower() in problematic_encodings.split():
190 if _encoding.lower() in problematic_encodings.split():
191 for f in funcs.split():
191 for f in funcs.split():
192 wrapname(f, wrapper)
192 wrapname(f, wrapper)
193 if pycompat.osname == 'nt':
193 if pycompat.iswindows:
194 for f in winfuncs.split():
194 for f in winfuncs.split():
195 wrapname(f, wrapper)
195 wrapname(f, wrapper)
196 wrapname("mercurial.util.listdir", wrapperforlistdir)
196 wrapname("mercurial.util.listdir", wrapperforlistdir)
@@ -210,7 +210,7 def _modesetup(ui):
210 mode = ui.config('color', 'pagermode', mode)
210 mode = ui.config('color', 'pagermode', mode)
211
211
212 realmode = mode
212 realmode = mode
213 if pycompat.osname == 'nt':
213 if pycompat.iswindows:
214 from . import win32
214 from . import win32
215
215
216 term = encoding.environ.get('TERM')
216 term = encoding.environ.get('TERM')
@@ -379,7 +379,7 def colorlabel(ui, msg, label):
379 return msg
379 return msg
380
380
381 w32effects = None
381 w32effects = None
382 if pycompat.osname == 'nt':
382 if pycompat.iswindows:
383 import ctypes
383 import ctypes
384
384
385 _kernel32 = ctypes.windll.kernel32
385 _kernel32 = ctypes.windll.kernel32
@@ -2072,7 +2072,7 def debugssl(ui, repo, source=None, **op
2072 If the update succeeds, retry the original operation. Otherwise, the cause
2072 If the update succeeds, retry the original operation. Otherwise, the cause
2073 of the SSL error is likely another issue.
2073 of the SSL error is likely another issue.
2074 '''
2074 '''
2075 if pycompat.osname != 'nt':
2075 if not pycompat.iswindows:
2076 raise error.Abort(_('certificate chain building is only possible on '
2076 raise error.Abort(_('certificate chain building is only possible on '
2077 'Windows'))
2077 'Windows'))
2078
2078
@@ -266,7 +266,7 def openlog(opt, default):
266 class MercurialHTTPServer(_mixin, httpservermod.httpserver, object):
266 class MercurialHTTPServer(_mixin, httpservermod.httpserver, object):
267
267
268 # SO_REUSEADDR has broken semantics on windows
268 # SO_REUSEADDR has broken semantics on windows
269 if pycompat.osname == 'nt':
269 if pycompat.iswindows:
270 allow_reuse_address = 0
270 allow_reuse_address = 0
271
271
272 def __init__(self, ui, app, addr, handler, **kwargs):
272 def __init__(self, ui, app, addr, handler, **kwargs):
@@ -29,7 +29,7 except NameError:
29 unicode = str
29 unicode = str
30
30
31 _languages = None
31 _languages = None
32 if (pycompat.osname == 'nt'
32 if (pycompat.iswindows
33 and 'LANGUAGE' not in encoding.environ
33 and 'LANGUAGE' not in encoding.environ
34 and 'LC_ALL' not in encoding.environ
34 and 'LC_ALL' not in encoding.environ
35 and 'LC_MESSAGES' not in encoding.environ
35 and 'LC_MESSAGES' not in encoding.environ
@@ -64,7 +64,7 def listdir(path, stat=False, skip=None)
64 result.append((fn, _mode_to_kind(st.st_mode)))
64 result.append((fn, _mode_to_kind(st.st_mode)))
65 return result
65 return result
66
66
67 if pycompat.osname != 'nt':
67 if not pycompat.iswindows:
68 posixfile = open
68 posixfile = open
69
69
70 _SCM_RIGHTS = 0x01
70 _SCM_RIGHTS = 0x01
@@ -15,7 +15,7 from . import (
15 util,
15 util,
16 )
16 )
17
17
18 if pycompat.osname == 'nt':
18 if pycompat.iswindows:
19 from . import scmwindows as scmplatform
19 from . import scmwindows as scmplatform
20 else:
20 else:
21 from . import scmposix as scmplatform
21 from . import scmposix as scmplatform
@@ -41,7 +41,7 from . import (
41 vfs,
41 vfs,
42 )
42 )
43
43
44 if pycompat.osname == 'nt':
44 if pycompat.iswindows:
45 from . import scmwindows as scmplatform
45 from . import scmwindows as scmplatform
46 else:
46 else:
47 from . import scmposix as scmplatform
47 from . import scmposix as scmplatform
@@ -291,7 +291,7 def checkportabilityalert(ui):
291 val = ui.config('ui', 'portablefilenames')
291 val = ui.config('ui', 'portablefilenames')
292 lval = val.lower()
292 lval = val.lower()
293 bval = util.parsebool(val)
293 bval = util.parsebool(val)
294 abort = pycompat.osname == 'nt' or lval == 'abort'
294 abort = pycompat.iswindows or lval == 'abort'
295 warn = bval or lval == 'warn'
295 warn = bval or lval == 'warn'
296 if bval is None and not (warn or abort or lval == 'ignore'):
296 if bval is None and not (warn or abort or lval == 'ignore'):
297 raise error.ConfigError(
297 raise error.ConfigError(
@@ -477,7 +477,7 def wrapsocket(sock, keyfile, certfile,
477 'for more info)\n'))
477 'for more info)\n'))
478
478
479 elif (e.reason == 'CERTIFICATE_VERIFY_FAILED' and
479 elif (e.reason == 'CERTIFICATE_VERIFY_FAILED' and
480 pycompat.osname == 'nt'):
480 pycompat.iswindows):
481
481
482 ui.warn(_('(the full certificate chain may not be available '
482 ui.warn(_('(the full certificate chain may not be available '
483 'locally; see "hg help debugssl")\n'))
483 'locally; see "hg help debugssl")\n'))
@@ -717,7 +717,7 def _defaultcacerts(ui):
717 # because we'll get a certificate verification error later and the lack
717 # because we'll get a certificate verification error later and the lack
718 # of loaded CA certificates will be the reason why.
718 # of loaded CA certificates will be the reason why.
719 # Assertion: this code is only called if certificates are being verified.
719 # Assertion: this code is only called if certificates are being verified.
720 if pycompat.osname == 'nt':
720 if pycompat.iswindows:
721 if not _canloaddefaultcerts:
721 if not _canloaddefaultcerts:
722 ui.warn(_('(unable to load Windows CA certificates; see '
722 ui.warn(_('(unable to load Windows CA certificates; see '
723 'https://mercurial-scm.org/wiki/SecureConnections for '
723 'https://mercurial-scm.org/wiki/SecureConnections for '
@@ -749,7 +749,7 def _defaultcacerts(ui):
749 # / is writable on Windows. Out of an abundance of caution make sure
749 # / is writable on Windows. Out of an abundance of caution make sure
750 # we're not on Windows because paths from _systemcacerts could be installed
750 # we're not on Windows because paths from _systemcacerts could be installed
751 # by non-admin users.
751 # by non-admin users.
752 assert pycompat.osname != 'nt'
752 assert not pycompat.iswindows
753
753
754 # Try to find CA certificates in well-known locations. We print a warning
754 # Try to find CA certificates in well-known locations. We print a warning
755 # when using a found file because we don't want too much silent magic
755 # when using a found file because we don't want too much silent magic
@@ -1347,7 +1347,7 class gitsubrepo(abstractsubrepo):
1347 if e.errno != errno.ENOENT:
1347 if e.errno != errno.ENOENT:
1348 raise error.Abort(genericerror % (
1348 raise error.Abort(genericerror % (
1349 self._path, encoding.strtolocal(e.strerror)))
1349 self._path, encoding.strtolocal(e.strerror)))
1350 elif pycompat.osname == 'nt':
1350 elif pycompat.iswindows:
1351 try:
1351 try:
1352 self._gitexecutable = 'git.cmd'
1352 self._gitexecutable = 'git.cmd'
1353 out, err = self._gitnodir(['--version'])
1353 out, err = self._gitnodir(['--version'])
@@ -1041,7 +1041,7 class ui(object):
1041 # gracefully and tell the user about their broken pager.
1041 # gracefully and tell the user about their broken pager.
1042 shell = any(c in command for c in "|&;<>()$`\\\"' \t\n*?[#~=%")
1042 shell = any(c in command for c in "|&;<>()$`\\\"' \t\n*?[#~=%")
1043
1043
1044 if pycompat.osname == 'nt' and not shell:
1044 if pycompat.iswindows and not shell:
1045 # Window's built-in `more` cannot be invoked with shell=False, but
1045 # Window's built-in `more` cannot be invoked with shell=False, but
1046 # its `more.com` can. Hide this implementation detail from the
1046 # its `more.com` can. Hide this implementation detail from the
1047 # user so we can also get sane bad PAGER behavior. MSYS has
1047 # user so we can also get sane bad PAGER behavior. MSYS has
@@ -92,7 +92,7 def isatty(fp):
92 if isatty(stdout):
92 if isatty(stdout):
93 stdout = os.fdopen(stdout.fileno(), pycompat.sysstr('wb'), 1)
93 stdout = os.fdopen(stdout.fileno(), pycompat.sysstr('wb'), 1)
94
94
95 if pycompat.osname == 'nt':
95 if pycompat.iswindows:
96 from . import windows as platform
96 from . import windows as platform
97 stdout = platform.winstdout(stdout)
97 stdout = platform.winstdout(stdout)
98 else:
98 else:
@@ -1348,7 +1348,7 def checkwinfilename(path):
1348 return _("filename ends with '%s', which is not allowed "
1348 return _("filename ends with '%s', which is not allowed "
1349 "on Windows") % t
1349 "on Windows") % t
1350
1350
1351 if pycompat.osname == 'nt':
1351 if pycompat.iswindows:
1352 checkosfilename = checkwinfilename
1352 checkosfilename = checkwinfilename
1353 timer = time.clock
1353 timer = time.clock
1354 else:
1354 else:
@@ -1572,7 +1572,7 def gui():
1572 # pure build; use a safe default
1572 # pure build; use a safe default
1573 return True
1573 return True
1574 else:
1574 else:
1575 return pycompat.osname == "nt" or encoding.environ.get("DISPLAY")
1575 return pycompat.iswindows or encoding.environ.get("DISPLAY")
1576
1576
1577 def mktempcopy(name, emptyok=False, createmode=None):
1577 def mktempcopy(name, emptyok=False, createmode=None):
1578 """Create a temporary file with the same contents from name
1578 """Create a temporary file with the same contents from name
@@ -543,7 +543,7 class backgroundfilecloser(object):
543
543
544 # Only Windows/NTFS has slow file closing. So only enable by default
544 # Only Windows/NTFS has slow file closing. So only enable by default
545 # on that platform. But allow to be enabled elsewhere for testing.
545 # on that platform. But allow to be enabled elsewhere for testing.
546 defaultenabled = pycompat.osname == 'nt'
546 defaultenabled = pycompat.iswindows
547 enabled = ui.configbool('worker', 'backgroundclose', defaultenabled)
547 enabled = ui.configbool('worker', 'backgroundclose', defaultenabled)
548
548
549 if not enabled:
549 if not enabled:
@@ -203,7 +203,7 def _posixexitstatus(code):
203 elif os.WIFSIGNALED(code):
203 elif os.WIFSIGNALED(code):
204 return -os.WTERMSIG(code)
204 return -os.WTERMSIG(code)
205
205
206 if pycompat.osname != 'nt':
206 if not pycompat.iswindows:
207 _platformworker = _posixworker
207 _platformworker = _posixworker
208 _exitstatus = _posixexitstatus
208 _exitstatus = _posixexitstatus
209
209
General Comments 0
You need to be logged in to leave comments. Login now