@@ -18,6 +18,9 | |||
|
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 | |
@@ -52,6 +55,18 class Repository::Mercurial < Repository | |||
|
52 | 55 | entries |
|
53 | 56 | end |
|
54 | 57 | |
|
58 | # Returns the latest changesets for +path+; sorted by revision number | |
|
59 | def latest_changesets(path, rev, limit=10) | |
|
60 | if path.blank? | |
|
61 | changesets.find(:all, :include => :user, :limit => limit) | |
|
62 | else | |
|
63 | changes.find(:all, :include => {:changeset => :user}, | |
|
64 | :conditions => ["path = ?", path.with_leading_slash], | |
|
65 | :order => "#{Changeset.table_name}.id DESC", | |
|
66 | :limit => limit).collect(&:changeset) | |
|
67 | end | |
|
68 | end | |
|
69 | ||
|
55 | 70 | def fetch_changesets |
|
56 | 71 | scm_info = scm.info |
|
57 | 72 | if scm_info |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -76,6 +76,17 class RepositoryMercurialTest < ActiveSupport::TestCase | |||
|
76 | 76 | assert_equal @repository.changesets.find_by_revision('0').committed_on, rev0_committed_on |
|
77 | 77 | end |
|
78 | 78 | end |
|
79 | ||
|
80 | def test_changeset_order_by_revision | |
|
81 | @repository.fetch_changesets | |
|
82 | @repository.reload | |
|
83 | ||
|
84 | c0 = @repository.latest_changeset | |
|
85 | c1 = @repository.changesets.find_by_revision('0') | |
|
86 | # sorted by revision (id), not by date | |
|
87 | assert c0.revision.to_i > c1.revision.to_i | |
|
88 | assert c0.committed_on < c1.committed_on | |
|
89 | end | |
|
79 | 90 | else |
|
80 | 91 | puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" |
|
81 | 92 | def test_fake; assert true end |
General Comments 0
You need to be logged in to leave comments.
Login now