Skip to content

Commit a059bd7

Browse files
authored
Merge pull request #23446 from JuliaLang/teh/revise
Describe how to hack Base more easily with Revise.jl
2 parents e89d150 + 6347dbd commit a059bd7

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

CONTRIBUTING.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ The Julia community uses [GitHub issues](https://github.com/JuliaLang/julia/issu
196196

197197
Note: These instructions are for adding to or improving functionality in the base library. Before getting started, it can be helpful to discuss the proposed changes or additions on the [Julia Discourse forum](https://discourse.julialang.org) or in a GitHub issue---it's possible your proposed change belongs in a package rather than the core language. Also, keep in mind that changing stuff in the base can potentially break a lot of things. Finally, because of the time required to build Julia, note that it's usually faster to develop your code in stand-alone files, get it working, and then migrate it into the base libraries.
198198

199-
Add new code to Julia's base libraries as follows:
199+
Add new code to Julia's base libraries as follows (this is the "basic" approach; see a more efficient approach in the next section):
200200

201201
1. Edit the appropriate file in the `base/` directory, or add new files if necessary. Create tests for your functionality and add them to files in the `test/` directory. If you're editing C or Scheme code, most likely it lives in `src/` or one of its subdirectories, although some aspects of Julia's REPL initialization live in `ui/`.
202202

@@ -218,6 +218,55 @@ or with the `runtests.jl` script, e.g. to run `test/bitarray.jl` and `test/math.
218218

219219
Make sure that [Travis](http://www.travis-ci.org) greenlights the pull request with a [`Good to merge` message](http://blog.travis-ci.com/2012-09-04-pull-requests-just-got-even-more-awesome).
220220

221+
#### Modifying base more efficiently with Revise.jl
222+
223+
[Revise](https://github.com/timholy/Revise.jl) is a package that
224+
tracks changes in source files and automatically updates function
225+
definitions in your running Julia session. Using it, you can make
226+
extensive changes to Base without needing to rebuild in order to test
227+
your changes.
228+
229+
Here is the standard procedure:
230+
231+
1. If you are planning changes to any types or macros, make those
232+
changes, commit them, and build julia using `make`. (This is
233+
necessary because `Revise` cannot handle changes to type
234+
definitions or macros.) By making a git commit, you "shield" these
235+
changes from the `git stash` procedure described below. Unless it's
236+
required to get Julia to build, you do not have to add any
237+
functionality based on the new types, just the type definitions
238+
themselves.
239+
240+
2. Start a Julia REPL session. Then issue the following commands:
241+
242+
```julia
243+
using Revise # if you aren't launching it in your .juliarc.jl
244+
Revise.track(Base)
245+
```
246+
247+
3. Edit files in `base/`, save your edits, and test the
248+
functionality. Once you are satisfied that things work as desired,
249+
make another commit and rebuild julia.
250+
251+
Should you for some reason need to quit and restart your REPL session
252+
before finishing your changes, the procedure above will fail because
253+
`Revise.track`
254+
[cannot detect changes in source files that occurred after Julia was built](https://github.com/JuliaLang/julia/issues/23448)---it
255+
will only detect changes to source files that occur after tracking is
256+
initiated. Consequently, any changes made prior to
257+
`Revise.track(Base)` will not be incorporated into your new REPL
258+
session. You can work around this by temporarily reverting all source
259+
files to their original state. From somewhere in the `julia`
260+
directory, start your REPL session and do the following:
261+
262+
```julia
263+
shell> git stash # ensure that the code in `base/` matches its state when you built julia
264+
265+
julia> Revise.track(Base) # Revise's source code cache is synchronized with what's running
266+
267+
shell> git stash pop # restore any in-progress changes (will now be tracked)
268+
```
269+
221270
### Code Formatting Guidelines
222271

223272
#### General Formatting Guidelines for Julia code contributions

0 commit comments

Comments
 (0)