Commit f698e13b1f3740d1b1dc5fd0ba4e3b4773e2c2e9
- Date: Wed Apr 30 16:59:53 +0000 2008
- Committer: Tim Harper (timcharper@gmail.com)
- Author: Tim Harper (timcharper@gmail.com)
- Commit SHA1: f698e13b1f3740d1b1dc5fd0ba4e3b4773e2c2e9
- Tree SHA1: e511acf9d569c5d0a7d1cd8e02d49452d8e7bf37
limit the amount of lines rendered in a diff
Commit diff
| |   |
| 32 | 32 | </thead> |
| 33 | 33 | <tbody> |
| 34 | 34 | <% diff_result[:lines].each do |line| |
| 35 | next if @diff_line_count >= Git::DEFAULT_DIFF_LIMIT |
| 36 | @diff_line_count += 1 |
| 35 | 37 | line_num_class, row_class = case line[:type] |
| 36 | 38 | when :deletion then ["", "del"] |
| 37 | 39 | when :insertion then ["", "ins"] |
| toggle raw diff |
--- a/Support/app/views/diff/_diff_result.html.erb
+++ b/Support/app/views/diff/_diff_result.html.erb
@@ -32,6 +32,8 @@
</thead>
<tbody>
<% diff_result[:lines].each do |line|
+ next if @diff_line_count >= Git::DEFAULT_DIFF_LIMIT
+ @diff_line_count += 1
line_num_class, row_class = case line[:type]
when :deletion then ["", "del"]
when :insertion then ["", "ins"] |
| |   |
| 1 | <% @diff_line_count = 0 %> |
| 1 | 2 | <% revision ||= nil %> |
| 2 | 3 | <code> |
| 3 | 4 | <% diff_results.each do |diff_result| %> |
| 5 | <% next if @diff_line_count >= Git::DEFAULT_DIFF_LIMIT %> |
| 4 | 6 | <% render "diff/_diff_result", :locals => {:diff_result => diff_result, :revision => revision } %> |
| 5 | 7 | <% flush %> |
| 6 | 8 | <% end %> |
| 7 | | </code> |
| 9 | </code> |
| 10 | <% if @diff_line_count >= Git::DEFAULT_DIFF_LIMIT %> |
| 11 | <h2>Diff taking to long to render... aborted</h2> |
| 12 | <% end %> |
| toggle raw diff |
--- a/Support/app/views/diff/_diff_results.html.erb
+++ b/Support/app/views/diff/_diff_results.html.erb
@@ -1,7 +1,12 @@
+<% @diff_line_count = 0 %>
<% revision ||= nil %>
<code>
<% diff_results.each do |diff_result| %>
+ <% next if @diff_line_count >= Git::DEFAULT_DIFF_LIMIT %>
<% render "diff/_diff_result", :locals => {:diff_result => diff_result, :revision => revision } %>
<% flush %>
<% end %>
-</code>
\ No newline at end of file
+</code>
+<% if @diff_line_count >= Git::DEFAULT_DIFF_LIMIT %>
+ <h2>Diff taking to long to render... aborted</h2>
+<% end %>
\ No newline at end of file |
| |   |
| 21 | 21 | 'X' => {:short => 'X', :long => 'external', :foreground => '#800080', :background => '#edaef5'}, |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | DEFAULT_DIFF_LIMIT = 3000 |
| 25 | |
| 24 | 26 | def short_rev(rev) |
| 25 | 27 | rev.to_s[0..7] |
| 26 | 28 | end |
| toggle raw diff |
--- a/Support/lib/git.rb
+++ b/Support/lib/git.rb
@@ -21,6 +21,8 @@ module SCM
'X' => {:short => 'X', :long => 'external', :foreground => '#800080', :background => '#edaef5'},
}
+ DEFAULT_DIFF_LIMIT = 3000
+
def short_rev(rev)
rev.to_s[0..7]
end |