Changeset 122311 in webkit


Ignore:
Timestamp:
Jul 11, 2012 1:34:25 AM (12 years ago)
Author:
Csaba Osztrogonác
Message:

webkit-patch land should automatically add svn:mime-type for .png files
https://bugs.webkit.org/show_bug.cgi?id=75825

Patch by Balazs Ankes <bank@inf.u-szeged.hu> on 2012-07-11
Reviewed by Dirk Pranke.

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):

Location:
trunk/Tools
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r122309 r122311  
     12012-07-11  Balazs Ankes  <bank@inf.u-szeged.hu>
     2
     3        webkit-patch land should automatically add svn:mime-type for .png files
     4        https://bugs.webkit.org/show_bug.cgi?id=75825
     5
     6        Reviewed by Dirk Pranke.
     7
     8        Refactor the png.py to avoid code duplication.
     9
     10        * Scripts/webkitpy/common/checksvnconfigfile.py: Added.
     11        (check):
     12        (config_file_path):
     13        (errorstr_autoprop):
     14        (errorstr_png):
     15        * Scripts/webkitpy/style/checkers/png.py:
     16        (PNGChecker.check):
     17        * Scripts/webkitpy/tool/commands/download.py:
     18        (Land):
     19        * Scripts/webkitpy/tool/steps/__init__.py:
     20        * Scripts/webkitpy/tool/steps/addsvnmimetypeforpng.py: Added.
     21        (AddSvnMimetypeForPng):
     22        (AddSvnMimetypeForPng.__init__):
     23        (AddSvnMimetypeForPng.run):
     24        (AddSvnMimetypeForPng._check_pngs):
     25        * Scripts/webkitpy/tool/steps/addsvnmimetypeforpng_unittest.py: Added.
     26        (MockSCMDetector):
     27        (MockSCMDetector.__init__):
     28        (MockSCMDetector.display_name):
     29        (AddSvnMimetypeForPngTest):
     30        (AddSvnMimetypeForPngTest.test_run):
     31
    1322012-07-11  Hayato Ito  <hayato@chromium.org>
    233
  • trunk/Tools/Scripts/webkitpy/style/checkers/png.py

    r118996 r122311  
    2828import re
    2929
     30from webkitpy.common import checksvnconfigfile
    3031from webkitpy.common import read_checksum_from_png
    3132from webkitpy.common.system.systemhost import SystemHost
     
    5556
    5657        if detection == "git":
    57             config_file_path = self._config_file_path()
    58             there_is_enable_line = False
    59             there_is_png_line = False
     58            (file_missing, autoprop_missing, png_missing) = checksvnconfigfile.check(self._host, self._fs)
     59            config_file_path = checksvnconfigfile.config_file_path(self._host, self._fs)
    6060
    61             try:
    62                 config_file = self._fs.read_text_file(config_file_path)
    63             except IOError:
    64                 errorstr = "There is no " + config_file_path
    65                 self._handle_style_error(0, 'image/png', 5, errorstr)
    66                 return
    67 
    68             errorstr_autoprop = "Have to enable auto props in the subversion config file (" + config_file_path + " \"enable-auto-props = yes\"). "
    69             errorstr_png = "Have to set the svn:mime-type in the subversion config file (" + config_file_path + " \"*.png = svn:mime-type=image/png\")."
    70 
    71             for line in config_file.split('\n'):
    72                 if not there_is_enable_line:
    73                     match = re.search("^\s*enable-auto-props\s*=\s*yes", line)
    74                     if match:
    75                         there_is_enable_line = True
    76                         errorstr_autoprop = ""
    77                         continue
    78 
    79                 if not there_is_png_line:
    80                     match = re.search("^\s*\*\.png\s*=\s*svn:mime-type=image/png", line)
    81                     if match:
    82                         there_is_png_line = True
    83                         errorstr_png = ""
    84                         continue
    85 
    86             errorstr = errorstr_autoprop + errorstr_png
    87             if errorstr:
    88                 self._handle_style_error(0, 'image/png', 5, errorstr)
     61            if file_missing:
     62                self._handle_style_error(0, 'image/png', 5, "There is no SVN config file. (%s)" % config_file_path)
     63            elif autoprop_missing and png_missing:
     64                self._handle_style_error(0, 'image/png', 5, checksvnconfigfile.errorstr_autoprop(config_file_path) + checksvnconfigfile.errorstr_png(config_file_path))
     65            elif autoprop_missing:
     66                self._handle_style_error(0, 'image/png', 5, checksvnconfigfile.errorstr_autoprop(config_file_path))
     67            elif png_missing:
     68                self._handle_style_error(0, 'image/png', 5, checksvnconfigfile.errorstr_png(config_file_path))
    8969
    9070        elif detection == "svn":
    9171            prop_get = self._detector.propget("svn:mime-type", self._file_path)
    9272            if prop_get != "image/png":
    93                 errorstr = "Set the svn:mime-type property (svn propset svn:mime-type image/png " + self._file_path + ")."
     73                errorstr = "Set the svn:mime-type property (svn propset svn:mime-type image/png %s)." % self._file_path
    9474                self._handle_style_error(0, 'image/png', 5, errorstr)
    9575
    96     def _config_file_path(self):
    97         config_file = ""
    98         if self._host.platform.is_win():
    99             config_file_path = self._fs.join(os.environ['APPDATA'], "Subversion\config")
    100         else:
    101             config_file_path = self._fs.join(self._fs.expanduser("~"), ".subversion/config")
    102         return config_file_path
  • trunk/Tools/Scripts/webkitpy/tool/commands/download.py

    r116947 r122311  
    9191    show_in_main_help = True
    9292    steps = [
     93        steps.AddSvnMimetypeForPng,
    9394        steps.UpdateChangeLogsWithReviewer,
    9495        steps.ValidateReviewer,
  • trunk/Tools/Scripts/webkitpy/tool/steps/__init__.py

    r116947 r122311  
    2828
    2929# FIXME: Is this the right way to do this?
     30from webkitpy.tool.steps.addsvnmimetypeforpng import AddSvnMimetypeForPng
    3031from webkitpy.tool.steps.applypatch import ApplyPatch
    3132from webkitpy.tool.steps.applypatchwithlocalcommit import ApplyPatchWithLocalCommit
Note: See TracChangeset for help on using the changeset viewer.