revlog: adapt the `reading` check for `unionrepo`
We cannot just rely on the length check for the `unionrepo` as the local revlog
might be empty while the other revlog contains data. In addition, we need to
also open the second revlog for reading when needed.
--- a/mercurial/unionrepo.py Mon Sep 25 12:13:38 2023 +0200
+++ b/mercurial/unionrepo.py Mon Sep 25 12:14:38 2023 +0200
@@ -11,6 +11,8 @@
allowing operations like diff and log with revsets.
"""
+import contextlib
+
from .i18n import _
@@ -112,6 +114,19 @@
self.bundlerevs.add(n)
n += 1
+ @contextlib.contextmanager
+ def reading(self):
+ if 0 <= len(self.bundlerevs) < len(self.index):
+ read_1 = super().reading
+ else:
+ read_1 = util.nullcontextmanager
+ if 0 < len(self.bundlerevs):
+ read_2 = self.revlog2.reading
+ else:
+ read_2 = util.nullcontextmanager
+ with read_1(), read_2():
+ yield
+
def _chunk(self, rev, df=None):
if rev <= self.repotiprev:
return revlog.revlog._chunk(self, rev)