mercurial/shelve.py
changeset 50079 acd2a0267660
parent 50054 e2b89b6d4cdd
child 50195 11e6eee4b063
equal deleted inserted replaced
50077:605f0ccffb43 50079:acd2a0267660
   430         bookmarks.activate(repo, mark)
   430         bookmarks.activate(repo, mark)
   431 
   431 
   432 
   432 
   433 def _aborttransaction(repo, tr):
   433 def _aborttransaction(repo, tr):
   434     """Abort current transaction for shelve/unshelve, but keep dirstate"""
   434     """Abort current transaction for shelve/unshelve, but keep dirstate"""
   435     dirstatebackupname = b'dirstate.shelve'
   435     # disable the transaction invalidation of the dirstate, to preserve the
   436     repo.dirstate.savebackup(None, dirstatebackupname)
   436     # current change in memory.
   437     tr.abort()
   437     ds = repo.dirstate
   438     repo.dirstate.restorebackup(None, dirstatebackupname)
   438     # The assert below check that nobody else did such wrapping.
       
   439     #
       
   440     # These is not such other wrapping currently, but if someone try to
       
   441     # implement one in the future, this will explicitly break here instead of
       
   442     # misbehaving in subtle ways.
       
   443     assert 'invalidate' not in vars(ds)
       
   444     try:
       
   445         # note : we could simply disable the transaction abort callback, but
       
   446         # other code also tries to rollback and invalidate this.
       
   447         ds.invalidate = lambda: None
       
   448         tr.abort()
       
   449     finally:
       
   450         del ds.invalidate
       
   451     # manually write the change in memory since we can no longer rely on the
       
   452     # transaction to do so.
       
   453     assert repo.currenttransaction() is None
       
   454     repo.dirstate.write(None)
   439 
   455 
   440 
   456 
   441 def getshelvename(repo, parent, opts):
   457 def getshelvename(repo, parent, opts):
   442     """Decide on the name this shelve is going to have"""
   458     """Decide on the name this shelve is going to have"""
   443 
   459