Project

General

Profile

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

Toshi MARUYAMA, 2010-11-30 07:18

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 ? ESCAPE ?",
113
                                      path.with_leading_slash,
114
                                      "#{path.with_leading_slash.gsub(/[%_\\]/) { |s| "\\#{s}" }}/%", '\\'],
115
                      :include => :user, :limit => limit)
116 116
    end
117 117
  end
118 118
    
app/models/repository/mercurial.rb
18 18
require 'redmine/scm/adapters/mercurial_adapter'
19 19

  
20 20
class Repository::Mercurial < Repository
21
  # sort changesets by revision number
22
  has_many :changesets, :order => "#{Changeset.table_name}.id DESC", :foreign_key => 'repository_id'
23

  
21 24
  attr_protected :root_url
22 25
  validates_presence_of :url
23 26

  
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
    if url =~ %r|^file://|
35
      revisions = scm.revisions(path, rev, nil, :limit => limit)
36
      revisions ? changesets.find_all_by_revision(
37
                        revisions.collect(&:identifier),
38
                        :order => "committed_on DESC", :include => :user) : []
39
    else
40
      path = "#{relative_url}/#{path}".gsub(%r|/+|, '/') unless path.blank?
41
      super(path, rev, limit)
42
    end
36 43
  end
37 44
  
38 45
  # Returns a path relative to the url of the repository
(5-5/9)