# HG changeset patch # User Pierre-Yves David # Date 2023-09-25 10:13:38 # Node ID 3470a39fb66b914f3ce7d8a311b35c56e50be718 # Parent 9461a0b74596a88d0a3e6dcdcd8d59161cde1385 revlog: adapt the `reading` check for `bundlerepo` We cannot just rely on the length check for the `bundlerepo` as the local revlog might be empty with all data in the bundle. diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -12,6 +12,7 @@ were part of the actual repository. """ +import contextlib import os import shutil @@ -108,6 +109,14 @@ class bundlerevlog(revlog.revlog): self.bundlerevs.add(n) n += 1 + @contextlib.contextmanager + def reading(self): + if self.repotiprev < 0: + yield + else: + with super().reading() as x: + yield x + def _chunk(self, rev, df=None): # Warning: in case of bundle, the diff is against what we stored as # delta base, not against rev - 1