svn_latest_changesets_improvement.diff

Go MAEDA, 2010-08-17 16:28

Download (1.13 KB)

View differences:

app/models/repository/subversion.rb (working copy)
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_to_find = "#{relative_url}/#{path}/%".gsub(%r{//+}, '/')
35
    revisions = 
36
      changesets.find(:all, :select => "distinct #{Changeset.table_name}.revision",
37
        :joins => "join #{Change.table_name} on #{Changeset.table_name}.id = #{Change.table_name}.changeset_id",
38
        :order => "#{Changeset.table_name}.revision desc",
39
        :limit => limit,
40
        :conditions => ["#{Change.table_name}.path like ?", path_to_find])
41
    revisions.collect! {|item| item.revision}
42
    changesets.find_all_by_revision(revisions, :order => "committed_on DESC", :include => :user)
36 43
  end
37 44
  
38 45
  # Returns a path relative to the url of the repository