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

Function insert_would_discard_work

libatomic/src/daemon/services.rs:1281–1311  ·  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

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