Skip to main content

BranchManager

Struct BranchManager 

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

Orchestrates branch-instance lifecycle against one store.

Implementations§

Source§

impl BranchManager

Source

pub fn open(store: MetadataStore) -> Result<Self>

Source

pub fn graph_problems(&self) -> &[GraphProblem]

Ways the resource graph is incomplete. An empty slice means it resolves.

Source

pub fn require_resolvable_graph(&self) -> Result<()>

The gate for commands that act on the graph — spawn, run, action, checkpoint, undo, remove. Commands that build the graph (tracker create, tracker track, resource add) must not call this: they are how an incomplete graph gets completed.

Source

pub fn store(&self) -> &MetadataStore

Source

pub fn tracker_definitions(&self) -> &[TrackerDefinition]

Source

pub fn gitignore_warnings(&self) -> Vec<String>

The tracker-path invariant, checked loudly: non-source tracker paths must be gitignored unless deliberately dual-tracked with source.

Source

pub fn spawn(&self, name: &str, from: Option<&str>) -> Result<SpawnOutcome>

Source

pub fn run_action(&self, instance: &str, spec: &str) -> Result<ActionOutcome>

Run <resource>.<action> for an instance.

Source

pub fn run_command( &self, instance: &str, command_line: &[String], ) -> Result<(i32, Utf8PathBuf)>

Run an arbitrary command inside the instance with the full export environment loaded. Returns the exit code.

Source

pub fn assemble_env( &self, branch: &BranchInstance, ) -> Result<Vec<(String, String)>>

The layered environment newgit run and actions see. Later layers win: resource exports in dependency order → port env vars → newgit context vars. Trackers own content; command environment wiring lives outside the tracker primitive.

Source

pub fn add_resource( &self, name: &str, template_name: &str, ) -> Result<AddResourceOutcome>

Source

pub fn resource_definitions(&self) -> &[ResourceDefinition]

Source

pub fn capture_tracker( &self, instance: &str, tracker: &str, ) -> Result<CaptureReport>

Source

pub fn seed_tracker_from_store(&self, tracker: &str) -> Result<SeedReport>

Seed a lane from the store repo’s working tree and make it the lane head.

A lane starts empty and Self::capture_tracker reads from an instance workspace, so the first instance of an env-carrying tracker is guaranteed to come up without its files. In a project adopting newgit that content already exists in the store repo at the same relative paths, so read it from there rather than round-tripping it through an instance. Seeding sets the lane head directly: there is no binding record to promote from, and the point is that the next spawn works.

Source

pub fn checkout_tracker( &self, instance: &str, tracker: &str, rev: Option<&str>, ) -> Result<RestoreReport>

Source

pub fn pull_tracker( &self, instance: &str, tracker: &str, ) -> Result<TrackerBindOutcome>

Pull a tracker’s lane head into an existing instance.

Source

pub fn merge_tracker( &self, instance: &str, tracker: &str, ) -> Result<MergeTrackerOutcome>

Promote this branch instance’s bound tracker revision to the lane head.

Source

pub fn create_tracker( &self, name: &str, audience: &str, storage: Storage, merge_with_source: bool, ) -> Result<AddTrackerOutcome>

Source

pub fn track_paths( &self, tracker: &str, paths: &[Utf8PathBuf], ) -> Result<TrackPathsOutcome>

Source

pub fn statuses(&self) -> Result<Vec<InstanceReport>>

Source

pub fn remove( &self, name: &str, cwd: &Utf8Path, checkpoints: ArchivedCheckpoints, ) -> Result<RemoveOutcome>

Deletes the workspace (plain rm -rf; clones have no registration) and archives the binding record. The source branch in the store is kept — removal disposes of the workspace, not the history.

Resource cleanup hooks run first, dependents before dependencies and while the workspace still exists. Without that, a resource newgit does not own — a cloud preview, a database — would outlive every trace of the instance that asked for it. Deliberately not gated on Self::require_resolvable_graph: teardown must stay reachable from a broken graph, and cleanup hooks run for every bound resource regardless of how they are ordered relative to each other.

Checkpoints outlive removal by default — they pin the lane revs their undo would need, and the instance may be re-created. checkpoints = Purge says that undo will never be wanted, and drops them so the next cleanup can reclaim what they held.

Source

pub fn cleanup( &self, dry_run: bool, archived: ArchivedCheckpoints, ) -> Result<CleanupOutcome>

Garbage collection across everything: finish instances whose workspace is gone, delete unclaimed workspaces and dead process state, and prune lane revs nothing references.

remove targets one instance; this is the sweep. It never deletes a checkpoint record, and never a lane rev a checkpoint still points at — unless archived = Purge, which discards the checkpoint logs of instances whose binding record is already gone, and so releases the revs those logs were the only claim on.

Source

pub fn export( &self, instance: &str, destination: &Utf8Path, filter: &ExportFilter, ) -> Result<ExportOutcome>

Write a branch instance’s content out as an ordinary Git repository.

Tracker audience is the default filter and it fails closed: only public lanes ship unless --include names a path. This is path-level filtering and nothing more — no hunk privacy, no concealment claim.

Source

pub fn checkpoint( &self, instance: &str, message: Option<&str>, ) -> Result<CheckpointOutcome>

Record one coherent snapshot across source, trackers, and resources.

Source

pub fn list_checkpoints(&self, instance: &str) -> Result<Vec<CheckpointRecord>>

Source

pub fn undo(&self, instance: &str, to: Option<&str>) -> Result<UndoOutcome>

Restore the branch instance to a checkpoint — the latest, unless to names one. The current state is checkpointed first, so undo is always undoable and running it twice is redo.

Trait Implementations§

Source§

impl Debug for BranchManager

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> Same for T

Source§

type Output = T

Should always be Self
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.