Skip to main content

Worktrees

Struct Worktrees 

Source
pub struct Worktrees { /* private fields */ }
Expand description

The city’s trees.

Implementations§

Source§

impl Worktrees

Source

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.

Source

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

Source

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

Source

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

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Worktrees

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.