From b0800482f903afd1df65d4faf44aa8d840906517 Mon Sep 17 00:00:00 2001 From: "tony@chromium.org" Date: Thu, 14 Apr 2011 17:47:48 +0000 Subject: [PATCH] 2011-04-14 Tony Chang Reviewed by Adam Roben. make PrettyPatch.rb aware of checksums in png files https://bugs.webkit.org/show_bug.cgi?id=58387 Patch v2 with nil checks in the case of file adds and deletes. * PrettyPatch/PrettyPatch.rb: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83870 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Websites/bugs.webkit.org/ChangeLog | 11 ++++++++ .../PrettyPatch/PrettyPatch.rb | 28 +++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Websites/bugs.webkit.org/ChangeLog b/Websites/bugs.webkit.org/ChangeLog index ed8a4920c978..1ee7ff296c20 100644 --- a/Websites/bugs.webkit.org/ChangeLog +++ b/Websites/bugs.webkit.org/ChangeLog @@ -1,3 +1,14 @@ +2011-04-14 Tony Chang + + Reviewed by Adam Roben. + + make PrettyPatch.rb aware of checksums in png files + https://bugs.webkit.org/show_bug.cgi?id=58387 + + Patch v2 with nil checks in the case of file adds and deletes. + + * PrettyPatch/PrettyPatch.rb: + 2011-04-13 Simon Fraser Revert http://trac.webkit.org/changeset/83750 because it broke PrettyPatch. diff --git a/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb b/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb index 8f960a91fccf..a4e389372c4a 100644 --- a/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb +++ b/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb @@ -228,7 +228,7 @@ h1 :hover { background-color: #fef; } -.Line.add { +.Line.add, .FileDiff .add { background-color: #dfd; } @@ -237,7 +237,7 @@ h1 :hover { text-decoration: none; } -.Line.remove { +.Line.remove, .FileDiff .remove { background-color: #fdd; } @@ -516,6 +516,7 @@ EOF @sections = DiffSection.parse(lines_with_contents) unless @binary if @image @image_url = "data:image/png;base64," + lines_with_contents.join + @image_checksum = FileDiff.read_checksum_from_png(lines_with_contents.join.unpack("m").join) elsif @git_image begin raise "index line is missing" unless @git_indexes @@ -530,9 +531,12 @@ EOF raise "no binary chunks" unless chunks - @image_urls = chunks.zip(@git_indexes).collect do |chunk, git_index| + binary_contents = chunks.zip(@git_indexes).collect do |chunk, git_index| FileDiff.extract_contents_from_git_binary_chunk(chunk, git_index) end + + @image_urls = binary_contents.collect { |content| content ? "data:image/png;base64," + [content].pack("m") : nil } + @image_checksums = binary_contents.collect { |content| FileDiff.read_checksum_from_png(content) } rescue @image_error = "Exception raised during decoding git binary patch:
#{CGI.escapeHTML($!.to_s + "\n" + $!.backtrace.join("\n"))}
" end @@ -544,6 +548,9 @@ EOF str = "
\n" str += "

#{PrettyPatch.linkifyFilename(@filename)}

\n" if @image then + if @image_checksum then + str += "

" + @image_checksum + "

" + end str += "" elsif @git_image then if @image_error @@ -551,12 +558,18 @@ EOF else for i in (0...2) image_url = @image_urls[i] + image_checksum = @image_checksums[i] + style = ["remove", "add"][i] str += "

" + + if image_checksum + str += image_checksum + "
" + end if image_url str += "" else - str += ["Added", "Removed"][i] + str += ["

Added", "

Removed"][i] end end end @@ -590,6 +603,11 @@ EOF linesForDiffs.collect { |lines| FileDiff.new(lines) } end + def self.read_checksum_from_png(png_bytes) + match = png_bytes && png_bytes.match(/tEXtchecksum\0([a-fA-F0-9]{32})/) + match ? match[1] : nil + end + def self.git_new_file_binary_patch(filename, encoded_chunk, git_index) return <