<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[173253] trunk/Websites/bugs.webkit.org</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/173253">173253</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2014-09-03 23:46:42 -0700 (Wed, 03 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make images work with patches created using svn 1.7
&lt;http://webkit.org/b/136507&gt;

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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesbugswebkitorgChangeLog">trunk/Websites/bugs.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesbugswebkitorgPrettyPatchPrettyPatchrb">trunk/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebsitesbugswebkitorgChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Websites/bugs.webkit.org/ChangeLog (173252 => 173253)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/bugs.webkit.org/ChangeLog        2014-09-04 06:43:35 UTC (rev 173252)
+++ trunk/Websites/bugs.webkit.org/ChangeLog        2014-09-04 06:46:42 UTC (rev 173253)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2014-09-03  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
+        Make images work with patches created using svn 1.7
+        &lt;http://webkit.org/b/136507&gt;
+
+        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.
+
</ins><span class="cx"> 2014-02-25  Jozsef Berta  &lt;jberta.u-szeged@partner.samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         PrettyPatch.rb should be more descriptive for &quot;git diff -M&quot; styled patches
</span></span></pre></div>
<a id="trunkWebsitesbugswebkitorgPrettyPatchPrettyPatchrb"></a>
<div class="modfile"><h4>Modified: trunk/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb (173252 => 173253)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb        2014-09-04 06:43:35 UTC (rev 173252)
+++ trunk/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb        2014-09-04 06:46:42 UTC (rev 173253)
</span><span class="lines">@@ -32,6 +32,16 @@
</span><span class="cx"> 
</span><span class="cx">         fileDiffs = FileDiff.parse(string)
</span><span class="cx"> 
</span><ins>+        # Newly added images get two diffs with svn 1.7; toss the first one.
+        deleteIndices = []
+        for i in 1...fileDiffs.length
+            prev = i - 1
+            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
+                deleteIndices.unshift(prev)
+            end
+        end
+        deleteIndices.each{ |i| fileDiffs.delete_at(i) }
+
</ins><span class="cx">         $last_prettify_file_count = fileDiffs.length
</span><span class="cx">         str &lt;&lt; fileDiffs.collect{ |diff| diff.to_html }.join
</span><span class="cx">         str &lt;&lt; &quot;&lt;/body&gt;&lt;/html&gt;&quot;
</span><span class="lines">@@ -63,10 +73,12 @@
</span><span class="cx"> 
</span><span class="cx">     RENAME_FROM = /^rename from (.*)/
</span><span class="cx"> 
</span><del>-    BINARY_FILE_MARKER_FORMAT = /^Cannot display: file marked as a binary type.$/
</del><ins>+    SVN_BINARY_FILE_MARKER_FORMAT = /^Cannot display: file marked as a binary type.$/
</ins><span class="cx"> 
</span><del>-    IMAGE_FILE_MARKER_FORMAT = /^svn:mime-type = image\/png$/
</del><ins>+    SVN_IMAGE_FILE_MARKER_FORMAT = /^svn:mime-type = image\/png$/
</ins><span class="cx"> 
</span><ins>+    SVN_PROPERTY_CHANGES_FORMAT = /^Property changes on: (.*)/
+
</ins><span class="cx">     GIT_INDEX_MARKER_FORMAT = /^index ([0-9a-f]{40})\.\.([0-9a-f]{40})/
</span><span class="cx"> 
</span><span class="cx">     GIT_BINARY_FILE_MARKER_FORMAT = /^GIT binary patch$/
</span><span class="lines">@@ -77,7 +89,7 @@
</span><span class="cx"> 
</span><span class="cx">     GIT_DELTA_FORMAT = /^delta \d+$/
</span><span class="cx"> 
</span><del>-    START_OF_BINARY_DATA_FORMAT = /^[0-9a-zA-Z\+\/=]{20,}/ # Assume 20 chars without a space is base64 binary data.
</del><ins>+    SVN_START_OF_BINARY_DATA_FORMAT = /^[0-9a-zA-Z\+\/=]{20,}/ # Assume 20 chars without a space is base64 binary data.
</ins><span class="cx"> 
</span><span class="cx">     START_OF_SECTION_FORMAT = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@\s*(.*)/
</span><span class="cx"> 
</span><span class="lines">@@ -530,6 +542,10 @@
</span><span class="cx">     end
</span><span class="cx"> 
</span><span class="cx">     class FileDiff
</span><ins>+        attr_reader :filename
+        attr_reader :image
+        attr_reader :image_url
+
</ins><span class="cx">         def initialize(lines)
</span><span class="cx">             @filename = PrettyPatch.filename_from_diff_header(lines[0].chomp)
</span><span class="cx">             startOfSections = 1
</span><span class="lines">@@ -541,15 +557,29 @@
</span><span class="cx">                     @filename = PrettyPatch.filename_from_diff_header(lines[i].chomp) if @filename.nil?
</span><span class="cx">                     @to = PrettyPatch.revisionOrDescription(lines[i])
</span><span class="cx">                     startOfSections = i + 1
</span><ins>+
+                    # Check for 'property' patch, then image data, since svn 1.7 creates a fake patch for property changes.
+                    if /^$/.match(lines[startOfSections]) and SVN_PROPERTY_CHANGES_FORMAT.match(lines[startOfSections + 1]) then
+                        startOfSections += 2
+                        for x in startOfSections...lines.length
+                            next if not /^$/.match(lines[x])
+                            if SVN_START_OF_BINARY_DATA_FORMAT.match(lines[x + 1]) then
+                                startOfSections = x + 1
+                                @binary = true
+                                @image = true
+                                break
+                            end
+                        end
+                    end
</ins><span class="cx">                     break
</span><del>-                when BINARY_FILE_MARKER_FORMAT
</del><ins>+                when SVN_BINARY_FILE_MARKER_FORMAT
</ins><span class="cx">                     @binary = true
</span><del>-                    if (IMAGE_FILE_MARKER_FORMAT.match(lines[i + 1]) or PrettyPatch.has_image_suffix(@filename)) then
</del><ins>+                    if (SVN_IMAGE_FILE_MARKER_FORMAT.match(lines[i + 1]) or PrettyPatch.has_image_suffix(@filename)) then
</ins><span class="cx">                         @image = true
</span><span class="cx">                         startOfSections = i + 2
</span><span class="cx">                         for x in startOfSections...lines.length
</span><span class="cx">                             # Binary diffs often have property changes listed before the actual binary data.  Skip them.
</span><del>-                            if START_OF_BINARY_DATA_FORMAT.match(lines[x]) then
</del><ins>+                            if SVN_START_OF_BINARY_DATA_FORMAT.match(lines[x]) then
</ins><span class="cx">                                 startOfSections = x
</span><span class="cx">                                 break
</span><span class="cx">                             end
</span></span></pre>
</div>
</div>

</body>
</html>