scm: mercurial: improvement latest_changesets without supporting tags and named branches (#4455).

Based on latest-changesets-improvements-2.diff of #6159.
http://www.redmine.org/attachments/4332/latest-changesets-improvements-2.diff

Contributed by Yuya Nishihara.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4868 e93f8b46-1217-0410-a6f0-8f06a7374b81
pull/351/head
Toshi MARUYAMA 14 years ago committed by Eric Davis
parent 05c0c88840
commit 7c6a205a01
  1. 11
      app/models/repository/mercurial.rb

@ -61,14 +61,17 @@ class Repository::Mercurial < Repository
end end
# Returns the latest changesets for +path+; sorted by revision number # Returns the latest changesets for +path+; sorted by revision number
# Default behavior 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, :limit => limit) changesets.find(:all, :include => :user, :limit => limit)
else else
changes.find(:all, :include => {:changeset => :user}, changesets.find(:all, :select => "DISTINCT #{Changeset.table_name}.*",
:conditions => ["path = ?", path.with_leading_slash], :joins => :changes,
:order => "#{Changeset.table_name}.id DESC", :conditions => ["#{Change.table_name}.path = ? OR #{Change.table_name}.path LIKE ? ESCAPE ?",
:limit => limit).collect(&:changeset) path.with_leading_slash,
"#{path.with_leading_slash.gsub(/[%_\\]/) { |s| "\\#{s}" }}/%", '\\'],
:include => :user, :limit => limit)
end end
end end

Loading…
Cancel
Save