PrettyPatch.rb should be more descriptive for "git diff -M" styled patches
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Feb 2014 12:44:42 +0000 (12:44 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Feb 2014 12:44:42 +0000 (12:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125514

Patch by Jozsef Berta <jberta.u-szeged@partner.samsung.com> on 2014-02-25
Reviewed by Csaba Osztrogonác.

* PrettyPatch/PrettyPatch.rb: PrettyPatch.rb is modified to show which file was renamed or moved.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164642 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/bugs.webkit.org/ChangeLog
Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb

index 68e55ff..3ce3851 100644 (file)
@@ -1,3 +1,12 @@
+2014-02-25  Jozsef Berta  <jberta.u-szeged@partner.samsung.com>
+
+        PrettyPatch.rb should be more descriptive for "git diff -M" styled patches
+        https://bugs.webkit.org/show_bug.cgi?id=125514
+
+        Reviewed by Csaba Osztrogonác.
+
+        * PrettyPatch/PrettyPatch.rb: PrettyPatch.rb is modified to show which file was renamed or moved.
+
 2013-12-16  Dániel Bátyai  <Batyai.Daniel@stud.u-szeged.hu>
 
         PrettyPatch.rb doesn't handle diffs where lines matching /^--/ are missing properly
index 837dbfa..1ccf877 100644 (file)
@@ -61,6 +61,8 @@ private
         /^diff/
     ]
 
+    RENAME_FROM = /^rename from (.*)/
+
     BINARY_FILE_MARKER_FORMAT = /^Cannot display: file marked as a binary type.$/
 
     IMAGE_FILE_MARKER_FORMAT = /^svn:mime-type = image\/png$/
@@ -150,10 +152,13 @@ private
         [nil, file_path]
     end
 
-    def self.linkifyFilename(filename)
-        url, pathBeneathTrunk = find_url_and_path(filename)
-
-        url.nil? ? filename : "<a href='#{url}browser/trunk/#{pathBeneathTrunk}'>#{filename}</a>"
+    def self.linkifyFilename(filename, force)
+        if force
+          "<a href='#{OPENSOURCE_TRAC_URL}browser/trunk/#{filename}'>#{filename}</a>"
+        else
+          url, pathBeneathTrunk = find_url_and_path(filename)
+          url.nil? ? filename : "<a href='#{url}browser/trunk/#{pathBeneathTrunk}'>#{filename}</a>"
+        end
     end
 
 
@@ -184,7 +189,7 @@ h1 {
     font-family: sans-serif;
     font-size: 1em;
     margin-left: 0.5em;
-    display: table-cell;
+    display: inline;
     width: 100%;
     padding: 0.5em;
 }
@@ -560,6 +565,8 @@ EOF
                         startOfSections = i + 1
                     end
                     break
+                when RENAME_FROM
+                    @renameFrom = RENAME_FROM.match(lines[i])[1]
                 end
             end
             lines_with_contents = lines[startOfSections...lines.length]
@@ -616,7 +623,13 @@ EOF
 
         def to_html
             str = "<div class='FileDiff'>\n"
-            str += "<h1>#{PrettyPatch.linkifyFilename(@filename)}</h1>\n"
+            if @renameFrom
+                str += "<h1>#{@filename}</h1>"
+                str += "was renamed from"
+                str += "<h1>#{PrettyPatch.linkifyFilename(@renameFrom.to_s, true)}</h1>"
+            else
+                str += "<h1>#{PrettyPatch.linkifyFilename(@filename, false)}</h1>\n"
+            end
             if @image then
                 str += self.image_to_html
             elsif @git_image then