diff --git a/README.md b/README.md index 53305fa35..7406aa4c3 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.trunc`, `Compat.floor`, `Compat.ceil`, `Compat.round`, `Compat.signif` take a keyword argument for `base` ([#26156]). +* `Compat.mv` and `Compat.cp` with `force` keyword argument ([#26069]). + ## Renaming * `Display` is now `AbstractDisplay` ([#24831]). @@ -580,6 +582,8 @@ includes this fix. Find the minimum version from there. [#25819]: https://github.com/JuliaLang/julia/issues/25819 [#25873]: https://github.com/JuliaLang/julia/issues/25873 [#25896]: https://github.com/JuliaLang/julia/issues/25896 +[#25959]: https://github.com/JuliaLang/julia/issues/25959 [#25990]: https://github.com/JuliaLang/julia/issues/25990 +[#26069]: https://github.com/JuliaLang/julia/issues/26069 [#26089]: https://github.com/JuliaLang/julia/issues/26089 [#26156]: https://github.com/JuliaLang/julia/issues/26156 diff --git a/src/Compat.jl b/src/Compat.jl index 714a05962..965669013 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1658,6 +1658,13 @@ else import Base: range, LinRange end +@static if VERSION < v"0.7.0-DEV.3995" + cp(src::AbstractString, dst::AbstractString; force::Bool=false, follow_symlinks::Bool=false) = + Base.cp(src, dst; remove_destination = force, follow_symlinks = follow_symlinks) + mv(src::AbstractString, dst::AbstractString; force::Bool=false) = + Base.mv(src, dst; remove_destination = force) +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index 0060a7c37..3844f2200 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1467,4 +1467,24 @@ end @test Compat.range(2, step=2, length=8) == 2:2:16 @test Compat.range(1.0, stop=2.0, length=3) == 1.0:0.5:2.0 +# 0.7.0-DEV.3995 +mktempdir(@__DIR__) do dir + src = joinpath(dir, "src.jl") + touch(src) + dest = joinpath(dir, "dest.jl") + touch(dest) + open(src, "w") do f + write(f, "Hello, world!") + end + Compat.cp(src, dest, force = true) + open(dest, "r") do f + @test read(f, String) == "Hello, world!" + end + Compat.mv(src, dest, force = true) + open(dest, "r") do f + @test read(f, String) == "Hello, world!" + end + @test readdir(dir) == ["dest.jl"] +end + nothing