You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

subversion.diff 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. Index: app/views/settings/_general.rhtml
  2. ===================================================================
  3. --- app/views/settings/_general.rhtml (revision 2094)
  4. +++ app/views/settings/_general.rhtml (working copy)
  5. @@ -48,6 +48,9 @@
  6. <p><label><%= l(:setting_feeds_limit) %></label>
  7. <%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></p>
  8. +<p><label><%= l(:setting_diff_max_lines_displayed) %></label>
  9. +<%= text_field_tag 'settings[diff_max_lines_displayed]', Setting.diff_max_lines_displayed, :size => 6 %></p>
  10. +
  11. <p><label><%= l(:setting_gravatar_enabled) %></label>
  12. <%= check_box_tag 'settings[gravatar_enabled]', 1, Setting.gravatar_enabled? %><%= hidden_field_tag 'settings[gravatar_enabled]', 0 %></p>
  13. </div>
  14. Index: app/views/common/_diff.rhtml
  15. ===================================================================
  16. --- app/views/common/_diff.rhtml (revision 2111)
  17. +++ app/views/common/_diff.rhtml (working copy)
  18. @@ -1,4 +1,5 @@
  19. -<% Redmine::UnifiedDiff.new(diff, :type => diff_type).each do |table_file| -%>
  20. +<% diff = Redmine::UnifiedDiff.new(diff, :type => diff_type, :max_lines => Setting.diff_max_lines_displayed.to_i) -%>
  21. +<% diff.each do |table_file| -%>
  22. <div class="autoscroll">
  23. <% if diff_type == 'sbs' -%>
  24. <table class="filecontent syntaxhl">
  25. @@ -62,3 +63,5 @@
  26. </div>
  27. <% end -%>
  28. +
  29. +<%= l(:text_diff_truncated) if diff.truncated? %>
  30. Index: lang/lt.yml
  31. ===================================================================
  32. --- config/settings.yml (revision 2094)
  33. +++ config/settings.yml (working copy)
  34. @@ -61,6 +61,9 @@
  35. feeds_limit:
  36. format: int
  37. default: 15
  38. +diff_max_lines_displayed:
  39. + format: int
  40. + default: 1500
  41. enabled_scm:
  42. serialized: true
  43. default:
  44. Index: lib/redmine/unified_diff.rb
  45. ===================================================================
  46. --- lib/redmine/unified_diff.rb (revision 2110)
  47. +++ lib/redmine/unified_diff.rb (working copy)
  48. @@ -19,8 +19,11 @@
  49. # Class used to parse unified diffs
  50. class UnifiedDiff < Array
  51. def initialize(diff, options={})
  52. + options.assert_valid_keys(:type, :max_lines)
  53. diff_type = options[:type] || 'inline'
  54. + lines = 0
  55. + @truncated = false
  56. diff_table = DiffTable.new(diff_type)
  57. diff.each do |line|
  58. if line =~ /^(---|\+\+\+) (.*)$/
  59. @@ -28,10 +31,17 @@
  60. diff_table = DiffTable.new(diff_type)
  61. end
  62. diff_table.add_line line
  63. + lines += 1
  64. + if options[:max_lines] && lines > options[:max_lines]
  65. + @truncated = true
  66. + break
  67. + end
  68. end
  69. self << diff_table unless diff_table.empty?
  70. self
  71. end
  72. +
  73. + def truncated?; @truncated; end
  74. end
  75. # Class that represents a file diff