Project

General

Profile

Patch #6159 » latest-changesets-improvements-4.diff

Toshi MARUYAMA, 2010-11-30 07:18

View differences:

app/models/repository.rb
# Default behaviour is to search in cached changesets
def latest_changesets(path, rev, limit=10)
if path.blank?
changesets.find(:all, :include => :user,
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
:limit => limit)
changesets.find(:all, :include => :user, :limit => limit)
else
changes.find(:all, :include => {:changeset => :user},
:conditions => ["path = ?", path.with_leading_slash],
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
:limit => limit).collect(&:changeset)
changesets.find(:all, :select => "DISTINCT #{Changeset.table_name}.*",
:joins => :changes,
:conditions => ["#{Change.table_name}.path = ? OR #{Change.table_name}.path LIKE ? ESCAPE ?",
path.with_leading_slash,
"#{path.with_leading_slash.gsub(/[%_\\]/) { |s| "\\#{s}" }}/%", '\\'],
:include => :user, :limit => limit)
end
end
app/models/repository/mercurial.rb
require 'redmine/scm/adapters/mercurial_adapter'
class Repository::Mercurial < Repository
# sort changesets by revision number
has_many :changesets, :order => "#{Changeset.table_name}.id DESC", :foreign_key => 'repository_id'
attr_protected :root_url
validates_presence_of :url
app/models/repository/subversion.rb
end
def latest_changesets(path, rev, limit=10)
revisions = scm.revisions(path, rev, nil, :limit => limit)
revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC", :include => :user) : []
if url =~ %r|^file://|
revisions = scm.revisions(path, rev, nil, :limit => limit)
revisions ? changesets.find_all_by_revision(
revisions.collect(&:identifier),
:order => "committed_on DESC", :include => :user) : []
else
path = "#{relative_url}/#{path}".gsub(%r|/+|, '/') unless path.blank?
super(path, rev, limit)
end
end
# Returns a path relative to the url of the repository
(5-5/9)