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
This commit is contained in:
parent
d393306a0c
commit
b3c517387a
|
@ -61,14 +61,17 @@ class Repository::Mercurial < Repository
|
|||
end
|
||||
|
||||
# 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)
|
||||
if path.blank?
|
||||
changesets.find(:all, :include => :user, :limit => limit)
|
||||
else
|
||||
changes.find(:all, :include => {:changeset => :user},
|
||||
:conditions => ["path = ?", path.with_leading_slash],
|
||||
:order => "#{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
|
||||
|
||||
|
|
Loading…
Reference in New Issue