entries
end
+ # Finds and returns a revision with a number or the beginning of a hash
+ def find_changeset_by_name(name)
+ if /[^\d]/ =~ name or name.to_s.size > 8
+ e = changesets.find(:first, :conditions => ['scmid = ?', name.to_s])
+ else
+ e = changesets.find(:first, :conditions => ['revision = ?', name.to_s])
+ end
+ return e if e
+ changesets.find(:first, :conditions => ['scmid LIKE ?', "#{name}%"]) # last ditch
+ end
+
# Returns the latest changesets for +path+; sorted by revision number
def latest_changesets(path, rev, limit=10)
if path.blank?
assert_nil @adapter.cat("sources/welcome_controller.rb")
end
+ def test_access_by_nodeid
+ path = 'sources/welcome_controller.rb'
+ assert_equal @adapter.cat(path, 2), @adapter.cat(path, '400bb8672109')
+ end
+
+ def test_access_by_fuzzy_nodeid
+ path = 'sources/welcome_controller.rb'
+ # falls back to nodeid
+ assert_equal @adapter.cat(path, 2), @adapter.cat(path, '400')
+ end
+
private
def test_hgversion_for(hgversion, version)
assert_equal 17, @repository.changesets.count
assert_equal 25, @repository.changes.count
- assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision('0').comments
+ assert_equal "Initial import.\nThe repository contains 3 files.",
+ @repository.changesets.find_by_revision('0').comments
end
def test_fetch_changesets_incremental
def test_entries
assert_equal 2, @repository.entries("sources", 2).size
+ assert_equal 2, @repository.entries("sources", '400bb8672109').size
assert_equal 1, @repository.entries("sources", 3).size
+ assert_equal 1, @repository.entries("sources", 'b3a615152df8').size
end
def test_locate_on_outdated_repository
assert_equal '/README (1)[2]&,%.-3_4', c2[0].path
assert_equal '/README', c2[0].from_path
end
+
+ def test_find_changeset_by_name
+ @repository.fetch_changesets
+ @repository.reload
+ %w|2 400bb8672109 400|.each do |r|
+ assert_equal @repository.find_changeset_by_name(r).revision, '2'
+ end
+ end
+
+ def test_find_changeset_by_invalid_name
+ @repository.fetch_changesets
+ @repository.reload
+ assert_nil @repository.find_changeset_by_name('100000')
+ end
else
puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!"
def test_fake; assert true end