Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/revlog/mod.rs @ 52167:7be39c5110c9
hg-core: add a complete VFS
This will be used from Python in a later change.
More changes are needed in hg-core and rhg to properly clean up the APIs
of the old VFS implementation but it can be done when the dust settles
and we start adding more functionality to the pure Rust VFS.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 29 Jul 2024 20:47:43 +0200 |
parents | 84b5802ba7d3 |
children | 1da6995835b4 |
comparison
equal
deleted
inserted
replaced
52166:1a8466fd904a | 52167:7be39c5110c9 |
---|---|
717 use itertools::Itertools; | 717 use itertools::Itertools; |
718 | 718 |
719 #[test] | 719 #[test] |
720 fn test_empty() { | 720 fn test_empty() { |
721 let temp = tempfile::tempdir().unwrap(); | 721 let temp = tempfile::tempdir().unwrap(); |
722 let vfs = VfsImpl { | 722 let vfs = VfsImpl::new(temp.path().to_owned(), false); |
723 base: temp.path().to_owned(), | |
724 }; | |
725 std::fs::write(temp.path().join("foo.i"), b"").unwrap(); | 723 std::fs::write(temp.path().join("foo.i"), b"").unwrap(); |
726 std::fs::write(temp.path().join("foo.d"), b"").unwrap(); | 724 std::fs::write(temp.path().join("foo.d"), b"").unwrap(); |
727 let revlog = | 725 let revlog = |
728 Revlog::open(&vfs, "foo.i", None, RevlogOpenOptions::default()) | 726 Revlog::open(&vfs, "foo.i", None, RevlogOpenOptions::default()) |
729 .unwrap(); | 727 .unwrap(); |
741 } | 739 } |
742 | 740 |
743 #[test] | 741 #[test] |
744 fn test_inline() { | 742 fn test_inline() { |
745 let temp = tempfile::tempdir().unwrap(); | 743 let temp = tempfile::tempdir().unwrap(); |
746 let vfs = VfsImpl { | 744 let vfs = VfsImpl::new(temp.path().to_owned(), false); |
747 base: temp.path().to_owned(), | |
748 }; | |
749 let node0 = Node::from_hex("2ed2a3912a0b24502043eae84ee4b279c18b90dd") | 745 let node0 = Node::from_hex("2ed2a3912a0b24502043eae84ee4b279c18b90dd") |
750 .unwrap(); | 746 .unwrap(); |
751 let node1 = Node::from_hex("b004912a8510032a0350a74daa2803dadfb00e12") | 747 let node1 = Node::from_hex("b004912a8510032a0350a74daa2803dadfb00e12") |
752 .unwrap(); | 748 .unwrap(); |
753 let node2 = Node::from_hex("dd6ad206e907be60927b5a3117b97dffb2590582") | 749 let node2 = Node::from_hex("dd6ad206e907be60927b5a3117b97dffb2590582") |
810 } | 806 } |
811 | 807 |
812 #[test] | 808 #[test] |
813 fn test_nodemap() { | 809 fn test_nodemap() { |
814 let temp = tempfile::tempdir().unwrap(); | 810 let temp = tempfile::tempdir().unwrap(); |
815 let vfs = VfsImpl { | 811 let vfs = VfsImpl::new(temp.path().to_owned(), false); |
816 base: temp.path().to_owned(), | |
817 }; | |
818 | 812 |
819 // building a revlog with a forced Node starting with zeros | 813 // building a revlog with a forced Node starting with zeros |
820 // This is a corruption, but it does not preclude using the nodemap | 814 // This is a corruption, but it does not preclude using the nodemap |
821 // if we don't try and access the data | 815 // if we don't try and access the data |
822 let node0 = Node::from_hex("00d2a3912a0b24502043eae84ee4b279c18b90dd") | 816 let node0 = Node::from_hex("00d2a3912a0b24502043eae84ee4b279c18b90dd") |