Show More
@@ -318,15 +318,16 def _changesetforwardcopies(a, b, match) | |||
|
318 | 318 | if p in children_count: |
|
319 | 319 | children_count[p] += 1 |
|
320 | 320 | revinfo = _revinfo_getter(repo, match) |
|
321 | return _combine_changeset_copies( | |
|
322 | revs, | |
|
323 |
|
|
|
324 | b.rev(), | |
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 | multi_thread, | |
|
329 | ) | |
|
321 | with repo.changelog.reading(): | |
|
322 | return _combine_changeset_copies( | |
|
323 | revs, | |
|
324 | children_count, | |
|
325 | b.rev(), | |
|
326 | revinfo, | |
|
327 | match, | |
|
328 | isancestor, | |
|
329 | multi_thread, | |
|
330 | ) | |
|
330 | 331 | else: |
|
331 | 332 | # When not using side-data, we will process the edges "from" the parent. |
|
332 | 333 | # so we need a full mapping of the parent -> children relation. |
@@ -2086,6 +2086,13 class revlog(object): | |||
|
2086 | 2086 | """called when trying to add a node already stored.""" |
|
2087 | 2087 | |
|
2088 | 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 | 2096 | def _writing(self, transaction): |
|
2090 | 2097 | if self._trypending: |
|
2091 | 2098 | msg = b'try to write in a `trypending` revlog: %s' |
@@ -40,6 +40,7 class randomaccessfile(object): | |||
|
40 | 40 | self.filename = filename |
|
41 | 41 | self.default_cached_chunk_size = default_cached_chunk_size |
|
42 | 42 | self.writing_handle = None # This is set from revlog.py |
|
43 | self.reading_handle = None | |
|
43 | 44 | self._cached_chunk = b'' |
|
44 | 45 | self._cached_chunk_position = 0 # Offset from the start of the file |
|
45 | 46 | if initial_cache: |
@@ -67,11 +68,31 class randomaccessfile(object): | |||
|
67 | 68 | elif self.writing_handle: |
|
68 | 69 | yield self.writing_handle |
|
69 | 70 | |
|
71 | elif self.reading_handle: | |
|
72 | yield self.reading_handle | |
|
73 | ||
|
70 | 74 | # Otherwise open a new file handle. |
|
71 | 75 | else: |
|
72 | 76 | with self._open() as fp: |
|
73 | 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 | 96 | def read_chunk(self, offset, length, existing_file_obj=None): |
|
76 | 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