Changeset 173253 in webkit


Ignore:
Timestamp:
Sep 3, 2014 11:46:42 PM (10 years ago)
Author:
ddkilzer@apple.com
Message:

Make images work with patches created using svn 1.7
<http://webkit.org/b/136507>

Reviewed by Darin Adler.

  • PrettyPatch/PrettyPatch.rb:

(PrettyPatch.prettify): Delete redundant patches that claim
newly added images are actually removed.
(PrettyPatch.SVN_BINARY_FILE_MARKER_FORMAT): Rename from
BINARY_FILE_MARKER_FORMAT.
(PrettyPatch.SVN_IMAGE_FILE_MARKER_FORMAT): Rename from
IMAGE_FILE_MARKER_FORMAT.
(PrettyPatch.SVN_PROPERTY_CHANGES_FORMAT): Add. Used to find
and ignore property changes in svn 1.7 patches.
(PrettyPatch.SVN_START_OF_BINARY_DATA_FORMAT): Rename from
START_OF_BINARY_DATA_FORMAT.
(FileDiff.filename): Add read-only accessor.
(FileDiff.image): Add read-only accessor.
(FileDiff.image_url): Add read-only accessor.
(FileDiff.initialize): Add special case for svn-1.7 image
patches that add a file. Update various regex constants per
above.

Location:
trunk/Websites/bugs.webkit.org
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Websites/bugs.webkit.org/ChangeLog

    r164642 r173253  
     12014-09-03  David Kilzer  <ddkilzer@apple.com>
     2
     3        Make images work with patches created using svn 1.7
     4        <http://webkit.org/b/136507>
     5
     6        Reviewed by Darin Adler.
     7
     8        * PrettyPatch/PrettyPatch.rb:
     9        (PrettyPatch.prettify): Delete redundant patches that claim
     10        newly added images are actually removed.
     11        (PrettyPatch.SVN_BINARY_FILE_MARKER_FORMAT): Rename from
     12        BINARY_FILE_MARKER_FORMAT.
     13        (PrettyPatch.SVN_IMAGE_FILE_MARKER_FORMAT): Rename from
     14        IMAGE_FILE_MARKER_FORMAT.
     15        (PrettyPatch.SVN_PROPERTY_CHANGES_FORMAT): Add. Used to find
     16        and ignore property changes in svn 1.7 patches.
     17        (PrettyPatch.SVN_START_OF_BINARY_DATA_FORMAT): Rename from
     18        START_OF_BINARY_DATA_FORMAT.
     19        (FileDiff.filename): Add read-only accessor.
     20        (FileDiff.image): Add read-only accessor.
     21        (FileDiff.image_url): Add read-only accessor.
     22        (FileDiff.initialize): Add special case for svn-1.7 image
     23        patches that add a file.  Update various regex constants per
     24        above.
     25
    1262014-02-25  Jozsef Berta  <jberta.u-szeged@partner.samsung.com>
    227
  • trunk/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb

    r164642 r173253  
    3333        fileDiffs = FileDiff.parse(string)
    3434
     35        # Newly added images get two diffs with svn 1.7; toss the first one.
     36        deleteIndices = []
     37        for i in 1...fileDiffs.length
     38            prev = i - 1
     39            if fileDiffs[prev].image and not fileDiffs[prev].image_url and fileDiffs[i].image and fileDiffs[i].image_url and fileDiffs[prev].filename == fileDiffs[i].filename
     40                deleteIndices.unshift(prev)
     41            end
     42        end
     43        deleteIndices.each{ |i| fileDiffs.delete_at(i) }
     44
    3545        $last_prettify_file_count = fileDiffs.length
    3646        str << fileDiffs.collect{ |diff| diff.to_html }.join
     
    6474    RENAME_FROM = /^rename from (.*)/
    6575
    66     BINARY_FILE_MARKER_FORMAT = /^Cannot display: file marked as a binary type.$/
    67 
    68     IMAGE_FILE_MARKER_FORMAT = /^svn:mime-type = image\/png$/
     76    SVN_BINARY_FILE_MARKER_FORMAT = /^Cannot display: file marked as a binary type.$/
     77
     78    SVN_IMAGE_FILE_MARKER_FORMAT = /^svn:mime-type = image\/png$/
     79
     80    SVN_PROPERTY_CHANGES_FORMAT = /^Property changes on: (.*)/
    6981
    7082    GIT_INDEX_MARKER_FORMAT = /^index ([0-9a-f]{40})\.\.([0-9a-f]{40})/
     
    7890    GIT_DELTA_FORMAT = /^delta \d+$/
    7991
    80     START_OF_BINARY_DATA_FORMAT = /^[0-9a-zA-Z\+\/=]{20,}/ # Assume 20 chars without a space is base64 binary data.
     92    SVN_START_OF_BINARY_DATA_FORMAT = /^[0-9a-zA-Z\+\/=]{20,}/ # Assume 20 chars without a space is base64 binary data.
    8193
    8294    START_OF_SECTION_FORMAT = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@\s*(.*)/
     
    531543
    532544    class FileDiff
     545        attr_reader :filename
     546        attr_reader :image
     547        attr_reader :image_url
     548
    533549        def initialize(lines)
    534550            @filename = PrettyPatch.filename_from_diff_header(lines[0].chomp)
     
    542558                    @to = PrettyPatch.revisionOrDescription(lines[i])
    543559                    startOfSections = i + 1
     560
     561                    # Check for 'property' patch, then image data, since svn 1.7 creates a fake patch for property changes.
     562                    if /^$/.match(lines[startOfSections]) and SVN_PROPERTY_CHANGES_FORMAT.match(lines[startOfSections + 1]) then
     563                        startOfSections += 2
     564                        for x in startOfSections...lines.length
     565                            next if not /^$/.match(lines[x])
     566                            if SVN_START_OF_BINARY_DATA_FORMAT.match(lines[x + 1]) then
     567                                startOfSections = x + 1
     568                                @binary = true
     569                                @image = true
     570                                break
     571                            end
     572                        end
     573                    end
    544574                    break
    545                 when BINARY_FILE_MARKER_FORMAT
     575                when SVN_BINARY_FILE_MARKER_FORMAT
    546576                    @binary = true
    547                     if (IMAGE_FILE_MARKER_FORMAT.match(lines[i + 1]) or PrettyPatch.has_image_suffix(@filename)) then
     577                    if (SVN_IMAGE_FILE_MARKER_FORMAT.match(lines[i + 1]) or PrettyPatch.has_image_suffix(@filename)) then
    548578                        @image = true
    549579                        startOfSections = i + 2
    550580                        for x in startOfSections...lines.length
    551581                            # Binary diffs often have property changes listed before the actual binary data.  Skip them.
    552                             if START_OF_BINARY_DATA_FORMAT.match(lines[x]) then
     582                            if SVN_START_OF_BINARY_DATA_FORMAT.match(lines[x]) then
    553583                                startOfSections = x
    554584                                break
Note: See TracChangeset for help on using the changeset viewer.