WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
proposed fix
2012-06-15_75825.patch (text/plain), 16.59 KB, created by
Balazs Ankes
on 2012-06-15 06:50:29 PDT
(
hide
)
Description:
proposed fix
Filename:
MIME Type:
Creator:
Balazs Ankes
Created:
2012-06-15 06:50:29 PDT
Size:
16.59 KB
patch
obsolete
>diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index f35edb5..7b47573 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,34 @@ >+2012-06-15 Balazs Ankes <bank@inf.u-szeged.hu> >+ >+ webkit-patch land should automatically add svn:mime-type for .png files >+ https://bugs.webkit.org/show_bug.cgi?id=75825 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Refactor the png.py to avoid code duplication. >+ >+ * Scripts/webkitpy/common/checksvnconfigfile.py: Added. >+ (check): >+ (_config_file_path): >+ (errorstr_autoprop): >+ (errorstr_png): >+ * Scripts/webkitpy/style/checkers/png.py: >+ (PNGChecker.check): >+ * Scripts/webkitpy/tool/commands/download.py: >+ (Land): >+ * Scripts/webkitpy/tool/steps/__init__.py: >+ * Scripts/webkitpy/tool/steps/addsvnmimetypeforpng.py: Added. >+ (AddSvnMimetypeForPng): >+ (AddSvnMimetypeForPng.__init__): >+ (AddSvnMimetypeForPng.run): >+ (AddSvnMimetypeForPng._check_pngs): >+ * Scripts/webkitpy/tool/steps/addsvnmimetypeforpng_unittest.py: Added. >+ (MockSCMDetector): >+ (MockSCMDetector.__init__): >+ (MockSCMDetector.display_name): >+ (AddSvnMimetypeForPngTest): >+ (AddSvnMimetypeForPngTest.test_run): >+ > 2012-06-15 Csaba Osztrogonác <ossy@webkit.org> > > Add ForceScheduler to build.webkit.org >diff --git a/Tools/Scripts/webkitpy/common/checksvnconfigfile.py b/Tools/Scripts/webkitpy/common/checksvnconfigfile.py >new file mode 100644 >index 0000000..fc53e22 >--- /dev/null >+++ b/Tools/Scripts/webkitpy/common/checksvnconfigfile.py >@@ -0,0 +1,66 @@ >+# Copyright (C) 2012 Balazs Ankes (bank@inf.u-szeged.hu) University of Szeged >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. Redistributions in binary form must reproduce the above copyright >+# notice, this list of conditions and the following disclaimer in the >+# documentation and/or other materials provided with the distribution. >+# >+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ >+# This file is used by: >+# webkitpy/tool/steps/addsvnmimetypeforpng.py >+# webkitpy/style/checkers/png.py >+ >+import os >+import re >+ >+ >+def check(self, host, fs): >+ """ >+ check the svn config file >+ return with three logical value: >+ is svn config file missing, is auto-props missing, is the svn:mime-type for png missing >+ """ >+ >+ config_file_path = _config_file_path(self, host, fs) >+ >+ try: >+ config_file = fs.read_text_file(config_file_path) >+ except IOError: >+ return (True, True, True) >+ >+ errorcode_autoprop = not re.search("^\s*enable-auto-props\s*=\s*yes", config_file, re.MULTILINE) >+ errorcode_png = not re.search("^\s*\*\.png\s*=\s*svn:mime-type=image/png", config_file, re.MULTILINE) >+ >+ return (False, errorcode_autoprop, errorcode_png) >+ >+ >+def _config_file_path(self, host, fs): >+ config_file = "" >+ if host.platform.is_win(): >+ config_file_path = fs.join(os.environ['APPDATA'], "Subversion\config") >+ else: >+ config_file_path = fs.join(fs.expanduser("~"), ".subversion/config") >+ return config_file_path >+ >+ >+def errorstr_autoprop(config_file_path): >+ return "Have to enable auto props in the subversion config file (" + config_file_path + " \"enable-auto-props = yes\"). " >+ >+ >+def errorstr_png(config_file_path): >+ return "Have to set the svn:mime-type in the subversion config file (" + config_file_path + " \"*.png = svn:mime-type=image/png\")." >diff --git a/Tools/Scripts/webkitpy/style/checkers/png.py b/Tools/Scripts/webkitpy/style/checkers/png.py >index 30b7a14..59dd6ff 100644 >--- a/Tools/Scripts/webkitpy/style/checkers/png.py >+++ b/Tools/Scripts/webkitpy/style/checkers/png.py >@@ -27,6 +27,7 @@ > import os > import re > >+from webkitpy.common import checksvnconfigfile > from webkitpy.common import read_checksum_from_png > from webkitpy.common.system.systemhost import SystemHost > from webkitpy.common.checkout.scm.detection import SCMDetector >@@ -54,38 +55,17 @@ class PNGChecker(object): > self._handle_style_error(0, 'image/png', 5, "Image lacks a checksum. Generate pngs using run-webkit-tests to ensure they have a checksum.") > > if detection == "git": >- config_file_path = self._config_file_path() >- there_is_enable_line = False >- there_is_png_line = False >- >- try: >- config_file = self._fs.read_text_file(config_file_path) >- except IOError: >- errorstr = "There is no " + config_file_path >- self._handle_style_error(0, 'image/png', 5, errorstr) >- return >- >- errorstr_autoprop = "Have to enable auto props in the subversion config file (" + config_file_path + " \"enable-auto-props = yes\"). " >- errorstr_png = "Have to set the svn:mime-type in the subversion config file (" + config_file_path + " \"*.png = svn:mime-type=image/png\")." >- >- for line in config_file.split('\n'): >- if not there_is_enable_line: >- match = re.search("^\s*enable-auto-props\s*=\s*yes", line) >- if match: >- there_is_enable_line = True >- errorstr_autoprop = "" >- continue >- >- if not there_is_png_line: >- match = re.search("^\s*\*\.png\s*=\s*svn:mime-type=image/png", line) >- if match: >- there_is_png_line = True >- errorstr_png = "" >- continue >- >- errorstr = errorstr_autoprop + errorstr_png >- if errorstr: >- self._handle_style_error(0, 'image/png', 5, errorstr) >+ (file_missing, autoprop_missing, png_missing) = checksvnconfigfile.check(self, self._host, self._fs) >+ config_file_path = checksvnconfigfile._config_file_path(self, self._host, self._fs) >+ >+ if file_missing: >+ self._handle_style_error(0, 'image/png', 5, "There is no SVN config file. (" + config_file_path + ")") >+ elif autoprop_missing and png_missing: >+ self._handle_style_error(0, 'image/png', 5, checksvnconfigfile.errorstr_autoprop(config_file_path) + checksvnconfigfile.errorstr_png(config_file_path)) >+ elif autoprop_missing: >+ self._handle_style_error(0, 'image/png', 5, checksvnconfigfile.errorstr_autoprop(config_file_path)) >+ elif png_missing: >+ self._handle_style_error(0, 'image/png', 5, checksvnconfigfile.errorstr_png(config_file_path)) > > elif detection == "svn": > prop_get = self._detector.propget("svn:mime-type", self._file_path) >@@ -93,10 +73,3 @@ class PNGChecker(object): > errorstr = "Set the svn:mime-type property (svn propset svn:mime-type image/png " + self._file_path + ")." > self._handle_style_error(0, 'image/png', 5, errorstr) > >- def _config_file_path(self): >- config_file = "" >- if self._host.platform.is_win(): >- config_file_path = self._fs.join(os.environ['APPDATA'], "Subversion\config") >- else: >- config_file_path = self._fs.join(self._fs.expanduser("~"), ".subversion/config") >- return config_file_path >diff --git a/Tools/Scripts/webkitpy/tool/commands/download.py b/Tools/Scripts/webkitpy/tool/commands/download.py >index 4f6b737..60c8920 100644 >--- a/Tools/Scripts/webkitpy/tool/commands/download.py >+++ b/Tools/Scripts/webkitpy/tool/commands/download.py >@@ -90,6 +90,7 @@ class Land(AbstractSequencedCommand): > argument_names = "[BUGID]" > show_in_main_help = True > steps = [ >+ steps.AddSvnMimetypeForPng, > steps.UpdateChangeLogsWithReviewer, > steps.ValidateReviewer, > steps.ValidateChangeLogs, # We do this after UpdateChangeLogsWithReviewer to avoid not having to cache the diff twice. >diff --git a/Tools/Scripts/webkitpy/tool/steps/__init__.py b/Tools/Scripts/webkitpy/tool/steps/__init__.py >index aca9706..56429e8 100644 >--- a/Tools/Scripts/webkitpy/tool/steps/__init__.py >+++ b/Tools/Scripts/webkitpy/tool/steps/__init__.py >@@ -27,6 +27,7 @@ > # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > > # FIXME: Is this the right way to do this? >+from webkitpy.tool.steps.addsvnmimetypeforpng import AddSvnMimetypeForPng > from webkitpy.tool.steps.applypatch import ApplyPatch > from webkitpy.tool.steps.applypatchwithlocalcommit import ApplyPatchWithLocalCommit > from webkitpy.tool.steps.applywatchlist import ApplyWatchList >diff --git a/Tools/Scripts/webkitpy/tool/steps/addsvnmimetypeforpng.py b/Tools/Scripts/webkitpy/tool/steps/addsvnmimetypeforpng.py >new file mode 100644 >index 0000000..dfeb4e7 >--- /dev/null >+++ b/Tools/Scripts/webkitpy/tool/steps/addsvnmimetypeforpng.py >@@ -0,0 +1,77 @@ >+# Copyright (C) 2012 Balazs Ankes (bank@inf.u-szeged.hu) University of Szeged >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. Redistributions in binary form must reproduce the above copyright >+# notice, this list of conditions and the following disclaimer in the >+# documentation and/or other materials provided with the distribution. >+# >+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ >+from webkitpy.tool.steps.abstractstep import AbstractStep >+from webkitpy.common import checksvnconfigfile >+from webkitpy.common.system.deprecated_logging import log >+from webkitpy.common.checkout.scm.detection import SCMDetector >+from webkitpy.common.system.systemhost import SystemHost >+ >+ >+class AddSvnMimetypeForPng(AbstractStep): >+ def __init__(self, tool, options, host=None, scm=None): >+ self._tool = tool >+ self._options = options >+ self._host = host or SystemHost() >+ self._fs = self._host.filesystem >+ self._detector = scm or SCMDetector(self._fs, self._host.executive).detect_scm_system(self._fs.getcwd()) >+ >+ def run(self, state): >+ png_files = self._check_pngs(self._changed_files(state)) >+ >+ if len(png_files) > 0: >+ detection = self._detector.display_name() >+ >+ if detection == "git": >+ (file_read, autoprop, png) = checksvnconfigfile.check(self, self._host, self._fs) >+ config_file_path = checksvnconfigfile._config_file_path(self, self._host, self._fs) >+ >+ if file_read: >+ log("There is no SVN config file. The svn:mime-type of pngs won't set.") >+ if not self._tool.user.confirm("Are you sure you want to continue?", default="n"): >+ self._exit(1) >+ elif autoprop and png: >+ log(checksvnconfigfile.errorstr_autoprop(config_file_path) + checksvnconfigfile.errorstr_png(config_file_path)) >+ if not self._tool.user.confirm("Do you want to continue?", default="n"): >+ self._exit(1) >+ elif autoprop: >+ log(checksvnconfigfile.errorstr_autoprop(config_file_path)) >+ if not self._tool.user.confirm("Do you want to continue?", default="n"): >+ self._exit(1) >+ elif png: >+ log(checksvnconfigfile.errorstr_png(config_file_path)) >+ if not self._tool.user.confirm("Do you want to continue?", default="n"): >+ self._exit(1) >+ >+ elif detection == "svn": >+ for filename in png_files: >+ if filename.endswith('.png') and self._detector.exists(filename) and self._detector.propget('svn:mime-type', filename) != 'image/png': >+ print "Adding image/png mime-type to %s" % filename >+ self._detector.propset('svn:mime-type', 'image/png', filename) >+ >+ def _check_pngs(self, changed_files): >+ png_files = [] >+ for filename in changed_files: >+ if filename.endswith('.png'): >+ png_files.append(filename) >+ return png_files >diff --git a/Tools/Scripts/webkitpy/tool/steps/addsvnmimetypeforpng_unittest.py b/Tools/Scripts/webkitpy/tool/steps/addsvnmimetypeforpng_unittest.py >new file mode 100644 >index 0000000..30ed074 >--- /dev/null >+++ b/Tools/Scripts/webkitpy/tool/steps/addsvnmimetypeforpng_unittest.py >@@ -0,0 +1,60 @@ >+# Copyright (C) 2012 Balazs Ankes (bank@inf.u-szeged.hu) University of Szeged >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. Redistributions in binary form must reproduce the above copyright >+# notice, this list of conditions and the following disclaimer in the >+# documentation and/or other materials provided with the distribution. >+# >+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ >+import unittest >+ >+from webkitpy.tool.steps.addsvnmimetypeforpng import AddSvnMimetypeForPng >+from webkitpy.common.system.filesystem_mock import MockFileSystem >+from webkitpy.tool.mocktool import MockOptions, MockTool >+from webkitpy.common.system.systemhost_mock import MockSystemHost >+from webkitpy.common.system.outputcapture import OutputCapture >+ >+ >+class MockSCMDetector(object): >+ >+ def __init__(self, scm): >+ self._scm = scm >+ >+ def display_name(self): >+ return self._scm >+ >+ >+class AddSvnMimetypeForPngTest(unittest.TestCase): >+ def test_run(self): >+ capture = OutputCapture() >+ options = MockOptions() >+ options.git_commit = 'MOCK git commit' >+ >+ files = {'/Users/mock/.subversion/config': 'enable-auto-props = yes\n*.png = svn:mime-type=image/png'} >+ fs = MockFileSystem(files) >+ scm = MockSCMDetector('git') >+ >+ step = AddSvnMimetypeForPng(MockTool(), options, MockSystemHost(os_name='linux', filesystem=fs), scm) >+ state = { >+ "changed_files": ["test.png"], >+ } >+ try: >+ capture.assert_outputs(self, step.run, [state]) >+ except SystemExit, e: >+ self.assertEquals(type(e), type(SystemExit())) >+ self.assertEquals(e.code, 1)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 75825
:
135140
|
137527
|
138335
|
140028
|
140967
|
141155
|
141181
|
141960
|
147528
|
147802
|
149495