Expand description
The two version grammars Mars reads and how a version is chosen among a repository’s tags.
A dependency entry’s version (see parse_constraint) and a package’s requires-mars /
requires-meridian (satisfies_requirement) are different grammars: a bare 0.20 is the
caret range ^0.20 in the first and >=0.20.0 in the second. Everything here is pure; the
caller supplies the tag list and acts on the choice. choose is the whole decision: the
binary runs its stages (settle, the lock check keeps_lock, then
select) itself, because it replays the lock without listing tags, and selectVersion of
the WASM package runs them all at once. A lock that holds is kept without asking whether its
tag is still in the repository: only mars upgrade moves it.
Enums§
- Choose
Error - Why no ref could be chosen.
- Chosen
- What a package ends at.
- Constraint
- A dependency entry’s
version, read. - Parse
Error - Version text that is not the kind of version the caller said it was.
- Select
Error - Why no version could be chosen.
- Selection
Policy - How a chosen version relates to the lock.
- Settle
Error - Constraints that cannot both hold on one ref.
Functions§
- allows
- Whether
versionmeets every semver range inconstraintsand is not inexcluded.Constraint::Latestallows any version; aConstraint::RefPinmust have been settled already, so it is not read here. - choose
- The whole decision for one package, from every constraint on it and the tags the repository
has:
settlefirst (a pin ends it), then the lock if it is kept, thenselectamong the tags that are versions. A tag that is not one (nightly) is ignored, as the binary ignores it when it lists a repository. - keeps_
lock - Whether the lock is kept:
policyprefers it (aConstraint::Latestasks for the newest, so beside onePreferLockThenLatestprefers nothing) and the locked version is allowed. It does not ask whether the tag is still in the repository, so the answer needs no tag list and a tag deleted upstream keeps the lock.--frozenis the binary’s own rule and asksallows. - parse_
constraint - Parse a dependency entry’s
version. - parse_
tag - Parse a tag name as a semver version tag: one leading
vis dropped, then the rest must be strict semver.v1.0.0and1.0.0are versions;latestandnightly-2024are not. - parse_
version - Parse strict semver (no leading
v). - require_
tag parse_tag, where a tag that is not a version is the caller’s mistake.- satisfies
- Whether
versionmeets a dependencyversion. AConstraint::RefPinnames no version, so nothing meets it. - satisfies_
requirement - Whether
versionmeets a package’srequires-mars/requires-meridian(a bare0.20means>=0.20.0). An error is a requirement that is not one. - select
- Choose one of
availablethatallowsand return its index. The newest allowed wins whatever the order ofavailable; of equal versions the later one does. Alockedthat is amongavailableand thatkeeps_lockwins instead.Ok(None)is a repository with no version tags: the caller takes its default branch. - settle
- Settle every
(requester, constraint)on a package: each must hold on the ref it ends at, whether or not it selects anything. AConstraint::RefPinholds only at that ref, aConstraint::Semvernever at a pin, andConstraint::Latestanywhere. So the package ends at the one pin if there is one (returned;Nonemeansselectchooses among the tags), and two pins, or a pin beside a range, refuse. ALatestbeside a pin holds but drifts: it asked for the newest and gets a fixed ref.