@@ -55,6 +55,17 class Repository::Mercurial < Repository | |||
|
55 | 55 | entries |
|
56 | 56 | end |
|
57 | 57 | |
|
58 | # Finds and returns a revision with a number or the beginning of a hash | |
|
59 | def find_changeset_by_name(name) | |
|
60 | if /[^\d]/ =~ name or name.to_s.size > 8 | |
|
61 | e = changesets.find(:first, :conditions => ['scmid = ?', name.to_s]) | |
|
62 | else | |
|
63 | e = changesets.find(:first, :conditions => ['revision = ?', name.to_s]) | |
|
64 | end | |
|
65 | return e if e | |
|
66 | changesets.find(:first, :conditions => ['scmid LIKE ?', "#{name}%"]) # last ditch | |
|
67 | end | |
|
68 | ||
|
58 | 69 | # Returns the latest changesets for +path+; sorted by revision number |
|
59 | 70 | def latest_changesets(path, rev, limit=10) |
|
60 | 71 | if path.blank? |
@@ -47,6 +47,17 begin | |||
|
47 | 47 | assert_nil @adapter.cat("sources/welcome_controller.rb") |
|
48 | 48 | end |
|
49 | 49 | |
|
50 | def test_access_by_nodeid | |
|
51 | path = 'sources/welcome_controller.rb' | |
|
52 | assert_equal @adapter.cat(path, 2), @adapter.cat(path, '400bb8672109') | |
|
53 | end | |
|
54 | ||
|
55 | def test_access_by_fuzzy_nodeid | |
|
56 | path = 'sources/welcome_controller.rb' | |
|
57 | # falls back to nodeid | |
|
58 | assert_equal @adapter.cat(path, 2), @adapter.cat(path, '400') | |
|
59 | end | |
|
60 | ||
|
50 | 61 | private |
|
51 | 62 | |
|
52 | 63 | def test_hgversion_for(hgversion, version) |
@@ -35,7 +35,8 class RepositoryMercurialTest < ActiveSupport::TestCase | |||
|
35 | 35 | |
|
36 | 36 | assert_equal 17, @repository.changesets.count |
|
37 | 37 | assert_equal 25, @repository.changes.count |
|
38 |
assert_equal "Initial import.\nThe repository contains 3 files.", |
|
|
38 | assert_equal "Initial import.\nThe repository contains 3 files.", | |
|
39 | @repository.changesets.find_by_revision('0').comments | |
|
39 | 40 | end |
|
40 | 41 | |
|
41 | 42 | def test_fetch_changesets_incremental |
@@ -51,7 +52,9 class RepositoryMercurialTest < ActiveSupport::TestCase | |||
|
51 | 52 | |
|
52 | 53 | def test_entries |
|
53 | 54 | assert_equal 2, @repository.entries("sources", 2).size |
|
55 | assert_equal 2, @repository.entries("sources", '400bb8672109').size | |
|
54 | 56 | assert_equal 1, @repository.entries("sources", 3).size |
|
57 | assert_equal 1, @repository.entries("sources", 'b3a615152df8').size | |
|
55 | 58 | end |
|
56 | 59 | |
|
57 | 60 | def test_locate_on_outdated_repository |
@@ -122,6 +125,20 class RepositoryMercurialTest < ActiveSupport::TestCase | |||
|
122 | 125 | assert_equal '/README (1)[2]&,%.-3_4', c2[0].path |
|
123 | 126 | assert_equal '/README', c2[0].from_path |
|
124 | 127 | end |
|
128 | ||
|
129 | def test_find_changeset_by_name | |
|
130 | @repository.fetch_changesets | |
|
131 | @repository.reload | |
|
132 | %w|2 400bb8672109 400|.each do |r| | |
|
133 | assert_equal @repository.find_changeset_by_name(r).revision, '2' | |
|
134 | end | |
|
135 | end | |
|
136 | ||
|
137 | def test_find_changeset_by_invalid_name | |
|
138 | @repository.fetch_changesets | |
|
139 | @repository.reload | |
|
140 | assert_nil @repository.find_changeset_by_name('100000') | |
|
141 | end | |
|
125 | 142 | else |
|
126 | 143 | puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" |
|
127 | 144 | def test_fake; assert true end |
General Comments 0
You need to be logged in to leave comments.
Login now