[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
cjerdonek at webkit.org
cjerdonek at webkit.org
Wed Mar 17 18:29:27 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 9cb855c1de980457a84778eb88ae0fe3cba5c5ec
Author: cjerdonek at webkit.org <cjerdonek at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Mar 9 08:30:46 2010 +0000
Simplified check-webkit-style's argument parsing code by removing
support for the vestigial "extra flag values" parameter.
Reviewed by Shinichiro Hamaji.
https://bugs.webkit.org/show_bug.cgi?id=34677
The "extra flag values" parameter was needed before WebKit
forked check-webkit-style from Google. It was used to pass
through the option parser those command-line flags that WebKit
required but that Google's parser did not support (the --git-commit
flag in particular).
We can remove the parameter now because it is no longer
needed and unnecessarily clutters the argument-parsing code.
* Scripts/webkitpy/style/optparser.py:
- Removed the extra_flag_values parameter from the
CommandOptionValues class's constructor.
- Removed the extra_flags parameter from the ArgumentParser
class's parse() method.
* Scripts/webkitpy/style/optparser_unittest.py:
- Removed from the unit tests all references to the
extra_flag_values variable.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 22fafe8..4456894 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,30 @@
+2010-03-09 Chris Jerdonek <cjerdonek at webkit.org>
+
+ Reviewed by Shinichiro Hamaji.
+
+ Simplified check-webkit-style's argument parsing code by removing
+ support for the vestigial "extra flag values" parameter.
+
+ https://bugs.webkit.org/show_bug.cgi?id=34677
+
+ The "extra flag values" parameter was needed before WebKit
+ forked check-webkit-style from Google. It was used to pass
+ through the option parser those command-line flags that WebKit
+ required but that Google's parser did not support (the --git-commit
+ flag in particular).
+ We can remove the parameter now because it is no longer
+ needed and unnecessarily clutters the argument-parsing code.
+
+ * Scripts/webkitpy/style/optparser.py:
+ - Removed the extra_flag_values parameter from the
+ CommandOptionValues class's constructor.
+ - Removed the extra_flags parameter from the ArgumentParser
+ class's parse() method.
+
+ * Scripts/webkitpy/style/optparser_unittest.py:
+ - Removed from the unit tests all references to the
+ extra_flag_values variable.
+
2010-03-08 Kent Tamura <tkent at chromium.org>
Reviewed by Dimitri Glazkov.
diff --git a/WebKitTools/Scripts/webkitpy/style/optparser.py b/WebKitTools/Scripts/webkitpy/style/optparser.py
index 4137c8b..97ea6c9 100644
--- a/WebKitTools/Scripts/webkitpy/style/optparser.py
+++ b/WebKitTools/Scripts/webkitpy/style/optparser.py
@@ -118,18 +118,12 @@ class DefaultCommandOptionValues(object):
self.verbosity = verbosity
-# FIXME: Eliminate support for "extra_flag_values".
-#
# This class should not have knowledge of the flag key names.
class CommandOptionValues(object):
"""Stores the option values passed by the user via the command line.
Attributes:
- extra_flag_values: A string-string dictionary of all flag key-value
- pairs that are not otherwise represented by this
- class. The default is the empty dictionary.
-
filter_rules: The list of filter rules provided by the user.
These rules are appended to the base rules and
path-specific rules and so take precedence over
@@ -148,13 +142,10 @@ class CommandOptionValues(object):
"""
def __init__(self,
- extra_flag_values=None,
filter_rules=None,
git_commit=None,
output_format="emacs",
verbosity=1):
- if extra_flag_values is None:
- extra_flag_values = {}
if filter_rules is None:
filter_rules = []
@@ -168,7 +159,6 @@ class CommandOptionValues(object):
"value must be an integer between 1-5 inclusive. "
'Value given: "%s".' % verbosity)
- self.extra_flag_values = extra_flag_values
self.filter_rules = filter_rules
self.git_commit = git_commit
self.output_format = output_format
@@ -177,8 +167,6 @@ class CommandOptionValues(object):
# Useful for unit testing.
def __eq__(self, other):
"""Return whether this instance is equal to another."""
- if self.extra_flag_values != other.extra_flag_values:
- return False
if self.filter_rules != other.filter_rules:
return False
if self.git_commit != other.git_commit:
@@ -212,8 +200,7 @@ class ArgumentPrinter(object):
options: A CommandOptionValues instance.
"""
- flags = options.extra_flag_values.copy()
-
+ flags = {}
flags['output'] = options.output_format
flags['verbose'] = options.verbosity
# Only include the filter flag if user-provided rules are present.
@@ -335,15 +322,11 @@ class ArgumentParser(object):
filters.append(filter)
return filters
- def parse(self, args, extra_flags=None):
+ def parse(self, args):
"""Parse the command line arguments to check-webkit-style.
Args:
args: A list of command-line arguments as returned by sys.argv[1:].
- extra_flags: A list of flags whose values we want to extract, but
- are not supported by the CommandOptionValues class.
- An example flag "new_flag=". This defaults to the
- empty list.
Returns:
A tuple of (filenames, options)
@@ -352,22 +335,12 @@ class ArgumentParser(object):
options: A CommandOptionValues instance.
"""
- if extra_flags is None:
- extra_flags = []
-
output_format = self.default_options.output_format
verbosity = self.default_options.verbosity
- # The flags already supported by the CommandOptionValues class.
+ # The flags that the CommandOptionValues class supports.
flags = ['help', 'output=', 'verbose=', 'filter=', 'git-commit=']
- for extra_flag in extra_flags:
- if extra_flag in flags:
- raise ValueError('Flag \'%(extra_flag)s is duplicated '
- 'or already supported.' %
- {'extra_flag': extra_flag})
- flags.append(extra_flag)
-
try:
(opts, filenames) = getopt.getopt(args, '', flags)
except getopt.GetoptError:
@@ -377,7 +350,6 @@ class ArgumentParser(object):
# sys.exit when needing to interrupt execution.
self._exit_with_usage('Invalid arguments.')
- extra_flag_values = {}
git_commit = None
filter_rules = []
@@ -395,7 +367,7 @@ class ArgumentParser(object):
self._exit_with_categories()
filter_rules = self._parse_filter_flag(val)
else:
- extra_flag_values[opt] = val
+ raise ValueError('Invalid option: "%s"' % opt)
# Check validity of resulting values.
if filenames and (git_commit != None):
@@ -414,8 +386,7 @@ class ArgumentParser(object):
raise ValueError('Invalid --verbose value %s: value must '
'be between 1-5.' % verbosity)
- options = CommandOptionValues(extra_flag_values=extra_flag_values,
- filter_rules=filter_rules,
+ options = CommandOptionValues(filter_rules=filter_rules,
git_commit=git_commit,
output_format=output_format,
verbosity=verbosity)
diff --git a/WebKitTools/Scripts/webkitpy/style/optparser_unittest.py b/WebKitTools/Scripts/webkitpy/style/optparser_unittest.py
index f23c5d1..e4c75fb 100644
--- a/WebKitTools/Scripts/webkitpy/style/optparser_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/style/optparser_unittest.py
@@ -52,19 +52,16 @@ class ArgumentPrinterTest(unittest.TestCase):
output_format='emacs',
verbosity=3,
filter_rules=[],
- git_commit=None,
- extra_flag_values={}):
- return ProcessorOptions(extra_flag_values=extra_flag_values,
- filter_rules=filter_rules,
+ git_commit=None):
+ return ProcessorOptions(filter_rules=filter_rules,
git_commit=git_commit,
output_format=output_format,
verbosity=verbosity)
def test_to_flag_string(self):
- options = self._create_options('vs7', 5, ['+foo', '-bar'], 'git',
- {'a': 0, 'z': 1})
- self.assertEquals('--a=0 --filter=+foo,-bar --git-commit=git '
- '--output=vs7 --verbose=5 --z=1',
+ options = self._create_options('vs7', 5, ['+foo', '-bar'], 'git')
+ self.assertEquals('--filter=+foo,-bar --git-commit=git '
+ '--output=vs7 --verbose=5',
self._printer.to_flag_string(options))
# This is to check that --filter and --git-commit do not
@@ -134,13 +131,6 @@ class ArgumentParserTest(unittest.TestCase):
parse(['--filter=+build']) # works
# Pass files and git-commit at the same time.
self.assertRaises(SystemExit, parse, ['--git-commit=', 'file.txt'])
- # Pass an extra flag already supported.
- self.assertRaises(ValueError, parse, [], ['filter='])
- parse([], ['extra=']) # works
- # Pass an extra flag with typo.
- self.assertRaises(SystemExit, parse, ['--extratypo='], ['extra='])
- parse(['--extra='], ['extra=']) # works
- self.assertRaises(ValueError, parse, [], ['extra=', 'extra='])
def test_parse_default_arguments(self):
@@ -176,14 +166,6 @@ class ArgumentParserTest(unittest.TestCase):
self.assertEquals(options.filter_rules,
["+build", "-whitespace"])
- # Pass extra flag values.
- (files, options) = parse(['--extra'], ['extra'])
- self.assertEquals(options.extra_flag_values, {'--extra': ''})
- (files, options) = parse(['--extra='], ['extra='])
- self.assertEquals(options.extra_flag_values, {'--extra': ''})
- (files, options) = parse(['--extra=x'], ['extra='])
- self.assertEquals(options.extra_flag_values, {'--extra': 'x'})
-
def test_parse_files(self):
parse = self._parse()
@@ -203,7 +185,6 @@ class CommandOptionValuesTest(unittest.TestCase):
"""Test __init__ constructor."""
# Check default parameters.
options = ProcessorOptions()
- self.assertEquals(options.extra_flag_values, {})
self.assertEquals(options.filter_rules, [])
self.assertEquals(options.git_commit, None)
self.assertEquals(options.output_format, "emacs")
@@ -219,12 +200,10 @@ class CommandOptionValuesTest(unittest.TestCase):
ProcessorOptions(verbosity=5) # works
# Check attributes.
- options = ProcessorOptions(extra_flag_values={"extra_value" : 2},
- filter_rules=["+"],
+ options = ProcessorOptions(filter_rules=["+"],
git_commit="commit",
output_format="vs7",
verbosity=3)
- self.assertEquals(options.extra_flag_values, {"extra_value" : 2})
self.assertEquals(options.filter_rules, ["+"])
self.assertEquals(options.git_commit, "commit")
self.assertEquals(options.output_format, "vs7")
@@ -236,13 +215,10 @@ class CommandOptionValuesTest(unittest.TestCase):
self.assertTrue(ProcessorOptions() == ProcessorOptions())
# Verify that a difference in any argument causes equality to fail.
- options = ProcessorOptions(extra_flag_values={"extra_value" : 1},
- filter_rules=["+"],
+ options = ProcessorOptions(filter_rules=["+"],
git_commit="commit",
output_format="vs7",
verbosity=1)
- self.assertFalse(options == ProcessorOptions(extra_flag_values=
- {"extra_value" : 2}))
self.assertFalse(options == ProcessorOptions(filter_rules=["-"]))
self.assertFalse(options == ProcessorOptions(git_commit="commit2"))
self.assertFalse(options == ProcessorOptions(output_format="emacs"))
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list