Show More
@@ -204,6 +204,7 b' class dirstate:' | |||
|
204 | 204 | msg = "entering a changing context, but dirstate is already dirty" |
|
205 | 205 | raise error.ProgrammingError(msg) |
|
206 | 206 | |
|
207 | assert self._changing_level >= 0 | |
|
207 | 208 | # different type of change are mutually exclusive |
|
208 | 209 | if self._change_type is None: |
|
209 | 210 | assert self._changing_level == 0 |
@@ -215,43 +216,37 b' class dirstate:' | |||
|
215 | 216 | ) |
|
216 | 217 | msg %= (change_type, self._change_type) |
|
217 | 218 | raise error.ProgrammingError(msg) |
|
219 | should_write = False | |
|
218 | 220 | self._changing_level += 1 |
|
219 | 221 | try: |
|
220 | 222 | yield |
|
221 | 223 | except: # re-raises |
|
222 | self.invalidate() | |
|
224 | self.invalidate() # this will set `_invalidated_context` | |
|
223 | 225 | raise |
|
224 | 226 | finally: |
|
225 | tr = repo.currenttransaction() | |
|
226 |
|
|
|
227 | if self._invalidated_context: | |
|
228 |
|
|
|
229 | # have changed. | |
|
230 | self.invalidate() | |
|
231 |
self._chang |
|
|
232 | # The invalidation is complete once we exit the final context | |
|
233 | # manager | |
|
234 | if self._changing_level <= 0: | |
|
235 |
|
|
|
236 | assert self._changing_level == 0 | |
|
237 | if self._invalidated_context: | |
|
238 | self._invalidated_context = False | |
|
239 | else: | |
|
240 | # When an exception occured, `_invalidated_context` | |
|
241 | # would have been set to True by the `invalidate` | |
|
242 | # call earlier. | |
|
243 | # | |
|
244 | # We don't have more straightforward code, because the | |
|
245 | # Exception catching (and the associated `invalidate` | |
|
246 | # calling) might have been called by a nested context | |
|
247 | # instead of the top level one. | |
|
248 | self.write(tr) | |
|
249 | if has_tr != (tr is not None): | |
|
250 | if has_tr: | |
|
251 | m = "transaction vanished while changing dirstate" | |
|
252 | else: | |
|
253 | m = "transaction appeared while changing dirstate" | |
|
254 | raise error.ProgrammingError(m) | |
|
227 | assert self._changing_level > 0 | |
|
228 | self._changing_level -= 1 | |
|
229 | # If the dirstate is being invalidated, call invalidate again. | |
|
230 | # This will throw away anything added by a upper context and | |
|
231 | # reset the `_invalidated_context` flag when relevant | |
|
232 | if self._changing_level <= 0: | |
|
233 | self._change_type = None | |
|
234 | assert self._changing_level == 0 | |
|
235 | if self._invalidated_context: | |
|
236 | # make sure we invalidate anything an upper context might | |
|
237 | # have changed. | |
|
238 | self.invalidate() | |
|
239 | else: | |
|
240 | should_write = self._changing_level <= 0 | |
|
241 | tr = repo.currenttransaction() | |
|
242 | if has_tr != (tr is not None): | |
|
243 | if has_tr: | |
|
244 | m = "transaction vanished while changing dirstate" | |
|
245 | else: | |
|
246 | m = "transaction appeared while changing dirstate" | |
|
247 | raise error.ProgrammingError(m) | |
|
248 | if should_write: | |
|
249 | self.write(tr) | |
|
255 | 250 | |
|
256 | 251 | @contextlib.contextmanager |
|
257 | 252 | def changing_parents(self, repo): |
General Comments 0
You need to be logged in to leave comments.
Login now