Commit 9d373059 authored by ddkilzer@apple.com's avatar ddkilzer@apple.com

Make PrettyPatch handle diffs with no Index or diff headers

        Part of Bug 19290: More patches not handled by PrettyPatch.rb
        <https://bugs.webkit.org/show_bug.cgi?id=19290>

        Reviewed by Adam.

        * PrettyPatch/PrettyPatch.rb:
        (PrettyPatch.DIFF_HEADER_FORMATS): Added regular expression to
        match on "+++ " lines for patches with no "Index" or "diff" header.
        (PrettyPatch.FileDiff.initialize): Look for filename on "+++ " line
        when the first line of a patch has no "Index" or "diff" header.
        (PrettyPatch.FileDiff.parse): Added haveSeenDiffHeader state
        variable to determine when no "Index" or "diff" header has been
        found, but a new patch has started with a "--- " line.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34797 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 180847c9
2008-06-24 David Kilzer <ddkilzer@apple.com>
Make PrettyPatch handle diffs with no Index or diff headers
Part of Bug 19290: More patches not handled by PrettyPatch.rb
<https://bugs.webkit.org/show_bug.cgi?id=19290>
Reviewed by Adam.
* PrettyPatch/PrettyPatch.rb:
(PrettyPatch.DIFF_HEADER_FORMATS): Added regular expression to
match on "+++ " lines for patches with no "Index" or "diff" header.
(PrettyPatch.FileDiff.initialize): Look for filename on "+++ " line
when the first line of a patch has no "Index" or "diff" header.
(PrettyPatch.FileDiff.parse): Added haveSeenDiffHeader state
variable to determine when no "Index" or "diff" header has been
found, but a new patch has started with a "--- " line.
2008-06-08 Dan Bernstein <mitz@apple.com>
Reviewed by Adam Roben.
......
......@@ -29,7 +29,8 @@ public
private
DIFF_HEADER_FORMATS = [
/^Index: (.*)\r?$/,
/^diff --git a\/.+ b\/(.+)\r?$/
/^diff --git a\/.+ b\/(.+)\r?$/,
/^\+\+\+ ([^\t]+)(\t.*)?\r?$/
]
RELAXED_DIFF_HEADER_FORMATS = [
......@@ -177,11 +178,12 @@ EOF
def initialize(lines)
@filename = PrettyPatch.filename_from_diff_header(lines[0].chomp)
startOfSections = 1
for i in 1...lines.length
for i in 0...lines.length
case lines[i]
when /^--- /
@from = PrettyPatch.revisionOrDescription(lines[i])
when /^\+\+\+ /
@filename = PrettyPatch.filename_from_diff_header(lines[i].chomp) if @filename.nil?
@to = PrettyPatch.revisionOrDescription(lines[i])
startOfSections = i + 1
break
......@@ -200,8 +202,15 @@ EOF
end
def self.parse(string)
haveSeenDiffHeader = false
linesForDiffs = string.inject([]) do |diffChunks, line|
diffChunks << [] if PrettyPatch.diff_header?(line)
if (PrettyPatch.diff_header?(line))
diffChunks << []
haveSeenDiffHeader = true
elsif (!haveSeenDiffHeader && line =~ /^--- /)
diffChunks << []
haveSeenDiffHeader = false
end
diffChunks.last << line unless diffChunks.last.nil?
diffChunks
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment