##// END OF EJS Templates
copies: Keep changelog sidedata file open during copy tracing...
Simon Sapin -
r48256:5fa083a5 default
parent child Browse files
Show More
@@ -318,15 +318,16 b' def _changesetforwardcopies(a, b, match)'
318 if p in children_count:
318 if p in children_count:
319 children_count[p] += 1
319 children_count[p] += 1
320 revinfo = _revinfo_getter(repo, match)
320 revinfo = _revinfo_getter(repo, match)
321 return _combine_changeset_copies(
321 with repo.changelog.reading():
322 revs,
322 return _combine_changeset_copies(
323 children_count,
323 revs,
324 b.rev(),
324 children_count,
325 revinfo,
325 b.rev(),
326 match,
326 revinfo,
327 isancestor,
327 match,
328 multi_thread,
328 isancestor,
329 )
329 multi_thread,
330 )
330 else:
331 else:
331 # When not using side-data, we will process the edges "from" the parent.
332 # When not using side-data, we will process the edges "from" the parent.
332 # so we need a full mapping of the parent -> children relation.
333 # so we need a full mapping of the parent -> children relation.
@@ -2086,6 +2086,13 b' class revlog(object):'
2086 """called when trying to add a node already stored."""
2086 """called when trying to add a node already stored."""
2087
2087
2088 @contextlib.contextmanager
2088 @contextlib.contextmanager
2089 def reading(self):
2090 """Context manager that keeps data and sidedata files open for reading"""
2091 with self._segmentfile.reading():
2092 with self._segmentfile_sidedata.reading():
2093 yield
2094
2095 @contextlib.contextmanager
2089 def _writing(self, transaction):
2096 def _writing(self, transaction):
2090 if self._trypending:
2097 if self._trypending:
2091 msg = b'try to write in a `trypending` revlog: %s'
2098 msg = b'try to write in a `trypending` revlog: %s'
@@ -40,6 +40,7 b' class randomaccessfile(object):'
40 self.filename = filename
40 self.filename = filename
41 self.default_cached_chunk_size = default_cached_chunk_size
41 self.default_cached_chunk_size = default_cached_chunk_size
42 self.writing_handle = None # This is set from revlog.py
42 self.writing_handle = None # This is set from revlog.py
43 self.reading_handle = None
43 self._cached_chunk = b''
44 self._cached_chunk = b''
44 self._cached_chunk_position = 0 # Offset from the start of the file
45 self._cached_chunk_position = 0 # Offset from the start of the file
45 if initial_cache:
46 if initial_cache:
@@ -67,11 +68,31 b' class randomaccessfile(object):'
67 elif self.writing_handle:
68 elif self.writing_handle:
68 yield self.writing_handle
69 yield self.writing_handle
69
70
71 elif self.reading_handle:
72 yield self.reading_handle
73
70 # Otherwise open a new file handle.
74 # Otherwise open a new file handle.
71 else:
75 else:
72 with self._open() as fp:
76 with self._open() as fp:
73 yield fp
77 yield fp
74
78
79 @contextlib.contextmanager
80 def reading(self):
81 """Context manager that keeps the file open for reading"""
82 if (
83 self.reading_handle is None
84 and self.writing_handle is None
85 and self.filename is not None
86 ):
87 with self._open() as fp:
88 self.reading_handle = fp
89 try:
90 yield
91 finally:
92 self.reading_handle = None
93 else:
94 yield
95
75 def read_chunk(self, offset, length, existing_file_obj=None):
96 def read_chunk(self, offset, length, existing_file_obj=None):
76 """Read a chunk of bytes from the file.
97 """Read a chunk of bytes from the file.
77
98
General Comments 0
You need to be logged in to leave comments. Login now