pub struct JjSandbox { /* private fields */ }Expand description
A throwaway jj repository (git-backed) with a repo-scoped identity.
Implementations§
Source§impl JjSandbox
impl JjSandbox
Sourcepub fn init(tag: &str) -> Self
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.
Sourcepub fn jj_capture(&self, args: &[&str]) -> String
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.
Sourcepub fn op_head(&self) -> String
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.
Sourcepub fn at_commit(&self) -> String
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.
Sourcepub fn write(&self, path: &str, content: &str)
pub fn write(&self, path: &str, content: &str)
Write content to the workspace-relative path (creating parents).
Sourcepub fn describe(&self, message: &str)
pub fn describe(&self, message: &str)
Describe the working-copy change (jj describe -m <message>).
Sourcepub fn new_change(&self, message: &str)
pub fn new_change(&self, message: &str)
Start a new change on top (jj new -m <message>).