Skip to content
Open
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
20 changes: 19 additions & 1 deletion docs/src/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,24 @@ string `"1"` (e.g., `JULIA_REVISE_INCLUDE=1` in a bash script).
Most users should avoid setting `JULIA_REVISE_INCLUDE`.
Try `includet` instead.

### Enabling struct revision

On Julia 1.12+, Revise can automatically revise `struct` definitions in a
running session. This feature requires scanning the global method table and
type hierarchy at startup, which can be slow so it's disabled by default. If you
would like to enable it you can set the `revise_structs` preference to `true`
via [Preferences.jl](https://github.com/JuliaPackaging/Preferences.jl).

Add the following to the `LocalPreferences.toml` file in your active project:

```toml
[Revise]
revise_structs = true
```

!!! warning
The default for this preference may change in the future.

## Configurations for fixing errors

### No space left on device
Expand Down Expand Up @@ -158,7 +176,7 @@ $ sudo sysctl fs.inotify.max_user_instances=2048
```
After changing these values, it is advised to run Revise's unit tests to see if they pass.

This change can be made [permanent](https://www.suse.com/de-de/support/kb/doc/?id=000020048).
This change can be made [permanent](https://support.scc.suse.com/s/kb/360054835111).

For more information see issues [#26](https://github.com/timholy/Revise.jl/issues/26)
and [#778](https://github.com/timholy/Revise.jl/issues/778).
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ end

To make it easier for other packages to benefit from Revise without needing to add it
as a dependency or understand Revise's internals, Revise interfaces with
[CodeTracking](https://github.com/timholy/CodeTracking.jl),
[CodeTracking](https://github.com/JuliaDebug/CodeTracking.jl),
which is a small package acting as Revise's "query" interface.

## What else do I need to know?
Expand Down
2 changes: 1 addition & 1 deletion src/lowered.jl
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ function _methods_by_execution!(
callstmt = stmt
@label call_dispatch
f = lookup(frame, callstmt.args[1])
if __bpart__ && f === Core._typebody!
if __bpart__[] && f === Core._typebody!
analyze_typebody!(exinfo, interp, frame, callstmt)
pc = step_expr!(interp, frame, stmt, true)
elseif is_defaultctors(f) && length(callstmt.args) == 3
Expand Down
12 changes: 7 additions & 5 deletions src/packagedef.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ Global variable, maps `(pkgdata, filename)` pairs that errored upon last revisio
"""
const queue_errors = Dict{Tuple{PkgData,String},Tuple{Exception, Any}}() # locking is covered by revision_queue_lock

# Can we revise types?
const __bpart__ = Base.VERSION >= v"1.12.0-DEV.2047"
# Can we revise types? This is assigned in __init__() based on the Julia version
# and preference.
const __bpart__ = Ref(false)

"""
Revise.NOPACKAGE
Expand Down Expand Up @@ -343,7 +344,7 @@ function delete_missing!(
for exinfo in exinfos
if exinfo isa SigInfo
handle_method_deletion!(exinfo, rex, world)
elseif __bpart__
elseif __bpart__[]
handle_type_deletion!(exinfo::TypeInfo, reeval_list, handled_types, world)
end
end
Expand Down Expand Up @@ -1006,7 +1007,7 @@ function revise(; throw::Bool=false)
end

# Do binding redefinitions
if __bpart__
if __bpart__[]
redefine_bindings!(revision_errors, reeval_list, world)
end

Expand Down Expand Up @@ -1594,6 +1595,7 @@ function __init__()
for pkg in silenced
push!(silence_pkgs, pkg)
end
__bpart__[] = Base.VERSION >= v"1.12.0-DEV.2047" && Preferences.@load_preference("revise_structs", false)
polling = get(ENV, "JULIA_REVISE_POLL", "0")
if polling == "1"
polling_files[] = watching_files[] = true
Expand Down Expand Up @@ -1663,7 +1665,7 @@ function __init__()
# This feature needs to be disabled on Apple Silicon for Julia v1.12 and earlier
# due to the Julia runtime side issue (https://github.com/JuliaLang/julia/issues/60721)
@static if !(VERSION < v"1.13-" && Sys.isapple())
if __bpart__ && (isnothing(distributed_module) || distributed_module.myid() == 1)
if __bpart__[] && (isnothing(distributed_module) || distributed_module.myid() == 1)
Threads.@spawn :default foreach_subtype(Any) do @nospecialize type
# Populating this cache can be time consuming (eg, 30s on an
# i7-7700HQ) so do this incrementally and yield() to the scheduler
Expand Down
10 changes: 5 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,7 @@ end
pop!(LOAD_PATH)
end

Revise.__bpart__ && do_test("Type info tracking") && @testset "Type info tracking" begin
Revise.__bpart__[] && do_test("Type info tracking") && @testset "Type info tracking" begin
let exinfo = lower_and_track(:(abstract type ABC end))
typeinfo = only(exinfo.typeinfos)
@test typeinfo.typname == @invokelatest(getglobal(TypeInfoTracking, :ABC)).name
Expand Down Expand Up @@ -2529,9 +2529,9 @@ end
end
end

Revise.__bpart__ && do_test("visit") && @testset "visit" include("test_visit.jl")
Revise.__bpart__[] && do_test("visit") && @testset "visit" include("test_visit.jl")

if Revise.__bpart__ && do_test("struct revision (simple)") # can we revise types and constants?
if Revise.__bpart__[] && do_test("struct revision (simple)") # can we revise types and constants?
@testset "struct revision (simple)" begin
testdir = newtestdir()
try
Expand Down Expand Up @@ -2566,7 +2566,7 @@ end
end
end

if Revise.__bpart__ && do_test("struct revision (retry)")
if Revise.__bpart__[] && do_test("struct revision (retry)")
@testset "struct revision (retry)" begin
testdir = newtestdir()
try
Expand Down Expand Up @@ -2617,7 +2617,7 @@ end
end
end

if Revise.__bpart__ && do_test("struct revision (dependency)") # can we revise types and constants?
if Revise.__bpart__[] && do_test("struct revision (dependency)") # can we revise types and constants?
@testset "struct revision (dependency)" begin
testdir = newtestdir()
try
Expand Down
Loading