mercurial/dirstate.py
changeset 50076 63c4e9639753
parent 50075 8eb460e0a202
child 50077 605f0ccffb43
equal deleted inserted replaced
50075:8eb460e0a202 50076:63c4e9639753
   215                         # We don't have more straightforward code, because the
   215                         # We don't have more straightforward code, because the
   216                         # Exception catching (and the associated `invalidate`
   216                         # Exception catching (and the associated `invalidate`
   217                         # calling) might have been called by a nested context
   217                         # calling) might have been called by a nested context
   218                         # instead of the top level one.
   218                         # instead of the top level one.
   219                         tr = repo.currenttransaction()
   219                         tr = repo.currenttransaction()
   220                         if tr is not None:
       
   221                             abort_cb = lambda tr: self.invalidate()
       
   222                             tr.addabort(b'dirstate', abort_cb)
       
   223                         self.write(tr)
   220                         self.write(tr)
   224 
   221 
   225     @contextlib.contextmanager
   222     @contextlib.contextmanager
   226     def changing_parents(self, repo):
   223     def changing_parents(self, repo):
   227         with self._changing(repo, CHANGE_TYPE_PARENTS) as c:
   224         with self._changing(repo, CHANGE_TYPE_PARENTS) as c:
   915         if not self._dirty:
   912         if not self._dirty:
   916             return
   913             return
   917 
   914 
   918         write_key = self._use_tracked_hint and self._dirty_tracked_set
   915         write_key = self._use_tracked_hint and self._dirty_tracked_set
   919         if tr:
   916         if tr:
       
   917             # make sure we invalidate the current change on abort
       
   918             if tr is not None:
       
   919                 tr.addabort(
       
   920                     b'dirstate-invalidate',
       
   921                     lambda tr: self.invalidate(),
       
   922                 )
   920             # delay writing in-memory changes out
   923             # delay writing in-memory changes out
   921             tr.addfilegenerator(
   924             tr.addfilegenerator(
   922                 b'dirstate-1-main',
   925                 b'dirstate-1-main',
   923                 (self._filename,),
   926                 (self._filename,),
   924                 lambda f: self._writedirstate(tr, f),
   927                 lambda f: self._writedirstate(tr, f),