Mercurial > public > mercurial-scm > hg
diff mercurial/revlog.py @ 47463:5fa083a5ff04
copies: Keep changelog sidedata file open during copy tracing
Instead of having a callback that opens and closes that file many times,
a add and use a context manager method on the `revlog` class that keeps
files open for its duration.
Differential Revision: https://phab.mercurial-scm.org/D10888
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Thu, 17 Jun 2021 19:48:25 +0200 |
parents | f8330a3fc39f |
children | bc8536e09a20 |
line wrap: on
line diff
--- a/mercurial/revlog.py Tue Jun 22 13:18:29 2021 -0400 +++ b/mercurial/revlog.py Thu Jun 17 19:48:25 2021 +0200 @@ -2086,6 +2086,13 @@ """called when trying to add a node already stored.""" @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 + + @contextlib.contextmanager def _writing(self, transaction): if self._trypending: msg = b'try to write in a `trypending` revlog: %s'