revlog: make `reading` not crash on empty repository
If the revlog is empty, the file might not exist and the open will fails. This
is not great, but that details or this is now contained in the revlog itself.
--- a/mercurial/revlog.py Mon Sep 25 11:59:38 2023 +0200
+++ b/mercurial/revlog.py Mon Sep 25 12:07:25 2023 +0200
@@ -2282,9 +2282,12 @@
@contextlib.contextmanager
def reading(self):
"""Context manager that keeps data and sidedata files open for reading"""
- with self._segmentfile.reading():
- with self._segmentfile_sidedata.reading():
- yield
+ if len(self.index) == 0:
+ yield # nothing to be read
+ else:
+ with self._segmentfile.reading():
+ with self._segmentfile_sidedata.reading():
+ yield
@contextlib.contextmanager
def _writing(self, transaction):