Provision an agent's private working tree as a copy-on-write clone of this repository's working tree. Copies every tracked-or-untracked working file into `dest`, reflinking where the filesystem supports it (so unchanged blocks are shared on disk) and falling back to a plain copy otherwise. The `.atomic/` directory is **never** cloned — the sandbox shares the canonical graph via [`Repository::open
(
&self,
dest: P,
view: &str,
)
| 201 | /// commands run inside the sandbox resolve to this repository's canonical |
| 202 | /// graph and the given `view`. |
| 203 | pub fn provision_sandbox<P: AsRef<Path>>( |
| 204 | &self, |
| 205 | dest: P, |
| 206 | view: &str, |
| 207 | ) -> Result<usize, RepositoryError> { |
| 208 | let dest = dest.as_ref(); |
| 209 | let count = provision_working_tree(&self.root, dest)?; |
| 210 | |
| 211 | let pointer = SandboxPointer { |
| 212 | canonical: self.root.clone(), |
| 213 | view: view.to_string(), |
| 214 | }; |
| 215 | let bytes = serde_json::to_vec_pretty(&pointer) |
| 216 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 217 | std::fs::write(dest.join(SANDBOX_POINTER), bytes)?; |
| 218 | |
| 219 | Ok(count) |
| 220 | } |
| 221 | |
| 222 | /// Materialize a view's visible file content into `dir` (created if needed). |
| 223 | /// |