~/bend-docscommunity

src/ledger/upgrade.bend checks

raw source on the hub · import 0x886223f5c47e4983fe57d887c034bc7f/src/ledger/upgrade.bend as Upgrade

ledger/upgrade: what ez lock --upgrade may do to one dependency, before it talks to a remote. The ledger pins exact commits. A tag is the only floating name a person wrote down, so that is what gets re-resolved. A pin with no tag fast-forwards to the default branch tip when the commit is an ancestor of it, and stays a commit pin. A hub package is the hash itself. vend says the tree under .ez/lib/<hash> is committed, so a move lays the new tree there; the allowlist that names it is ledger/ignore.bend's, derived from the ledger the move writes. A move also rewrites an import 0x<hash>/ line that names the old hash.

2 imports
import Base
import ./manifest.bend as M

Types

type Aim source · line 14 · raw

Data

what an upgrade will ask the remote, once the ledger has been read

type Verdict source · line 20 · raw

Data

what that answer means for the pin

type Swap source · line 28 · raw

Data

one hash that moved, and the hash that replaces it: an import line to rewrite, or a committed tree to remove

Definitions

def chosen.go source · line 32 · raw

@all:Bool -> @+only:String -> @+name:String -> Bool

an empty --package is every dependency; a name is that one

def chosen source · line 40 · raw

@+only:String -> @+name:String -> Bool

an empty --package is every dependency; a name is that one

def known.step source · line 44 · raw

@hit:Bool -> @rest:(@_:Unit -> Bool) -> Bool

the rest of the scan only when this one was not it

def known.in source · line 52 · raw

@ds:List<&2, 0x886223f5c47e4983fe57d887c034bc7f/src/ledger/manifest.Dep> -> @+name:String -> Bool

whether the ledger names this dependency

def known.go source · line 60 · raw

@all:Bool -> @ds:List<&2, 0x886223f5c47e4983fe57d887c034bc7f/src/ledger/manifest.Dep> -> @+name:String -> Bool

--package with no such dependency is a mistake, and no filter is not

def known source · line 68 · raw

@+only:String -> @ds:List<&2, 0x886223f5c47e4983fe57d887c034bc7f/src/ledger/manifest.Dep> -> Bool

whether the ledger names the dependency --package asked for

def aim.tag source · line 72 · raw

@bare:Bool -> @+tag:String -> Aim

a selected git pin with no tag follows the default branch

def aim.src source · line 80 · raw

@source:0x886223f5c47e4983fe57d887c034bc7f/src/ledger/manifest.Source -> Aim

a selected hub pin has nothing to follow

def aim source · line 89 · raw

@sel:Bool -> @source:0x886223f5c47e4983fe57d887c034bc7f/src/ledger/manifest.Source -> Aim

what this dependency is asked. Unselected dependencies are left alone, including a git one, so --package does not move its neighbours.

def judge.same source · line 97 · raw

@agree:Bool -> Verdict

the same commit either still hashes to the pin or it does not

def judge.move source · line 105 · raw

@onward:Bool -> @+rev:String -> @+tag:String -> Verdict

a different commit is the upgrade only when it descends from the pin

def judge source · line 116 · raw

@same:Bool -> @onward:Bool -> @agree:Bool -> @rev:String -> @tag:String -> Verdict

same is the resolved commit against the pin. onward is that commit being a descendant of the pin. agree is the recomputed hash, NAR hash and root against what the ledger recorded, and it only matters when the commit did not move.

def agree.nar source · line 124 · raw

@same_nar:Bool -> @same_root:Bool -> Bool

the three fields a checkout can disagree on, each required

def agree.go source · line 132 · raw

@same_hash:Bool -> @same_nar:Bool -> @same_root:Bool -> Bool

whether a recomputed pin is the one the ledger already recorded

def agree source · line 140 · raw

@+oh:String -> @+nh:String -> @+onar:String -> @+nnar:String -> @+oroot:String -> @+nroot:String -> Bool

whether a recomputed pin is the one the ledger already recorded

def hub.bad source · line 145 · raw

@+why:String -> Bool

a hub miss is a different digest only when the body arrived and hashed wrong. A package the hub has never seen is not that.

def retarget.go source · line 150 · raw

@+name:String -> @+entry:String -> @source:0x886223f5c47e4983fe57d887c034bc7f/src/ledger/manifest.Source -> @+rev:String -> @+hash:String -> @+root:String -> @+nar:String -> 0x886223f5c47e4983fe57d887c034bc7f/src/ledger/manifest.Dep

the dependency with a new commit written in, and the name, the entry, the tag and the vendor bit left as they were

def retarget source · line 166 · raw

@dep:0x886223f5c47e4983fe57d887c034bc7f/src/ledger/manifest.Dep -> @+rev:String -> @+hash:String -> @+root:String -> @+nar:String -> 0x886223f5c47e4983fe57d887c034bc7f/src/ledger/manifest.Dep

the dependency with a new commit written in

def reimport.head source · line 174 · raw

@+hash:String -> String

what an import line that names a package starts with: import <hash>/. import 0x<hash>/<file>.bend as P is the only shape bend has, and the match is exact at column 0, so an indented import is not rewritten, and neither is a line that names the hash with no / after it.

def reimport.hit source · line 178 · raw

@empty:Bool -> @+line:String -> @+old:String -> Bool

an empty hash names no package, so it rewrites nothing

def reimport.line.go source · line 186 · raw

@hit:Bool -> @+line:String -> @+old:String -> @+new:String -> String

one line, with the branch already chosen. A match cannot scrutinise a call.

def reimport.line source · line 195 · raw

@+line:String -> @+old:String -> @+new:String -> String

one line, with its import hash rewritten when the line names the old one

def reimport.many.line source · line 199 · raw

@ss:List<&2, Swap> -> @+line:String -> String

one line through every replacement, in order

def reimport.many.lines source · line 207 · raw

@+ss:List<&2, Swap> -> @ls:List<&2, String> -> List<&2, String>

every line, in order

def reimport.many source · line 218 · raw

@+ss:List<&2, Swap> -> @+text:String -> String

a source file with every moved import hash replaced, in order. The text is cut at its newlines once and joined back with them, so a line that names no moved hash is left as it was, and so is the newline the file ends with, or its lack of one.