Project

General

Profile

Patch #6159 » latest-changesets-improvements.diff

Yuya Nishihara, 2010-08-19 16:21

View differences:

app/models/repository.rb
105 105
  # Default behaviour is to search in cached changesets
106 106
  def latest_changesets(path, rev, limit=10)
107 107
    if path.blank?
108
      changesets.find(:all, :include => :user,
109
                            :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
110
                            :limit => limit)
108
      changesets.find(:all, :include => :user, :limit => limit)
111 109
    else
112
      changes.find(:all, :include => {:changeset => :user}, 
113
                         :conditions => ["path = ?", path.with_leading_slash],
114
                         :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
115
                         :limit => limit).collect(&:changeset)
110
      changesets.find(:all, :select => "DISTINCT #{Changeset.table_name}.*",
111
                      :joins => :changes,
112
                      :conditions => ["#{Change.table_name}.path = ? OR #{Change.table_name}.path LIKE ?",
113
                                      path.with_leading_slash,
114
                                      "#{path.with_leading_slash.gsub('%', '%%')}/%"],
115
                      :include => :user, :limit => limit)
116 116
    end
117 117
  end
118 118
    
app/models/repository/subversion.rb
31 31
  end
32 32

  
33 33
  def latest_changesets(path, rev, limit=10)
34
    revisions = scm.revisions(path, rev, nil, :limit => limit)
35
    revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC", :include => :user) : []
34
    path = "#{relative_url}/#{path}".gsub(%r|/+|, '/') unless path.blank?
35
    super(path, rev, limit)
36 36
  end
37 37
  
38 38
  # Returns a path relative to the url of the repository
(2-2/9)