rhg: show a bug in the rust implementation of path_encode introduced recently stable
authorArseniy Alekseyev <aalekseyev@janestreet.com>
Fri, 24 Mar 2023 19:01:03 +0000
branchstable
changeset 50366 eb07591825fa
parent 50362 3dbc7b1ecaba
child 50367 0b84474ebd0a
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.
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";