Skip to content

Commit

Permalink
Remove unused Base.check_new_version function. (#31800)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored Apr 23, 2019
1 parent 73366ae commit 5741c7f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
21 changes: 0 additions & 21 deletions base/version.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down
28 changes: 1 addition & 27 deletions test/version.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5741c7f

Please sign in to comment.