1.6 KiB
markup, title, description, import
| markup | title | description | import | ||||
|---|---|---|---|---|---|---|---|
| occlusion | sandbox CoW — write stays upper until commit | Readable trial: seed on disk, mutate in session, host tree unchanged, then commit / discard. Prefer link index over json.get. |
|
main
Prepare a tiny workspace under this test directory (reset leftovers from prior runs).
had = fs.exists path="_sbx_cow"
had
fs.remove path="_sbx_cow"
_ = 0
fs.make_dir path="_sbx_cow" fs.write_text path="_sbx_cow/seed.txt" text=seed-lower
sb = sandbox.open root="_sbx_cow" id = id)
Session edits (upper / whiteout only).
sandbox.write id=
idpath="seed.txt" text=seed-upper sandbox.write id=idpath="new.txt" text=brand-new sandbox.remove id=idpath="seed.txt"
pending = sandbox.diff id=id
n = len value=pending
print text=
n
Host tree must still show the lower seed; new.txt must not exist yet.
lower = fs.read_text path="_sbx_cow/seed.txt"
print text=
lowerex_new = fs.exists path="_sbx_cow/new.txt" print text=ex_new
Commit applies upper + whiteout.
sandbox.commit id=
id
after = fs.read_text path="_sbx_cow/new.txt"
print text=
afterseed_gone = fs.exists path="_sbx_cow/seed.txt" print text=seed_gone
Discard must not touch the host.
sb2 = sandbox.open root="_sbx_cow" id2 = id)
sandbox.write id=
id2path="new.txt" text=should-discard sandbox.discard id=id2
kept = fs.read_text path="_sbx_cow/new.txt"
print text=
kept