[Commented On] D10888: copies: Keep changelog sidedata file open during copy tracing
baymax (Baymax, Your Personal Patch-care Companion)
phabricator at mercurial-scm.org
Tue Jun 22 15:19:22 UTC 2021
baymax added a comment.
baymax updated this revision to Diff 28670.
✅ refresh by Heptapod after a successful CI run (🐙 💚)
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10888?vs=28630&id=28670
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10888/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10888
AFFECTED FILES
mercurial/copies.py
mercurial/revlog.py
mercurial/revlogutils/randomaccessfile.py
CHANGE DETAILS
diff --git a/mercurial/revlogutils/randomaccessfile.py b/mercurial/revlogutils/randomaccessfile.py
--- a/mercurial/revlogutils/randomaccessfile.py
+++ b/mercurial/revlogutils/randomaccessfile.py
@@ -40,6 +40,7 @@
self.filename = filename
self.default_cached_chunk_size = default_cached_chunk_size
self.writing_handle = None # This is set from revlog.py
+ self.reading_handle = None
self._cached_chunk = b''
self._cached_chunk_position = 0 # Offset from the start of the file
if initial_cache:
@@ -67,11 +68,31 @@
elif self.writing_handle:
yield self.writing_handle
+ elif self.reading_handle:
+ yield self.reading_handle
+
# Otherwise open a new file handle.
else:
with self._open() as fp:
yield fp
+ @contextlib.contextmanager
+ def reading(self):
+ """Context manager that keeps the file open for reading"""
+ if (
+ self.reading_handle is None
+ and self.writing_handle is None
+ and self.filename is not None
+ ):
+ with self._open() as fp:
+ self.reading_handle = fp
+ try:
+ yield
+ finally:
+ self.reading_handle = None
+ else:
+ yield
+
def read_chunk(self, offset, length, existing_file_obj=None):
"""Read a chunk of bytes from the file.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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'
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -318,15 +318,16 @@
if p in children_count:
children_count[p] += 1
revinfo = _revinfo_getter(repo, match)
- return _combine_changeset_copies(
- revs,
- children_count,
- b.rev(),
- revinfo,
- match,
- isancestor,
- multi_thread,
- )
+ with repo.changelog.reading():
+ return _combine_changeset_copies(
+ revs,
+ children_count,
+ b.rev(),
+ revinfo,
+ match,
+ isancestor,
+ multi_thread,
+ )
else:
# When not using side-data, we will process the edges "from" the parent.
# so we need a full mapping of the parent -> children relation.
To: SimonSapin, indygreg, #hg-reviewers
Cc: joerg.sonnenberger, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210622/d7cc8252/attachment-0002.html>
More information about the Mercurial-patches
mailing list