revlog: fix the naming scheme use by split temporary file stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 21 Jul 2023 15:50:56 +0200
branchstable
changeset 50814 4a3a9d961561
parent 50813 4ee64ff1d49f
child 50815 d2f72f702de2
revlog: fix the naming scheme use by split temporary file The `-s` is now added on the first piece only and the `.i` is added to the index. This match the initially intended naming scheme.
mercurial/revlog.py
tests/test-transaction-rollback-on-revlog-split.t
--- a/mercurial/revlog.py	Fri Jul 21 15:15:43 2023 +0200
+++ b/mercurial/revlog.py	Fri Jul 21 15:50:56 2023 +0200
@@ -2131,11 +2131,14 @@
 
         The file will only exist if a splitting operation is in progress, but
         it is always expected at the same location."""
-        parts = os.path.split(self.radix)
+        parts = self.radix.split(b'/')
         if len(parts) > 1:
             # adds a '-s' prefix to the ``data/` or `meta/` base
             head = parts[0] + b'-s'
-            return os.path.join(head, *parts[1:])
+            mids = parts[1:-1]
+            tail = parts[-1] + b'.i'
+            pieces = [head] + mids + [tail]
+            return b'/'.join(pieces)
         else:
             # the revlog is stored at the root of the store (changelog or
             # manifest), no risk of collision.
--- a/tests/test-transaction-rollback-on-revlog-split.t	Fri Jul 21 15:15:43 2023 +0200
+++ b/tests/test-transaction-rollback-on-revlog-split.t	Fri Jul 21 15:50:56 2023 +0200
@@ -202,11 +202,11 @@
   data/some_dir/sub_dir/foo_bar.i.s/tutu.i 1174
   data/some_dir/sub_dir/foo_bar.i.s/tutu.d 0
   $ f -s .hg/store/data*/file*
-  .hg/store/data-s/file: size=320
+  .hg/store/data-s/file.i: size=320
   .hg/store/data/file.d: size=267307
   .hg/store/data/file.i: size=132395
   $ f -s .hg/store/data*/foo*/bar*/babar__celeste*/foo*
-  .hg/store/data/foo/bar/babar__celeste-s/foo: size=320
+  .hg/store/data-s/foo/bar/babar__celeste/foo.i: size=320
   .hg/store/data/foo/bar/babar__celeste/foo.d: size=267307
   .hg/store/data/foo/bar/babar__celeste/foo.i: size=132395
 
@@ -221,7 +221,7 @@
   data/file.d 0
   $ cat .hg/store/journal.backupfiles | tr -s '\000' ' ' | tr -s '\00' ' '| grep 'data.*/file'
    data/file.i data/journal.backup.file.i.bck 0
-   data-s/file 0
+   data-s/file.i 0
 
 recover is rolling the split back, the fncache is still valid
 
@@ -285,7 +285,7 @@
 The inline revlog still exist, but a split version exist next to it
 
   $ f -s .hg/store/data*/file*
-  .hg/store/data-s/file: size=320
+  .hg/store/data-s/file.i: size=320
   .hg/store/data/file.d: size=267307
   .hg/store/data/file.i: size=132395