Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat.mv and Compat.cp with force keyword argument #512

Merged
merged 1 commit into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]).
Expand Down Expand Up @@ -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
7 changes: 7 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 20 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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