diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2012-02-23 12:18:30 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2012-02-23 12:18:30 +0000 |
commit | 6bdc2c36f112ff1c024ed174fb4d47b38b8a90ac (patch) | |
tree | d24467054d62f3c95896849cc9701a2fd5e0e81c | |
parent | 7e347069d5607a329de2bcfd77dbbb9c2e345630 (diff) | |
download | redmine-6bdc2c36f112ff1c024ed174fb4d47b38b8a90ac.tar.gz redmine-6bdc2c36f112ff1c024ed174fb4d47b38b8a90ac.zip |
scm: mercurial: use to_s for revision in find_changeset_by_name method
On Rails 3.0.11, functional test fails.
<pre>
Error: test_diff_two_revs(RepositoriesMercurialControllerTest)
NoMethodError: undefined method `empty?' for 4:Fixnum
app/models/repository/mercurial.rb:76:in `find_changeset_by_name'
</pre>
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8938 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/repository/mercurial.rb | 11 |
1 files 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 |