diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -16,6 +16,7 @@ from .i18n import _ from .node import nullid, short from . import ( + encoding, error, formatter, match, @@ -165,7 +166,7 @@ def _picktool(repo, ui, path, binary, sy return (force, force) # HGMERGE takes next precedence - hgmerge = os.environ.get("HGMERGE") + hgmerge = encoding.environ.get("HGMERGE") if hgmerge: if changedelete and not supportscd(hgmerge): return ":prompt", None diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py --- a/mercurial/hgweb/common.py +++ b/mercurial/hgweb/common.py @@ -13,6 +13,7 @@ import mimetypes import os from .. import ( + encoding, pycompat, util, ) @@ -191,7 +192,7 @@ def get_contact(config): """ return (config("web", "contact") or config("ui", "username") or - os.environ.get("EMAIL") or "") + encoding.environ.get("EMAIL") or "") def caching(web, req): tag = 'W/"%s"' % web.mtime diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -286,7 +286,8 @@ class hgweb(object): Modern servers should be using WSGI and should avoid this method, if possible. """ - if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): + if not encoding.environ.get('GATEWAY_INTERFACE', + '').startswith("CGI/1."): raise RuntimeError("This function is only intended to be " "called while running as a CGI script.") wsgicgi.launch(self) diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -186,7 +186,8 @@ class hgwebdir(object): self.lastrefresh = time.time() def run(self): - if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): + if not encoding.environ.get('GATEWAY_INTERFACE', + '').startswith("CGI/1."): raise RuntimeError("This function is only intended to be " "called while running as a CGI script.") wsgicgi.launch(self) diff --git a/mercurial/hgweb/wsgicgi.py b/mercurial/hgweb/wsgicgi.py --- a/mercurial/hgweb/wsgicgi.py +++ b/mercurial/hgweb/wsgicgi.py @@ -10,9 +10,8 @@ from __future__ import absolute_import -import os - from .. import ( + encoding, util, ) @@ -24,7 +23,7 @@ def launch(application): util.setbinary(util.stdin) util.setbinary(util.stdout) - environ = dict(os.environ.iteritems()) + environ = dict(encoding.environ.iteritems()) environ.setdefault('PATH_INFO', '') if environ.get('SERVER_SOFTWARE', '').startswith('Microsoft-IIS'): # IIS includes script_name in PATH_INFO diff --git a/mercurial/url.py b/mercurial/url.py --- a/mercurial/url.py +++ b/mercurial/url.py @@ -15,6 +15,7 @@ import socket from .i18n import _ from . import ( + encoding, error, httpconnection as httpconnectionmod, keepalive, @@ -118,8 +119,8 @@ class proxyhandler(urlreq.proxyhandler): if ui.config("http_proxy", "host"): for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]: try: - if env in os.environ: - del os.environ[env] + if env in encoding.environ: + del encoding.environ[env] except OSError: pass diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -177,7 +177,7 @@ def _is_win_9x(): try: return sys.getwindowsversion()[3] == 1 except AttributeError: - return 'command' in os.environ.get('comspec', '') + return 'command' in encoding.environ.get('comspec', '') def openhardlinks(): return not _is_win_9x() @@ -303,7 +303,7 @@ def findexe(command): PATH isn't searched if command is an absolute or relative path. An extension from PATHEXT is found and added if not present. If command isn't found None is returned.''' - pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD') + pathext = encoding.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD') pathexts = [ext for ext in pathext.lower().split(pycompat.ospathsep)] if os.path.splitext(command)[1].lower() in pathexts: pathexts = [''] @@ -319,7 +319,7 @@ def findexe(command): if pycompat.ossep in command: return findexisting(command) - for path in os.environ.get('PATH', '').split(pycompat.ospathsep): + for path in encoding.environ.get('PATH', '').split(pycompat.ospathsep): executable = findexisting(os.path.join(path, command)) if executable is not None: return executable