Merged r2110 to r2112 (diff limit) from trunk.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.8-stable@2132 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-12-12 19:49:22 +00:00
parent 618ab6004e
commit 633e026e44
37 changed files with 209 additions and 5 deletions
+16 -4
View File
@@ -18,18 +18,30 @@
module Redmine
# Class used to parse unified diffs
class UnifiedDiff < Array
def initialize(diff, type="inline")
diff_table = DiffTable.new type
def initialize(diff, options={})
options.assert_valid_keys(:type, :max_lines)
diff_type = options[:type] || 'inline'
lines = 0
@truncated = false
diff_table = DiffTable.new(diff_type)
diff.each do |line|
if line =~ /^(---|\+\+\+) (.*)$/
self << diff_table if diff_table.length > 1
diff_table = DiffTable.new type
diff_table = DiffTable.new(diff_type)
end
diff_table.add_line line
lines += 1
if options[:max_lines] && lines > options[:max_lines]
@truncated = true
break
end
a = diff_table.add_line line
end
self << diff_table unless diff_table.empty?
self
end
def truncated?; @truncated; end
end
# Class that represents a file diff