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

Function insert_would_discard_work

libatomic/src/daemon/services.rs:1282–1312  ·  view source on GitHub ↗

A conflict is recorded state too: unchanged canonical markers may be resolved by an insertion. Everything else keeps the dirty-worktree guard.

(
    repo: &Repository,
    view: &str,
    status: &atomic_repository::RepositoryStatus,
)

Source from the content-addressed store, hash-verified

1280/// A conflict is recorded state too: unchanged canonical markers may be
1281/// resolved by an insertion. Everything else keeps the dirty-worktree guard.
1282fn insert_would_discard_work(
1283 repo: &Repository,
1284 view: &str,
1285 status: &atomic_repository::RepositoryStatus,
1286) -> Result<bool, Status> {
1287 use atomic_repository::status::FileStatus;
1288 let mut conflicts = std::collections::HashSet::new();
1289 for entry in status.entries() {
1290 match entry.status() {
1291 FileStatus::Clean => {}
1292 FileStatus::Conflicted => {
1293 conflicts.insert(entry.path().to_path_buf());
1294 }
1295 _ => return Ok(true),
1296 }
1297 }
1298 if conflicts.is_empty() {
1299 return Ok(false);
1300 }
1301 let mut changed = false;
1302 repo.materialize_view_entries::<Status>(view, |entry| {
1303 if conflicts.remove(std::path::Path::new(&entry.path)) {
1304 changed |= !matches_canonical_entry(repo.root(), &entry)?;
1305 }
1306 Ok(())
1307 })
1308 .map_err(repository_error)??;
1309 // A reported conflict absent from the canonical render is not safe to
1310 // discard. Neither TREE nor saved materialization history proves ownership.
1311 Ok(changed || !conflicts.is_empty())
1312}
1313
1314fn matches_canonical_entry(
1315 root: &std::path::Path,

Callers 1

insert_changesMethod · 0.85

Calls 8

matches_canonical_entryFunction · 0.85
entriesMethod · 0.80
removeMethod · 0.65
statusMethod · 0.45
insertMethod · 0.45
pathMethod · 0.45
is_emptyMethod · 0.45
rootMethod · 0.45

Tested by

no test coverage detected