Skip to content

Commit

Permalink
Merge branch 'master' into sk/protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat authored Nov 14, 2019
2 parents b3ce2f3 + b16053f commit 6da5be9
Show file tree
Hide file tree
Showing 26 changed files with 292 additions and 138 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ docs/build
/docs/src/repl.md
.DS_Store
/test/registries/*
/test/loaded_depot/*
10 changes: 10 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ This section describes the function interface, or "API mode",
for interacting with Pkg.jl. The function API is recommended
for non-interactive usage, for example in scripts.

## General API Reference

Certain options are generally useful and can be specified in any API call.
You can specify these options by setting keyword arguments.

### Redirecting output

Use the `io::IOBuffer` keyword argument to redirect Pkg output.
For example, `Pkg.add("Example"; io=devnull)` will discard any output produced by the `add` call.

## Package API Reference

In the REPL mode, packages (with associated version, UUID, URL etc) are parsed from strings,
Expand Down
3 changes: 3 additions & 0 deletions docs/src/artifacts.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# [**8.** Artifacts](@id Artifacts)

!!! compat "Julia 1.3"
Pkg's artifacts functionality requires at least Julia 1.3.

`Pkg` can install and manage containers of data that are not Julia packages. These containers can contain platform-specific binaries, datasets, text, or any other kind of data that would be convenient to place within an immutable, life-cycled datastore.
These containers, (called "Artifacts") can be created locally, hosted anywhere, and automatically downloaded and unpacked upon installation of your Julia package.
This mechanism is also used to provide the binary dependencies for packages built with [`BinaryBuilder.jl`](https://github.com/JuliaPackaging/BinaryBuilder.jl).
Expand Down
4 changes: 2 additions & 2 deletions docs/src/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The union of multiple version specifiers can be formed by comma separating indiv
[compat]
Example = "1.2, 2"
```
will result in `[1.2.0, 3.0.0)`.
will result in `[1.2.0, 3.0.0)`. Note leading zeros are treated differently, e.g. `Example = "0.2, 1"` would only result in `[0.2.0-0.3.0, 1.0.0-2.0.0]`. See the next section for more information on versions with leading zeros.

### Behavior of versions with leading zeros (0.0.x and 0.x.y)

Expand All @@ -46,7 +46,7 @@ minor versions are not considered compatible, so the version 0.3.0 might have br
Example = "0.0.1"
```

results in a versionbound on `Example` as `[0.0.1, 0.02)` (which is equivalent to only the version 0.0.1), while the
results in a versionbound on `Example` as `[0.0.1, 0.0.2)` (which is equivalent to only the version 0.0.1), while the
`[compat]` entry:

```julia
Expand Down
21 changes: 12 additions & 9 deletions docs/src/toml-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ and `Manifest.toml` are written in [TOML](https://github.com/toml-lang/toml) (he
UUIDs etc.

!!! note
The `Project.toml` and `Manifest.toml` files are not only used by the package manager,
they are also used by Julia's code loading, and determines e.g. what `using Example`
The `Project.toml` and `Manifest.toml` files are not only used by the package manager;
they are also used by Julia's code loading, and determine e.g. what `using Example`
should do. For more details see the section about
[Code Loading](https://docs.julialang.org/en/v1/manual/code-loading/)
in the Julia manual.
Expand Down Expand Up @@ -41,6 +41,9 @@ uuid = "7876af07-990d-54b4-ab0e-23690620f79a"
```
The `uuid` field is mandatory for packages.

!!! note
It is recommended that `UUIDs.uuid4()` is used to generate random UUIDs.


### The `version` field

Expand Down Expand Up @@ -74,7 +77,7 @@ Example = "7876af07-990d-54b4-ab0e-23690620f79a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
```

Typically it is not needed to manually add entries to the `[deps]` section, this is instead
Typically it is not needed to manually add entries to the `[deps]` section; this is instead
handled by Pkg operations such as `add`.


Expand Down Expand Up @@ -105,10 +108,10 @@ julia = "1.1"
## `Manifest.toml`

The manifest file is an absolute record of the state of the packages in the environment.
It includes exact information about (direct and indirect) dependencies of the project, and
given a `Project.toml` + `Manifest.toml` pair it is possible to instantiate the exact same
package environment, which is very useful for reproducibility,
see [`Pkg.instantiate`](@ref).
It includes exact information about (direct and indirect) dependencies of the project.
Given a `Project.toml` + `Manifest.toml` pair, it is possible to instantiate the exact same
package environment, which is very useful for reproducibility.
For the details, see [`Pkg.instantiate`](@ref).

!!! note
The `Manifest.toml` file is generated and maintained by Pkg and, in general, this file
Expand All @@ -118,7 +121,7 @@ see [`Pkg.instantiate`](@ref).
### `Manifest.toml` entries

Each dependency has its own section in the manifest file, and its content varies depending
on how the dependency was added to the environment, see the examples below. Every
on how the dependency was added to the environment. Every
dependency section includes a combination of the following entries:

* `uuid`: the [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)
Expand Down Expand Up @@ -207,7 +210,7 @@ source tree is directly reflected.

#### Pinned package

Pinned packages are also recorded in the manifest file, the resulting
Pinned packages are also recorded in the manifest file; the resulting
dependency section for e.g. `pkg> add Example; pin Example` looks like:

```toml
Expand Down
2 changes: 1 addition & 1 deletion ext/TOML/src/TOML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module TOML

"Convert `TOML.Table` to `Dict{String,Any}`"
function table2dict(tbl::Union{Nothing,Table})
tbl == nothing && return Dict{String,Any}()
tbl === nothing && return Dict{String,Any}()
return table2dict(get(tbl))
end

Expand Down
24 changes: 17 additions & 7 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import LibGit2
import ..depots, ..depots1, ..logdir, ..devdir
import ..Operations, ..Display, ..GitTools, ..Pkg, ..UPDATED_REGISTRY_THIS_SESSION
using ..Types, ..TOML
using Pkg.Types: VersionTypes
using ..Types: VersionTypes
using ..BinaryPlatforms
using ..Artifacts: artifact_paths

Expand Down Expand Up @@ -394,7 +394,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(30), kwargs...)

# Collect the locations of every package referred to in this manifest
pkg_dir(uuid, entry) = Operations.find_installed(entry.name, uuid, entry.tree_hash)
return [pkg_dir(u, e) for (u, e) in manifest if e.tree_hash != nothing]
return [pkg_dir(u, e) for (u, e) in manifest if e.tree_hash !== nothing]
end

function process_artifacts_toml(path)
Expand Down Expand Up @@ -434,7 +434,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(30), kwargs...)
for index_file in index_files
# Check to see if it's still alive
paths = process_func(index_file)
if paths != nothing
if paths !== nothing
# Print the path of this beautiful, extant file to the user
println(" $(Types.pathrepr(index_file))")
append!(marked_paths, paths)
Expand Down Expand Up @@ -682,7 +682,7 @@ function precompile(ctx::Context)
for pkg in pkgids
paths = Base.find_all_in_cache_path(pkg)
sourcepath = Base.locate_package(pkg)
sourcepath == nothing && continue
sourcepath === nothing && continue
# Heuristic for when precompilation is disabled
occursin(r"\b__precompile__\(\s*false\s*\)", read(sourcepath, String)) && continue
stale = true
Expand Down Expand Up @@ -906,8 +906,18 @@ end
UndoState() = UndoState(0, UndoState[])
const undo_entries = Dict{String, UndoState}()
const max_undo_limit = 50

function add_snapshot_to_undo(env = EnvCache())
const saved_initial_snapshot = Ref(false)

function add_snapshot_to_undo(env=nothing)
# only attempt to take a snapshot if there is
# an active project to be found
if env === nothing
if Base.active_project() === nothing
return
else
env = EnvCache()
end
end
state = get!(undo_entries, env.project_file) do
UndoState()
end
Expand All @@ -929,7 +939,7 @@ function redo_undo(ctx, mode::Symbol, direction::Int)
@assert direction == 1 || direction == -1
state = get(undo_entries, ctx.env.project_file, nothing)
state === nothing && pkgerror("no undo state for current project")
state.idx == (mode == :redo ? 1 : length(state.entries)) && pkgerror("$mode: no more states left")
state.idx == (mode === :redo ? 1 : length(state.entries)) && pkgerror("$mode: no more states left")

state.idx += direction
snapshot = state.entries[state.idx]
Expand Down
Loading

0 comments on commit 6da5be9

Please sign in to comment.