changelog: make the `_delayopener` a real proxy
We use the same approach as the `_divertopener`. This make it possible to use
other methods of the vfs and not just the `__call__` API.
--- a/mercurial/changelog.py Mon Sep 25 11:23:38 2023 +0200
+++ b/mercurial/changelog.py Mon Sep 25 11:59:38 2023 +0200
@@ -175,16 +175,22 @@
return getattr(self._opener, attr)
-def _delayopener(opener, target, buf):
+class _delayopener:
"""build an opener that stores chunks in 'buf' instead of 'target'"""
- def _delay(name, mode=b'r', checkambig=False, **kwargs):
- if name != target:
- return opener(name, mode, **kwargs)
+ def __init__(self, opener, target, buf):
+ self._opener = opener
+ self._target = target
+ self._buf = buf
+
+ def __call__(self, name, mode=b'r', checkambig=False, **kwargs):
+ if name != self._target:
+ return self._opener(name, mode, **kwargs)
assert not kwargs
- return appender(opener, name, mode, buf)
+ return appender(self._opener, name, mode, self._buf)
- return _delay
+ def __getattr__(self, attr):
+ return getattr(self._opener, attr)
@attr.s