[PATCH 1 of 1] util.system: Clear environment vars before deleting
Mads Kiilerich
mads at kiilerich.com
Sun Sep 20 07:10:56 CDT 2009
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1253448632 -7200
# Node ID d46ad92cd366d52c831df6c4d4187e950a82f35a
# Parent bccf780f78ed7cab3fac47bfac68fdd56a059ba7
util.system: Clear environment vars before deleting
Environment variables can't (easily) be deleted in Python on Solaris:
Python 2.6.2 (r262:71600, May 27 2009, 13:06:14) [C] on sunos5
>>> import os
>>> os.environ['x'] = 'y'
>>> os.system('echo $x')
y
0
>>> del os.environ['x']
>>> os.system('echo $x')
y
0
>>> os.unsetenv('x')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'unsetenv'
>>>
Setting the variable to empty string is for must purposes sufficiently close to
deleting it.
test-hook failed because the HG_PENDING variable had been set for running the
hook, but when the following del was a noop the variable was thus set in too
many hooks.
diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -22,6 +22,7 @@
return util.popen(s, 'rb')
finally:
if prevgitdir is None:
+ os.environ['GIT_DIR'] = '' # del is noop on solaris
del os.environ['GIT_DIR']
else:
os.environ['GIT_DIR'] = prevgitdir
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -207,6 +207,7 @@
for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
try:
if env in os.environ:
+ os.environ[env] = '' # del is noop on solaris
del os.environ[env]
except OSError:
pass
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -387,6 +387,7 @@
finally:
for k, v in oldenv.iteritems():
if v is None:
+ os.environ[k] = '' # del is noop on solaris
del os.environ[k]
else:
os.environ[k] = v
More information about the Mercurial-devel
mailing list