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

Function assert_raw_history

atomic-cli/src/commands/git/stream.rs:1335–1397  ·  view source on GitHub ↗
(git: &GitRepository, tips: &[Oid])

Source from the content-addressed store, hash-verified

1333 }
1334
1335 fn assert_raw_history(git: &GitRepository, tips: &[Oid]) {
1336 let policy = conversion_policy(git).unwrap();
1337 for tip in tips {
1338 let mut state = None;
1339 for (batch, rolling) in [(1, false), (100, false), (100, true)] {
1340 let output = tempfile::tempdir().unwrap();
1341 let mut repo = Repository::init(output.path()).unwrap();
1342 let importer = ParallelImporter::new(
1343 git,
1344 ParallelImportOptions {
1345 graph_only: true,
1346 target_view: repo.current_view().into(),
1347 ..Default::default()
1348 },
1349 );
1350 let limits = GitStreamLimits::new(batch, 32 * 1024 * 1024).unwrap();
1351 let outcome = if rolling {
1352 let (_, _, ordered) = importer.graph_stream_inputs(*tip).unwrap();
1353 importer.import_graph_stream_rolling(&mut repo, *tip, limits, &ordered)
1354 } else {
1355 importer.import_graph_stream(&mut repo, *tip, limits)
1356 }
1357 .unwrap_or_else(|error| {
1358 panic!("tip {tip}, batch {batch}, rolling {rolling}: {error}")
1359 });
1360 for entry in repo.effective_history(None).unwrap() {
1361 assert!(repo.load_change(&entry.hash).unwrap().file_ops().is_empty());
1362 }
1363 if let Some(state) = state {
1364 assert_eq!(outcome.state, state, "batch size changed identity at {tip}");
1365 } else {
1366 state = Some(outcome.state);
1367 }
1368 let source = git.find_commit(*tip).unwrap().tree_id();
1369 let projection = repo.project_tree(repo.current_view(), &policy);
1370 if policy.platform.lossless_unix_paths {
1371 let actual = projection.unwrap();
1372 assert_eq!(
1373 actual.git.root.as_bytes(),
1374 source.as_bytes(),
1375 "raw Git tree bytes must survive at {tip}"
1376 );
1377 } else {
1378 // The import itself verifies the staged graph against the
1379 // source tree before promotion. The separate graph-to-Git
1380 // projection API deliberately refuses this host policy.
1381 assert!(matches!(
1382 projection,
1383 Err(atomic_repository::repository::ProjectTreeError::UnsupportedPlatformPath)
1384 ));
1385 }
1386 // Exercise the Windows policy contract on Unix too, without
1387 // claiming the host can project arbitrary Git paths natively.
1388 let mut unsupported_policy = policy.clone();
1389 unsupported_policy.platform.lossless_unix_paths = false;
1390 assert!(matches!(
1391 repo.project_tree(repo.current_view(), &unsupported_policy),
1392 Err(atomic_repository::repository::ProjectTreeError::UnsupportedPlatformPath)

Calls 11

conversion_policyFunction · 0.85
graph_stream_inputsMethod · 0.80
import_graph_streamMethod · 0.80
effective_historyMethod · 0.80
project_treeMethod · 0.80
initFunction · 0.50
unwrapMethod · 0.45
pathMethod · 0.45
current_viewMethod · 0.45
cloneMethod · 0.45