MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / insert_changes

Method insert_changes

libatomic/src/daemon/services.rs:2259–2701  ·  view source on GitHub ↗
(
        &self,
        request: Request<InsertChangesRequest>,
    )

Source from the content-addressed store, hash-verified

2257 }
2258
2259 async fn insert_changes(
2260 &self,
2261 request: Request<InsertChangesRequest>,
2262 ) -> Result<Response<InsertChangesResponse>, Status> {
2263 let request = request.into_inner();
2264 let handle = self
2265 .state
2266 .resolve(request.repository.as_ref().unwrap_or(&default_ref()))?;
2267 self.state.log_rpc("InsertChanges", Some(&handle));
2268 let gate_handle = handle.clone();
2269 let _gate = gate_handle.exclusive().await;
2270 let result =
2271 tokio::task::spawn_blocking(move || -> Result<InsertChangesResponse, Status> {
2272 // A stale insertion must not reconcile or capture the working
2273 // copy before its refusal. The second check below still fences
2274 // the mutation after workspace entry; dry runs remain reads.
2275 if !request.dry_run.unwrap_or(false) {
2276 if let Some(expected) = &request.expected_snapshot {
2277 let repo = handle.repository_readonly()?;
2278 let working_copy =
2279 repo.require_working_copy_id().map_err(repository_error)?;
2280 let target = match &request.target_view {
2281 Some(target) => target.clone(),
2282 None => repo
2283 .desired_view_name(working_copy)
2284 .map_err(repository_error)?,
2285 };
2286 check_view_fence(&repo, &target, expected)?;
2287 }
2288 }
2289 let (repo, workspace) =
2290 handle.workspace_repository(if request.dry_run.unwrap_or(false) {
2291 atomic_repository::WorkspaceTxnMode::Observe
2292 } else {
2293 atomic_repository::WorkspaceTxnMode::Reconcile
2294 })?;
2295 let working_copy = workspace.working_copy();
2296 // The target defaults to the repository's current view (the
2297 // wire's target_view is a display hint that must agree).
2298 let target = request
2299 .target_view
2300 .clone()
2301 .unwrap_or_else(|| workspace.view().name.clone());
2302 // The fence: the target view must be at the state the
2303 // caller last saw — two concurrent inserters (two
2304 // expeditions merging into the same view) can't both
2305 // land on a stale read silently. Dry runs read only and
2306 // don't fence.
2307 if !request.dry_run.unwrap_or(false) {
2308 if let Some(expected) = &request.expected_snapshot {
2309 check_view_fence(&repo, &target, expected)?;
2310 }
2311 }
2312 let dry_run = request.dry_run.unwrap_or(false);
2313 let apply_dependencies = request.apply_dependencies.unwrap_or(true);
2314 // Insert may refresh the current working copy below. Refuse
2315 // before publishing any membership, rather than overwriting
2316 // edits (including untracked files) during materialization.

Calls 15

default_refFunction · 0.85
check_view_fenceFunction · 0.85
domain_statusFunction · 0.85
wire_hashFunction · 0.85
single_insertFunction · 0.85
resolve_change_referenceFunction · 0.85
change_infoFunction · 0.85
bare_change_infoFunction · 0.85
as_refMethod · 0.80
log_rpcMethod · 0.80
exclusiveMethod · 0.80