pub struct Worktrees { /* private fields */ }Expand description
The city’s trees.
Implementations§
Source§impl Worktrees
impl Worktrees
Sourcepub fn claim_at(
&self,
name: &WorktreeName,
point: &GitOid,
) -> Result<WorktreeLease, StorageError>
pub fn claim_at( &self, name: &WorktreeName, point: &GitOid, ) -> Result<WorktreeLease, StorageError>
Opens a new tree whose branch starts at point. The trunk and the
city working tree do not move: another run may be writing, and
the trunk is where its work lands.
§Errors
WorktreeBusy when the name holds a live tree or a branch, or the
city working tree is over the ceiling; Worktree when point is
not a commit of the city.
Sourcepub fn restore_file(
&self,
lease: &WorktreeLease,
point: &GitOid,
path: &Path,
) -> Result<FileRestored, StorageError>
pub fn restore_file( &self, lease: &WorktreeLease, point: &GitOid, path: &Path, ) -> Result<FileRestored, StorageError>
Takes path back from point into the tree lease holds: the
point’s bytes when it holds the file, and no file when it does
not. No other tree and not the trunk are touched. Returns the
file_restored record of this step for the caller to append.
§Errors
Refuses a path that is empty, absolute, climbs, or names the reserved subtree; a point that is not a commit of the city; and a path the point holds as something other than a file.
Source§impl Worktrees
impl Worktrees
Sourcepub fn sweep_abandoned(
city_root: &Path,
held: &[WorktreeName],
) -> Result<Vec<WorktreeName>, StorageError>
pub fn sweep_abandoned( city_root: &Path, held: &[WorktreeName], ) -> Result<Vec<WorktreeName>, StorageError>
Takes back every tree under <city>/.sprawling/worktrees/ that
no name in held holds, and answers the names taken, sorted.
§Errors
Propagates a repository that cannot be read, a registration git will not prune, a branch it will not delete, and a directory that cannot be removed.
Source§impl Worktrees
impl Worktrees
Sourcepub fn lift_abandoned_leases(
city_root: &Path,
_writer: &JsonlLedger,
) -> Result<(), StorageError>
pub fn lift_abandoned_leases( city_root: &Path, _writer: &JsonlLedger, ) -> Result<(), StorageError>
Lifts every lease a previous writer of this city left behind.
A city has one writer, and _writer is the proof that the caller
is it: while it is held, no lock can belong to a run that is
still alive, so every lock is one a dead process never gave
back. A city with no repository has no trees to free.
§Errors
Propagates a repository that cannot list, read or unlock its trees.
Source§impl Worktrees
impl Worktrees
Sourcepub fn stock(&self) -> Result<FileWork, StorageError>
pub fn stock(&self) -> Result<FileWork, StorageError>
Keeps one tree checked out at the trunk for the next placement to take over, and answers what that cost the filesystem: a whole checkout when there is no stock, and the files the trunk changed since the stock was last brought to it otherwise. A stock that another call is checking out is left to it, at no cost.
Call it where nobody waits on it: its cost is the placement’s.
§Errors
Refuses a city whose working tree exceeds the ceiling and a repository with no commit, and propagates whatever git or the disk refuses while the stock is checked out.
Source§impl Worktrees
impl Worktrees
Sourcepub fn open(city_root: &Path) -> Result<Worktrees, StorageError>
pub fn open(city_root: &Path) -> Result<Worktrees, StorageError>
Opens the city’s repository as the source every tree branches from.
§Errors
Refuses a city with no repository. Initialising one here would make two modules able to create the city’s history.
Sourcepub fn claim(
&self,
name: &WorktreeName,
scopes: &[String],
) -> Result<WorktreeLease, StorageError>
pub fn claim( &self, name: &WorktreeName, scopes: &[String], ) -> Result<WorktreeLease, StorageError>
Lends one node its tree: the one it was given before when that tree is still on disk, reset to the node’s branch, and a new one otherwise.
§Errors
Refuses a tree somebody holds, a city whose working tree exceeds the ceiling, and a repository with no commit to branch from.
Sourcepub fn plan_merge(
&self,
name: &WorktreeName,
) -> Result<PlannedMerge<'_>, StorageError>
pub fn plan_merge( &self, name: &WorktreeName, ) -> Result<PlannedMerge<'_>, StorageError>
Decides a merge without making it.
Fast-forward only. A node whose trunk moved underneath it does not get its work merged on top of somebody else’s by a machine: it rebuilds on the trunk as it now stands and is verified again. This is the same stance the draft desk takes about a room that moved, and for the same reason - the party who knows whether the work is still right is the one who did it.
Every refusal happens here, before anything moves, and the commit the trunk will point at is already known - so a caller can write the line that announces the merge before the merge exists, and still never announce one that was going to be refused.
§Errors
Refuses an unknown branch, a repository with no commit, and a merge that is not a fast-forward.
Sourcepub fn release(&self, lease: WorktreeLease) -> Result<(), StorageError>
pub fn release(&self, lease: WorktreeLease) -> Result<(), StorageError>
Gives a tree back and keeps its files for the node’s next run: the lock is the lease, so lifting it is the whole release.
§Errors
Propagates a repository that cannot find or unlock the tree.
Sourcepub fn live(&self) -> Result<Vec<WorktreeName>, StorageError>
pub fn live(&self) -> Result<Vec<WorktreeName>, StorageError>
Every node’s tree the repository knows about, sorted. The stock is no node’s tree, and is not among them.
§Errors
Propagates a repository that cannot list its worktrees.