color: fix crash in cmd.exe
When 'term' is None because it isn't in the environment, don't iterate over it.
Unfortunately, unsetting $TERM or exporting it as '' doesn't work in the tests,
so there's no way to simulate cmd.exe in the test suite.
--- a/hgext/color.py Wed Mar 18 21:44:25 2015 -0700
+++ b/hgext/color.py Tue Mar 31 14:27:45 2015 -0400
@@ -234,8 +234,6 @@
if os.name == 'nt':
term = os.environ.get('TERM')
# TERM won't be defined in a vanilla cmd.exe environment.
- if not term:
- realmode = 'win32'
# UNIX-like environments on Windows such as Cygwin and MSYS will
# set TERM. They appear to make a best effort attempt at setting it
@@ -244,7 +242,7 @@
# gibberish, we error on the side of selecting "win32". However, if
# w32effects is not defined, we almost certainly don't support
# "win32", so don't even try.
- if 'xterm' in term or not w32effects:
+ if (term and 'xterm' in term) or not w32effects:
realmode = 'ansi'
else:
realmode = 'win32'