# HG changeset patch # User Arseniy Alekseyev # Date 1679684463 0 # Node ID eb07591825faa34140490121360bbb3d1088a4f4 # Parent 3dbc7b1ecaba409c5ae417742184920f7f5fff09 rhg: show a bug in the rust implementation of path_encode introduced recently In commit 96d31efd21f7 I did a refactoring where I dropped a chunk of code by accident, thus introducing a bug. This commit adds a test demonstrating that bug. diff -r 3dbc7b1ecaba -r eb07591825fa rust/hg-core/src/revlog/path_encode.rs --- a/rust/hg-core/src/revlog/path_encode.rs Fri Mar 24 02:22:12 2023 -0400 +++ b/rust/hg-core/src/revlog/path_encode.rs Fri Mar 24 19:01:03 2023 +0000 @@ -610,6 +610,18 @@ use crate::utils::hg_path::HgPathBuf; #[test] + fn test_dirname_ends_with_underscore() { + let input = b"data/dir1234.foo/ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ.i"; + // TODO: BUG: trailing dot should become an underscore + let expected = b"dh/dir1234./abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij.if2e9ce59e095eff5f8f334dc809e65606a0aa50b.i"; + let res = path_encode(input); + assert_eq!( + HgPathBuf::from_bytes(&res), + HgPathBuf::from_bytes(expected) + ); + } + + #[test] fn test_long_filename_at_root() { let input = b"data/ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ.i"; let expected = b"dh/abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij.i708243a2237a7afae259ea3545a72a2ef11c247b.i";