diff rust/hg-core/src/repo.rs @ 47989:4d2a5ca060e3

rust: Add a Filelog struct that wraps Revlog Some filelog-specific logic is moved from code `rhg cat` into this struct where it can better be reused. Additionally, a missing end delimiter for metadata causes an error to be returned instead of being silently ignored. Differential Revision: https://phab.mercurial-scm.org/D11408
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 13 Sep 2021 15:42:39 +0200
parents cfb6e6699b25
children 001d747c2baf
line wrap: on
line diff
--- a/rust/hg-core/src/repo.rs	Mon Sep 13 13:45:10 2021 +0200
+++ b/rust/hg-core/src/repo.rs	Mon Sep 13 15:42:39 2021 +0200
@@ -7,8 +7,10 @@
 use crate::errors::HgResultExt;
 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};
@@ -346,6 +348,10 @@
             Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?;
         manifest.get_node(manifest_node.into())
     }
+
+    pub fn filelog(&self, path: &HgPath) -> Result<Filelog, RevlogError> {
+        Filelog::open(self, path)
+    }
 }
 
 /// Lazily-initialized component of `Repo` with interior mutability