D1034: codemod: use pycompat.iswindows
ryanmce added a comment. Thanks for making this nice improvement @quark! REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D1034 To: quark, #hg-reviewers, spectral, lothiraldan Cc: ryanmce, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D1034: codemod: use pycompat.iswindows
This revision was automatically updated to reflect the committed changes. Closed by commit rHG75979c8d4572: codemod: use pycompat.iswindows (authored by quark, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D1034?vs=2656=2683 REVISION DETAIL https://phab.mercurial-scm.org/D1034 AFFECTED FILES hgext/convert/subversion.py hgext/largefiles/lfutil.py hgext/logtoprocess.py hgext/schemes.py hgext/win32mbcs.py mercurial/color.py mercurial/debugcommands.py mercurial/hgweb/server.py mercurial/i18n.py mercurial/pure/osutil.py mercurial/rcutil.py mercurial/scmutil.py mercurial/sslutil.py mercurial/subrepo.py mercurial/ui.py mercurial/util.py mercurial/vfs.py mercurial/worker.py CHANGE DETAILS diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -203,7 +203,7 @@ elif os.WIFSIGNALED(code): return -os.WTERMSIG(code) -if pycompat.osname != 'nt': +if not pycompat.iswindows: _platformworker = _posixworker _exitstatus = _posixexitstatus diff --git a/mercurial/vfs.py b/mercurial/vfs.py --- a/mercurial/vfs.py +++ b/mercurial/vfs.py @@ -543,7 +543,7 @@ # 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: diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -92,7 +92,7 @@ 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 @@ 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 @@ # 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 diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1041,7 +1041,7 @@ # 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 diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -1347,7 +1347,7 @@ 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']) diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py --- a/mercurial/sslutil.py +++ b/mercurial/sslutil.py @@ -477,7 +477,7 @@ '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 @@ # 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 @@ # / 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
D1034: codemod: use pycompat.iswindows
quark updated this revision to Diff 2656. quark edited the summary of this revision. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D1034?vs=2637=2656 REVISION DETAIL https://phab.mercurial-scm.org/D1034 AFFECTED FILES hgext/convert/subversion.py hgext/largefiles/lfutil.py hgext/logtoprocess.py hgext/schemes.py hgext/win32mbcs.py mercurial/color.py mercurial/debugcommands.py mercurial/hgweb/server.py mercurial/i18n.py mercurial/pure/osutil.py mercurial/rcutil.py mercurial/scmutil.py mercurial/sslutil.py mercurial/subrepo.py mercurial/ui.py mercurial/util.py mercurial/vfs.py mercurial/worker.py CHANGE DETAILS diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -203,7 +203,7 @@ elif os.WIFSIGNALED(code): return -os.WTERMSIG(code) -if pycompat.osname != 'nt': +if not pycompat.iswindows: _platformworker = _posixworker _exitstatus = _posixexitstatus diff --git a/mercurial/vfs.py b/mercurial/vfs.py --- a/mercurial/vfs.py +++ b/mercurial/vfs.py @@ -543,7 +543,7 @@ # 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: diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -92,7 +92,7 @@ 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 @@ 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 @@ # 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 diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1041,7 +1041,7 @@ # 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 diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -1347,7 +1347,7 @@ 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']) diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py --- a/mercurial/sslutil.py +++ b/mercurial/sslutil.py @@ -477,7 +477,7 @@ '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 @@ # 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 @@ # / 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 diff --git a/mercurial/scmutil.py
D1034: codemod: use pycompat.iswindows
quark created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This is done by: sed -i "s/pycompat\.osname == 'nt'/pycompat.iswindows/" **/*.py REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D1034 AFFECTED FILES hgext/convert/subversion.py hgext/largefiles/lfutil.py hgext/logtoprocess.py hgext/schemes.py hgext/win32mbcs.py mercurial/color.py mercurial/hgweb/server.py mercurial/i18n.py mercurial/rcutil.py mercurial/scmutil.py mercurial/sslutil.py mercurial/subrepo.py mercurial/ui.py mercurial/util.py mercurial/vfs.py CHANGE DETAILS diff --git a/mercurial/vfs.py b/mercurial/vfs.py --- a/mercurial/vfs.py +++ b/mercurial/vfs.py @@ -543,7 +543,7 @@ # 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: diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -92,7 +92,7 @@ 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 @@ 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: diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1041,7 +1041,7 @@ # 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 diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -1347,7 +1347,7 @@ 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']) diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py --- a/mercurial/sslutil.py +++ b/mercurial/sslutil.py @@ -477,7 +477,7 @@ '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 @@ # 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 ' diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -41,7 +41,7 @@ vfs, ) -if pycompat.osname == 'nt': +if pycompat.iswindows: from . import scmwindows as scmplatform else: from . import scmposix as scmplatform @@ -291,7 +291,7 @@ 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( diff --git a/mercurial/rcutil.py b/mercurial/rcutil.py --- a/mercurial/rcutil.py +++ b/mercurial/rcutil.py @@ -15,7 +15,7 @@ util, ) -if pycompat.osname == 'nt': +if pycompat.iswindows: from . import scmwindows as scmplatform else: from . import scmposix as scmplatform diff --git a/mercurial/i18n.py b/mercurial/i18n.py --- a/mercurial/i18n.py +++ b/mercurial/i18n.py @@ -29,7 +29,7 @@ unicode = str _languages = None -if (pycompat.osname == 'nt' +if (pycompat.iswindows and 'LANGUAGE' not in encoding.environ