comparison hgext/color.py @ 10045:d1f9640e9a67

color: Do not pass --color, --no-color parameters to wrapped function Passing the --color and --no-color parameter to the wrapped function can cause a invalid argument exception if the wrapped function doesn't accepts a **opts dict.
author David Soria Parra <dsp@php.net>
date Fri, 11 Dec 2009 11:04:31 +0100
parents af04a3dea4cd
children 0c23b0b3516b
comparison
equal deleted inserted replaced
10044:dc5462d94a72 10045:d1f9640e9a67
280 def nocolor(orig, *args, **opts): 280 def nocolor(orig, *args, **opts):
281 281
282 if (opts['no_color'] or opts['color'] == 'never' or 282 if (opts['no_color'] or opts['color'] == 'never' or
283 (opts['color'] == 'auto' and (os.environ.get('TERM') == 'dumb' 283 (opts['color'] == 'auto' and (os.environ.get('TERM') == 'dumb'
284 or not sys.__stdout__.isatty()))): 284 or not sys.__stdout__.isatty()))):
285 del opts['no_color']
286 del opts['color']
285 return orig(*args, **opts) 287 return orig(*args, **opts)
286 288
287 oldshowpatch = extensions.wrapfunction(cmdutil.changeset_printer, 289 oldshowpatch = extensions.wrapfunction(cmdutil.changeset_printer,
288 'showpatch', colorshowpatch) 290 'showpatch', colorshowpatch)
291 del opts['no_color']
292 del opts['color']
289 try: 293 try:
290 if func is not None: 294 if func is not None:
291 return func(orig, *args, **opts) 295 return func(orig, *args, **opts)
292 return orig(*args, **opts) 296 return orig(*args, **opts)
293 finally: 297 finally: