scm: mercurial: fix error on revision page for empty revision (#7307).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4704 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-01-13 12:04:51 +00:00
parent 98b3a50657
commit 89627d0334
3 changed files with 19 additions and 0 deletions

View File

@ -71,6 +71,7 @@ class Repository::Mercurial < Repository
# Finds and returns a revision with a number or the beginning of a hash
def find_changeset_by_name(name)
return nil if name.nil? || name.empty?
if /[^\d]/ =~ name or name.to_s.size > 8
e = changesets.find(:first, :conditions => ['scmid = ?', name.to_s])
else

View File

@ -195,6 +195,16 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
:attributes => { :class => 'line-num' },
:sibling => { :tag => 'td', :content => /watcher =/ }
end
def test_empty_revision
@repository.fetch_changesets
@repository.reload
['', ' ', nil].each do |r|
get :revision, :id => 1, :rev => r
assert_response 500
assert_error_tag :content => /was not found/
end
end
else
puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
def test_fake; assert true end

View File

@ -154,6 +154,14 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
assert_equal '2:400bb8672109', c.format_identifier
end
def test_find_changeset_by_empty_name
@repository.fetch_changesets
@repository.reload
['', ' ', nil].each do |r|
assert_nil @repository.find_changeset_by_name(r)
end
end
def test_activities
c = Changeset.new(:repository => @repository,
:committed_on => Time.now,