scm: code clean up repository model.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5653 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-05-05 07:30:22 +00:00
parent 9c3a9fdd87
commit fbdbdf96fe

View File

@ -1,5 +1,5 @@
# redMine - project management software # Redmine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@ -146,14 +146,19 @@ class Repository < ActiveRecord::Base
# Default behaviour is to search in cached changesets # Default behaviour is to search in cached changesets
def latest_changesets(path, rev, limit=10) def latest_changesets(path, rev, limit=10)
if path.blank? if path.blank?
changesets.find(:all, :include => :user, changesets.find(
:all,
:include => :user,
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC", :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
:limit => limit) :limit => limit)
else else
changes.find(:all, :include => {:changeset => :user}, changes.find(
:all,
:include => {:changeset => :user},
:conditions => ["path = ?", path.with_leading_slash], :conditions => ["path = ?", path.with_leading_slash],
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC", :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
:limit => limit).collect(&:changeset) :limit => limit
).collect(&:changeset)
end end
end end