diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -42,6 +42,8 @@ else: from .. import posix as platform +UNSET_ENV = object() + def isatty(fp): try: @@ -466,7 +468,11 @@ env = dict(encoding.environ) if environ: - env.update((k, py2shell(v)) for k, v in pycompat.iteritems(environ)) + for k, v in pycompat.iteritems(environ): + if v is UNSET_ENV: + env.pop(k, None) + else: + env[k] = py2shell(v) env[b'HG'] = hgexecutable() return env