Skip to main content

JjSandbox

Struct JjSandbox 

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

A throwaway jj repository (git-backed) with a repo-scoped identity.

Implementations§

Source§

impl JjSandbox

Source

pub fn init(tag: &str) -> Self

Create and initialise the repository (jj git init + repo-scoped user.name/user.email).

The identity is supplied to every jj invocation as JJ_USER / JJ_EMAIL env (see command), so the working-copy commit that jj git init creates is authored deterministically — a later config set --repo user.* only affects future commits and so cannot fix the init commit on its own. The repo-scoped config is kept anyway as belt-and-braces for any tool path that reads config over the env.

Source

pub fn colocated(tag: &str) -> Self

Create a colocated jj/git workspace (jj git init --colocate) with deterministic jj and git identities.

The --colocate flag is deliberately explicit: jj’s default varies by version and can be changed by git.colocate config. The resulting workspace has both .jj and .git directories. jj receives the same deterministic JJ_USER / JJ_EMAIL environment as Self::init, its repo-scoped user.* config is set, and configure_identity configures the colocated git repository for direct git scenario steps.

Source

pub fn path(&self) -> &Path

The workspace root path.

Source

pub fn jj(&self, args: &[&str])

Run jj <args> in the workspace, panicking on failure.

Source

pub fn jj_capture(&self, args: &[&str]) -> String

Run jj <args> in the workspace and capture trimmed stdout (panics on failure) — for reading state in assertions (op ids, the @ commit id). Uses the same config-isolated environment as jj.

Source

pub fn op_head(&self) -> String

The current operation id (jj op log … --ignore-working-copy). Capture it before and after a series of read-only queries to assert none recorded a new operation (a mutating jj snapshot would advance it).

Read-only measurement: --ignore-working-copy is essential here — a plain jj op log would itself snapshot any pending working-tree edit and record an operation, so the measurement would perturb the very thing it is asserting about.

Source

pub fn at_commit(&self) -> String

The working-copy commit id of @ (jj log -r @ … --ignore-working-copy) — to assert a read-only query did not move @ (jj rewrites @ when it snapshots an unsnapshotted working-tree edit). Read-only for the same reason as op_head.

Source

pub fn write(&self, path: &str, content: &str)

Write content to the workspace-relative path (creating parents).

Source

pub fn describe(&self, message: &str)

Describe the working-copy change (jj describe -m <message>).

Source

pub fn new_change(&self, message: &str)

Start a new change on top (jj new -m <message>).

Source

pub fn bookmark(&self, name: &str)

Create a bookmark at @ (jj bookmark create <name> -r @).

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.