rust/hg-core/src/revlog/changelog.rs
changeset 51191 13f58ce70299
parent 50978 27e773aa607d
child 51369 508fd40dc86a
equal deleted inserted replaced
51190:6ec8387eb0be 51191:13f58ce70299
     2 use crate::revlog::Revision;
     2 use crate::revlog::Revision;
     3 use crate::revlog::{Node, NodePrefix};
     3 use crate::revlog::{Node, NodePrefix};
     4 use crate::revlog::{Revlog, RevlogEntry, RevlogError};
     4 use crate::revlog::{Revlog, RevlogEntry, RevlogError};
     5 use crate::utils::hg_path::HgPath;
     5 use crate::utils::hg_path::HgPath;
     6 use crate::vfs::Vfs;
     6 use crate::vfs::Vfs;
     7 use crate::{Graph, GraphError, UncheckedRevision};
     7 use crate::{Graph, GraphError, RevlogOpenOptions, UncheckedRevision};
     8 use itertools::Itertools;
     8 use itertools::Itertools;
     9 use std::ascii::escape_default;
     9 use std::ascii::escape_default;
    10 use std::borrow::Cow;
    10 use std::borrow::Cow;
    11 use std::fmt::{Debug, Formatter};
    11 use std::fmt::{Debug, Formatter};
    12 
    12 
    16     pub(crate) revlog: Revlog,
    16     pub(crate) revlog: Revlog,
    17 }
    17 }
    18 
    18 
    19 impl Changelog {
    19 impl Changelog {
    20     /// Open the `changelog` of a repository given by its root.
    20     /// Open the `changelog` of a repository given by its root.
    21     pub fn open(store_vfs: &Vfs, use_nodemap: bool) -> Result<Self, HgError> {
    21     pub fn open(
    22         let revlog =
    22         store_vfs: &Vfs,
    23             Revlog::open(store_vfs, "00changelog.i", None, use_nodemap)?;
    23         options: RevlogOpenOptions,
       
    24     ) -> Result<Self, HgError> {
       
    25         let revlog = Revlog::open(store_vfs, "00changelog.i", None, options)?;
    24         Ok(Self { revlog })
    26         Ok(Self { revlog })
    25     }
    27     }
    26 
    28 
    27     /// Return the `ChangelogRevisionData` for the given node ID.
    29     /// Return the `ChangelogRevisionData` for the given node ID.
    28     pub fn data_for_node(
    30     pub fn data_for_node(
   340     fn test_data_from_rev_null() -> Result<(), RevlogError> {
   342     fn test_data_from_rev_null() -> Result<(), RevlogError> {
   341         // an empty revlog will be enough for this case
   343         // an empty revlog will be enough for this case
   342         let temp = tempfile::tempdir().unwrap();
   344         let temp = tempfile::tempdir().unwrap();
   343         let vfs = Vfs { base: temp.path() };
   345         let vfs = Vfs { base: temp.path() };
   344         std::fs::write(temp.path().join("foo.i"), b"").unwrap();
   346         std::fs::write(temp.path().join("foo.i"), b"").unwrap();
   345         let revlog = Revlog::open(&vfs, "foo.i", None, false).unwrap();
   347         let revlog =
       
   348             Revlog::open(&vfs, "foo.i", None, RevlogOpenOptions::new())
       
   349                 .unwrap();
   346 
   350 
   347         let changelog = Changelog { revlog };
   351         let changelog = Changelog { revlog };
   348         assert_eq!(
   352         assert_eq!(
   349             changelog.data_for_rev(NULL_REVISION.into())?,
   353             changelog.data_for_rev(NULL_REVISION.into())?,
   350             ChangelogRevisionData::null()
   354             ChangelogRevisionData::null()