Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/revlog/mod.rs @ 50983:eccf7dc7c91e stable
revlog: make the rust test for node hex prefix resolution exercise the nodemap
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Thu, 14 Sep 2023 10:52:09 +0100 |
parents | 363620b934aa |
children | 12c308c55e53 |
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/mod.rs Wed Sep 13 18:28:51 2023 +0100 +++ b/rust/hg-core/src/revlog/mod.rs Thu Sep 14 10:52:09 2023 +0100 @@ -156,6 +156,16 @@ data_path: Option<&Path>, use_nodemap: bool, ) -> Result<Self, HgError> { + Self::open_gen(store_vfs, index_path, data_path, use_nodemap, None) + } + + fn open_gen( + store_vfs: &Vfs, + index_path: impl AsRef<Path>, + data_path: Option<&Path>, + use_nodemap: bool, + nodemap_for_test: Option<nodemap::NodeTree>, + ) -> Result<Self, HgError> { let index_path = index_path.as_ref(); let index = { match store_vfs.mmap_open_opt(&index_path)? { @@ -193,6 +203,8 @@ ) }; + let nodemap = nodemap_for_test.or(nodemap); + Ok(Revlog { index, data_bytes, @@ -790,7 +802,13 @@ .flatten() .collect_vec(); std::fs::write(temp.path().join("foo.i"), contents).unwrap(); - let revlog = Revlog::open(&vfs, "foo.i", None, false).unwrap(); + + let mut idx = nodemap::tests::TestNtIndex::new(); + idx.insert_node(0, node0).unwrap(); + idx.insert_node(1, node1).unwrap(); + + let revlog = + Revlog::open_gen(&vfs, "foo.i", None, true, Some(idx.nt)).unwrap(); // accessing the data shows the corruption revlog.get_entry(0).unwrap().data().unwrap_err();