From 5741c7f53c5ea443bbd73cc5157b83de415c6d1b Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Tue, 23 Apr 2019 16:33:49 +0200 Subject: [PATCH] Remove unused Base.check_new_version function. (#31800) --- base/version.jl | 21 --------------------- test/version.jl | 28 +--------------------------- 2 files changed, 1 insertion(+), 48 deletions(-) diff --git a/base/version.jl b/base/version.jl index 7959d2c77bc4d..16c9ccc83a8cf 100644 --- a/base/version.jl +++ b/base/version.jl @@ -211,27 +211,6 @@ nextpatch(v::VersionNumber) = v < thispatch(v) ? thispatch(v) : VersionNumber(v. nextminor(v::VersionNumber) = v < thisminor(v) ? thisminor(v) : VersionNumber(v.major, v.minor+1, 0) nextmajor(v::VersionNumber) = v < thismajor(v) ? thismajor(v) : VersionNumber(v.major+1, 0, 0) -function check_new_version(existing::Vector{VersionNumber}, ver::VersionNumber) - if isempty(existing) - for v in [v"0.0.1", v"0.1", v"1"] - lowerbound(v) <= ver <= v && return - end - error("version $ver is invalid initial version (try 0.0.1, 0.1, 1.0)") - end - issorted(existing) || (existing = sort(existing)) - idx = searchsortedlast(existing, ver) - idx > 0 || error("version $ver less than least existing version $(existing[1])") - prv = existing[idx] - ver == prv && error("version $ver already exists") - nxt = thismajor(ver) != thismajor(prv) ? nextmajor(prv) : - thisminor(ver) != thisminor(prv) ? nextminor(prv) : nextpatch(prv) - ver <= nxt || error("version $ver skips over $nxt") - thispatch(ver) <= ver && return # regular or build release - idx < length(existing) && thispatch(existing[idx+1]) <= nxt && - error("version $ver is pre-release of existing version $(existing[idx+1])") - return # acceptable new version -end - ## julia version info """ diff --git a/test/version.jl b/test/version.jl index 37f41fa613fb4..f5da803eed795 100644 --- a/test/version.jl +++ b/test/version.jl @@ -134,7 +134,7 @@ import Base: lowerbound, upperbound # advanced comparison & manipulation import Base: thispatch, thisminor, thismajor, - nextpatch, nextminor, nextmajor, check_new_version + nextpatch, nextminor, nextmajor @test v"1.2.3" == thispatch(v"1.2.3-") @test v"1.2.3" == thispatch(v"1.2.3-pre") @test v"1.2.3" == thispatch(v"1.2.3") @@ -207,32 +207,6 @@ for major=0:3, minor=0:3, patch=0:3 end end -# check_new_version -import Base.check_new_version -@test check_new_version([v"1", v"2"], v"3") === nothing -@test check_new_version([v"2", v"1"], v"3") === nothing -@test_throws ErrorException check_new_version([v"1", v"2"], v"2") -@test_throws ErrorException check_new_version(VersionNumber[], v"0") -@test check_new_version(VersionNumber[], v"0.0.1") === nothing -@test_throws ErrorException check_new_version(VersionNumber[], v"0.0.2") -@test check_new_version(VersionNumber[], v"0.1") === nothing -@test_throws ErrorException check_new_version(VersionNumber[], v"0.2") -@test check_new_version(VersionNumber[], v"1") === nothing -@test_throws ErrorException check_new_version(VersionNumber[], v"2") -@test_throws ErrorException check_new_version(VersionNumber[v"1", v"2", v"3"], v"2") -@test_throws ErrorException check_new_version([v"1", v"2"], v"4") -@test_throws ErrorException check_new_version([v"1", v"2"], v"2-rc") -@test_throws ErrorException check_new_version([v"1", v"2"], v"0") -@test_throws ErrorException check_new_version([v"1", v"2"], v"0.9") -@test check_new_version([v"1", v"2"], v"2.0.1") === nothing -@test check_new_version([v"1", v"2"], v"2.1") === nothing -@test check_new_version([v"1", v"2"], v"3") === nothing - -let vers = [v"2", v"1"] - @test check_new_version(vers, v"3") == nothing - @test vers == [v"2", v"1"] # no mutation -end - # banner import Base.banner io = IOBuffer()