Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/repo.rs @ 47992:796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
When `rhg status` cannot determine whether a file is clean based on mtime and
size alone, it needs to compare its contents with those found in the parent
commit. Previously, rhg would find the (same) manifest of that commit again
for every such file. This is lifted out of the loop and reused.
Differential Revision: https://phab.mercurial-scm.org/D11411
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 13 Sep 2021 18:09:10 +0200 |
parents | 001d747c2baf |
children | 87e3f878e65f |
line wrap: on
line diff
--- a/rust/hg-core/src/repo.rs Mon Sep 13 18:02:45 2021 +0200 +++ b/rust/hg-core/src/repo.rs Mon Sep 13 18:09:10 2021 +0200 @@ -5,15 +5,15 @@ use crate::dirstate_tree::owning::OwningDirstateMap; use crate::errors::HgError; use crate::errors::HgResultExt; +use crate::exit_codes; use crate::manifest::{Manifest, Manifestlog}; -use crate::requirements; use crate::revlog::filelog::Filelog; use crate::revlog::revlog::RevlogError; use crate::utils::files::get_path_from_bytes; use crate::utils::hg_path::HgPath; use crate::utils::SliceExt; use crate::vfs::{is_dir, is_file, Vfs}; -use crate::{exit_codes, Node}; +use crate::{requirements, NodePrefix}; use crate::{DirstateError, Revision}; use std::cell::{Cell, Ref, RefCell, RefMut}; use std::collections::HashSet; @@ -336,17 +336,27 @@ self.manifestlog.get_mut_or_init(self) } + /// Returns the manifest of the given node ID + pub fn manifest_for_node( + &self, + node: impl Into<NodePrefix>, + ) -> Result<Manifest, RevlogError> { + self.manifestlog()?.get_node( + self.changelog()? + .get_node(node.into())? + .manifest_node()? + .into(), + ) + } + /// Returns the manifest of the given revision - pub fn manifest( + pub fn manifest_for_rev( &self, revision: Revision, ) -> Result<Manifest, RevlogError> { - let changelog = self.changelog()?; - let manifest = self.manifestlog()?; - let changelog_entry = changelog.get_rev(revision)?; - let manifest_node = - Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?; - manifest.get_node(manifest_node.into()) + self.manifestlog()?.get_node( + self.changelog()?.get_rev(revision)?.manifest_node()?.into(), + ) } pub fn filelog(&self, path: &HgPath) -> Result<Filelog, HgError> {