Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/operations/cat.rs @ 47988:cfb6e6699b25
rust: Add Repo::manifest(revision)
This deduplicates some common code.
Differential Revision: https://phab.mercurial-scm.org/D11407
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 13 Sep 2021 13:45:10 +0200 |
parents | 21d25e9ee58e |
children | 4d2a5ca060e3 |
line wrap: on
line diff
--- a/rust/hg-core/src/operations/cat.rs Mon Sep 13 13:29:55 2021 +0200 +++ b/rust/hg-core/src/operations/cat.rs Mon Sep 13 13:45:10 2021 +0200 @@ -40,20 +40,16 @@ files: &'a [HgPathBuf], ) -> Result<CatOutput, RevlogError> { let rev = crate::revset::resolve_single(revset, repo)?; - let changelog = repo.changelog()?; - let manifest = repo.manifestlog()?; - let changelog_entry = changelog.get_rev(rev)?; - let node = *changelog + let manifest = repo.manifest(rev)?; + let node = *repo + .changelog()? .node_from_rev(rev) - .expect("should succeed when changelog.get_rev did"); - let manifest_node = - Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?; - let manifest_entry = manifest.get_node(manifest_node.into())?; + .expect("should succeed when repo.manifest did"); let mut bytes = vec![]; let mut matched = vec![false; files.len()]; let mut found_any = false; - for (manifest_file, node_bytes) in manifest_entry.files_with_nodes() { + for (manifest_file, node_bytes) in manifest.files_with_nodes() { for (cat_file, is_matched) in files.iter().zip(&mut matched) { if cat_file.as_bytes() == manifest_file.as_bytes() { *is_matched = true;