From 6bdc2c36f112ff1c024ed174fb4d47b38b8a90ac Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Thu, 23 Feb 2012 12:18:30 +0000 Subject: [PATCH] scm: mercurial: use to_s for revision in find_changeset_by_name method On Rails 3.0.11, functional test fails.
Error: test_diff_two_revs(RepositoriesMercurialControllerTest)
NoMethodError: undefined method `empty?' for 4:Fixnum
app/models/repository/mercurial.rb:76:in `find_changeset_by_name'
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8938 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/repository/mercurial.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb index e40841f20..391c4466f 100644 --- a/app/models/repository/mercurial.rb +++ b/app/models/repository/mercurial.rb @@ -73,14 +73,15 @@ 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]) + return nil if name.blank? + s = name.to_s + if /[^\d]/ =~ s or s.size > 8 + e = changesets.find(:first, :conditions => ['scmid = ?', s]) else - e = changesets.find(:first, :conditions => ['revision = ?', name.to_s]) + e = changesets.find(:first, :conditions => ['revision = ?', s]) end return e if e - changesets.find(:first, :conditions => ['scmid LIKE ?', "#{name}%"]) # last ditch + changesets.find(:first, :conditions => ['scmid LIKE ?', "#{s}%"]) # last ditch end # Returns the latest changesets for +path+; sorted by revision number -- 2.39.5