##// END OF EJS Templates
changelog: disallow delayed write on inline changesets...
marmoute -
r52460:a93e52f0 default
parent child Browse files
Show More
@@ -367,7 +367,7 b' class _InnerRevlog:'
367 367 self.opener = opener
368 368 self.index = index
369 369
370 self.__index_file = index_file
370 self.index_file = index_file
371 371 self.data_file = data_file
372 372 self.sidedata_file = sidedata_file
373 373 self.inline = inline
@@ -416,16 +416,6 b' class _InnerRevlog:'
416 416
417 417 self._delay_buffer = None
418 418
419 @property
420 def index_file(self):
421 return self.__index_file
422
423 @index_file.setter
424 def index_file(self, new_index_file):
425 self.__index_file = new_index_file
426 if self.inline:
427 self._segmentfile.filename = new_index_file
428
429 419 def __len__(self):
430 420 return len(self.index)
431 421
@@ -652,6 +642,9 b' class _InnerRevlog:'
652 642 """Context manager that keeps data and sidedata files open for reading"""
653 643 if len(self.index) == 0:
654 644 yield # nothing to be read
645 elif self._delay_buffer is not None and self.inline:
646 msg = "revlog with delayed write should not be inline"
647 raise error.ProgrammingError(msg)
655 648 else:
656 649 with self._segmentfile.reading():
657 650 with self._segmentfile_sidedata.reading():
@@ -1137,18 +1130,16 b' class _InnerRevlog:'
1137 1130 ifh.write(entry)
1138 1131 else:
1139 1132 self._delay_buffer.append(entry)
1133 elif self._delay_buffer is not None:
1134 msg = b'invalid delayed write on inline revlog'
1135 raise error.ProgrammingError(msg)
1140 1136 else:
1141 1137 offset += curr * self.index.entry_size
1142 1138 transaction.add(self.canonical_index_file, offset)
1143 1139 assert not sidedata
1144 if self._delay_buffer is None:
1145 ifh.write(entry)
1146 ifh.write(data[0])
1147 ifh.write(data[1])
1148 else:
1149 self._delay_buffer.append(entry)
1150 self._delay_buffer.append(data[0])
1151 self._delay_buffer.append(data[1])
1140 ifh.write(entry)
1141 ifh.write(data[0])
1142 ifh.write(data[1])
1152 1143 return (
1153 1144 ifh.tell(),
1154 1145 dfh.tell() if dfh else None,
@@ -1160,6 +1151,9 b' class _InnerRevlog:'
1160 1151
1161 1152 def delay(self):
1162 1153 assert not self.is_open
1154 if self.inline:
1155 msg = "revlog with delayed write should not be inline"
1156 raise error.ProgrammingError(msg)
1163 1157 if self._delay_buffer is not None or self._orig_index_file is not None:
1164 1158 # delay or divert already in place
1165 1159 return None
@@ -1173,12 +1167,13 b' class _InnerRevlog:'
1173 1167 return self.index_file
1174 1168 else:
1175 1169 self._delay_buffer = []
1176 if self.inline:
1177 self._segmentfile._delay_buffer = self._delay_buffer
1178 1170 return None
1179 1171
1180 1172 def write_pending(self):
1181 1173 assert not self.is_open
1174 if self.inline:
1175 msg = "revlog with delayed write should not be inline"
1176 raise error.ProgrammingError(msg)
1182 1177 if self._orig_index_file is not None:
1183 1178 return None, True
1184 1179 any_pending = False
@@ -1195,16 +1190,15 b' class _InnerRevlog:'
1195 1190 ifh.write(b"".join(self._delay_buffer))
1196 1191 any_pending = True
1197 1192 self._delay_buffer = None
1198 if self.inline:
1199 self._segmentfile._delay_buffer = self._delay_buffer
1200 else:
1201 assert self._segmentfile._delay_buffer is None
1202 1193 self._orig_index_file = self.index_file
1203 1194 self.index_file = pending_index_file
1204 1195 return self.index_file, any_pending
1205 1196
1206 1197 def finalize_pending(self):
1207 1198 assert not self.is_open
1199 if self.inline:
1200 msg = "revlog with delayed write should not be inline"
1201 raise error.ProgrammingError(msg)
1208 1202
1209 1203 delay = self._delay_buffer is not None
1210 1204 divert = self._orig_index_file is not None
@@ -1216,7 +1210,7 b' class _InnerRevlog:'
1216 1210 with self.opener(self.index_file, b'r+') as ifh:
1217 1211 ifh.seek(0, os.SEEK_END)
1218 1212 ifh.write(b"".join(self._delay_buffer))
1219 self._segmentfile._delay_buffer = self._delay_buffer = None
1213 self._delay_buffer = None
1220 1214 elif divert:
1221 1215 if self.opener.exists(self.index_file):
1222 1216 self.opener.rename(
@@ -2831,7 +2825,7 b' class revlog:'
2831 2825 """
2832 2826 tiprev = len(self) - 1
2833 2827 total_size = self.start(tiprev) + self.length(tiprev)
2834 if not self._inline or total_size < _maxinline:
2828 if not self._inline or (self._may_inline and total_size < _maxinline):
2835 2829 return
2836 2830
2837 2831 if self._docket is not None:
@@ -116,8 +116,6 b' class randomaccessfile:'
116 116 if initial_cache:
117 117 self._cached_chunk_position, self._cached_chunk = initial_cache
118 118
119 self._delay_buffer = None
120
121 119 def clear_cache(self):
122 120 self._cached_chunk = b''
123 121 self._cached_chunk_position = 0
@@ -133,12 +131,7 b' class randomaccessfile:'
133 131
134 132 def _open(self, mode=b'r'):
135 133 """Return a file object"""
136 if self._delay_buffer is None:
137 return self.opener(self.filename, mode=mode)
138 else:
139 return appender(
140 self.opener, self.filename, mode, self._delay_buffer
141 )
134 return self.opener(self.filename, mode=mode)
142 135
143 136 @contextlib.contextmanager
144 137 def _read_handle(self):
General Comments 0
You need to be logged in to leave comments. Login now