[PATCH] color: Do not pass --color, --no-color parameters to wrapped function

David Soria Parra sn_ at gmx.net
Tue Dec 8 16:39:26 CST 2009


 hgext/color.py |  4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)


# HG changeset patch
# User David Soria Parra <dsp at php.net>
# Date 1260311944 -3600
# Node ID 4b773fcc8969ca20e32bd3ce824e95aaeff7c795
# Parent  bccf780f78ed7cab3fac47bfac68fdd56a059ba7
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.

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -242,10 +242,14 @@
         if (opts['no_color'] or opts['color'] == 'never' or
             (opts['color'] == 'auto' and (os.environ.get('TERM') == 'dumb'
                                           or not sys.__stdout__.isatty()))):
+            del opts['no_color']
+            del opts['color']
             return orig(*args, **opts)
 
         oldshowpatch = extensions.wrapfunction(cmdutil.changeset_printer,
                                                'showpatch', colorshowpatch)
+        del opts['no_color']
+        del opts['color']
         try:
             if func is not None:
                 return func(orig, *args, **opts)


More information about the Mercurial-devel mailing list