##// END OF EJS Templates
scm: mercurial: fix error on revision page for empty revision (#7307)....
Toshi MARUYAMA -
r4584:89627d0334e5
parent child
Show More
@@ -71,6 +71,7 class Repository::Mercurial < Repository
71
71
72 # Finds and returns a revision with a number or the beginning of a hash
72 # Finds and returns a revision with a number or the beginning of a hash
73 def find_changeset_by_name(name)
73 def find_changeset_by_name(name)
74 return nil if name.nil? || name.empty?
74 if /[^\d]/ =~ name or name.to_s.size > 8
75 if /[^\d]/ =~ name or name.to_s.size > 8
75 e = changesets.find(:first, :conditions => ['scmid = ?', name.to_s])
76 e = changesets.find(:first, :conditions => ['scmid = ?', name.to_s])
76 else
77 else
@@ -195,6 +195,16 class RepositoriesMercurialControllerTest < ActionController::TestCase
195 :attributes => { :class => 'line-num' },
195 :attributes => { :class => 'line-num' },
196 :sibling => { :tag => 'td', :content => /watcher =/ }
196 :sibling => { :tag => 'td', :content => /watcher =/ }
197 end
197 end
198
199 def test_empty_revision
200 @repository.fetch_changesets
201 @repository.reload
202 ['', ' ', nil].each do |r|
203 get :revision, :id => 1, :rev => r
204 assert_response 500
205 assert_error_tag :content => /was not found/
206 end
207 end
198 else
208 else
199 puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
209 puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
200 def test_fake; assert true end
210 def test_fake; assert true end
@@ -154,6 +154,14 class RepositoryMercurialTest < ActiveSupport::TestCase
154 assert_equal '2:400bb8672109', c.format_identifier
154 assert_equal '2:400bb8672109', c.format_identifier
155 end
155 end
156
156
157 def test_find_changeset_by_empty_name
158 @repository.fetch_changesets
159 @repository.reload
160 ['', ' ', nil].each do |r|
161 assert_nil @repository.find_changeset_by_name(r)
162 end
163 end
164
157 def test_activities
165 def test_activities
158 c = Changeset.new(:repository => @repository,
166 c = Changeset.new(:repository => @repository,
159 :committed_on => Time.now,
167 :committed_on => Time.now,
General Comments 0
You need to be logged in to leave comments. Login now