aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-11-24 09:52:41 +0100
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-11-24 09:52:41 +0100
commit8da3d5d0ea69aa9fc991c136ba6274cfc5f459ba (patch)
tree1cac3d9e59957b3e6b9fc0250ed0bb65406fc635
parente4d1de4f78d03bb3d9b5b759f2950c99f368ae6b (diff)
bugfix for empty history
-rwxr-xr-xedit_columns.rb22
-rwxr-xr-xhistory.rb2
-rw-r--r--log.rb11
3 files changed, 27 insertions, 8 deletions
diff --git a/edit_columns.rb b/edit_columns.rb
index 5033a48..c331c8d 100755
--- a/edit_columns.rb
+++ b/edit_columns.rb
@@ -117,21 +117,35 @@ if urevs.max
</td>
UNDO
end
- if rrevs.min
$html << <<REDO
<td>
<form method='post' action=''>
<div>
- <input type='submit' title='#{title}' value='Redo' />
+ <input type='submit' title='#{title}' value='Redo' #{rrevs.min ? "" : "disabled='disabled'"}/>
+REDO
+ if rrevs.min
+ $html << <<REDO
<input type='hidden' name='redo'/>
<input type='hidden' name='undo_revision' value='#{rrevs.min.rev()}' />
#{hidden}
+REDO
+ end
+ $html << <<REDO
</div>
</form>
</td>
REDO
- urhist += rrevs
- end
+ urhist += rrevs
+
+ $html << <<READY
+<td>
+<form method='get' action='.'>
+ <div>
+ <input type='submit' value='Ready' />
+ </div>
+</form>
+</td>
+READY
$html << "</tr></table>"
$html << (urhist).to_html(urevs.max.rev,"")
diff --git a/history.rb b/history.rb
index a425d91..5f206d8 100755
--- a/history.rb
+++ b/history.rb
@@ -63,7 +63,7 @@ $html << table.to_html("",false)
$html << "<h2>History</h2>"
$html << "<div id='history'>"
-$html << table.history_selectform($cgi.include?("revision") ? nil : revno, $cgi["history"])
+$html << table.history_selectform($cgi.include?("revision") ? revno : nil, $cgi["history"])
$html << table.history_to_html(revno, $cgi["history"])
$html << "</div>"
diff --git a/log.rb b/log.rb
index a02e7ec..c98e9b4 100644
--- a/log.rb
+++ b/log.rb
@@ -53,7 +53,7 @@ end
class Log
attr_reader :log
def initialize(a = [])
- @log = a
+ @log = a.compact.sort
end
def min
@log.sort!
@@ -72,6 +72,7 @@ class Log
return @log[i]
else # no revision found, search the nearest
dist = revisions.collect{|e| (e - revision).abs }.sort[0]
+ return nil unless dist
i = revisions.index(revision + dist) || revisions.index(revision - dist)
return @log[i]
end
@@ -107,9 +108,9 @@ class Log
end
def to_html(unlinkedrevision,history)
ret = "<table summary='Historytable' ><tr><th>Version</th><th>Date</th><th>Comment</th></tr>"
- self.each do |l|
+ self.each{|l|
ret += l.to_html(unlinkedrevision != l.rev,history)
- end
+ }
ret += "</table>"
ret
end
@@ -172,6 +173,10 @@ require "pp"
def test_indexes
l = Log.new
+
+ l.each{flunk("this should not happen")}
+ assert_equal(nil,l[2])
+
l.add(10,Time.now,"baz 10")
20.times{|i|
l.add(i,Time.now,"foo #{i}") unless i == 10