changeset 51077:74c004a515bc stable

stream-clone: fix a crash when a repo with an empty revlog is cloned
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Thu, 12 Oct 2023 17:41:06 +0100
parents 704c3d0878d9
children 8d574691d915
files mercurial/revlog.py tests/test-clone-stream.t
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Tue Oct 10 18:29:04 2023 +0200
+++ b/mercurial/revlog.py	Thu Oct 12 17:41:06 2023 +0100
@@ -292,6 +292,9 @@
 
     @staticmethod
     def is_inline_index(header_bytes):
+        if len(header_bytes) == 0:
+            return True
+
         header = INDEX_HEADER.unpack(header_bytes)[0]
 
         _format_flags = header & ~0xFFFF
--- a/tests/test-clone-stream.t	Tue Oct 10 18:29:04 2023 +0200
+++ b/tests/test-clone-stream.t	Thu Oct 12 17:41:06 2023 +0100
@@ -980,3 +980,15 @@
   $ mkdir -p empty-repo/.hg
   $ hg clone -q --stream ssh://user@dummy/empty-repo empty-repo2
   $ hg --cwd empty-repo2 verify -q
+
+Cloning a repo with an empty manifestlog doesn't give some weird error
+
+  $ rm -r empty-repo; hg init empty-repo
+  $ (cd empty-repo; touch x; hg commit -Am empty; hg debugstrip -r 0) > /dev/null
+  $ hg clone -q --stream ssh://user@dummy/empty-repo empty-repo3
+  $ hg --cwd empty-repo3 verify -q 2>&1 | grep -v warning
+  [1]
+
+The warnings filtered out here are talking about zero-length 'orphan' data files.
+Those are harmless, so that's fine.
+