Skip to content
Snippets Groups Projects
  • Jun Wu's avatar
    fcd1c483
    strip: add a delayedstrip method that works in a transaction · fcd1c483
    Jun Wu authored
    For long, the fact that strip does not work inside a transaction and some
    code has to work with both obsstore and fallback to strip lead to duplicated
    code like:
    
          with repo.transaction():
              ....
              if obsstore:
                  obsstore.createmarkers(...)
          if not obsstore:
              repair.strip(...)
    
    Things get more complex when you want to call something which may call strip
    under the hood. Like you cannot simply write:
    
          with repo.transaction():
              ....
              rebasemod.rebase(...) # may call "strip", so this doesn't work
    
    But you do want rebase to run inside a same transaction if possible, so the
    code may look like:
    
          with repo.transaction():
              ....
              if obsstore:
                  rebasemod.rebase(...)
                  obsstore.createmarkers(...)
          if not obsstore:
              rebasemod.rebase(...)
              repair.strip(...)
    
    That's ugly and error-prone. Ideally it's possible to just write:
    
          with repo.transaction():
              rebasemod.rebase(...)
              saferemovenodes(...)
    
    This patch is the first step towards that. It adds a "delayedstrip" method
    to repair.py which maintains a postclose callback in the transaction object.
    fcd1c483
    History
    strip: add a delayedstrip method that works in a transaction
    Jun Wu authored
    For long, the fact that strip does not work inside a transaction and some
    code has to work with both obsstore and fallback to strip lead to duplicated
    code like:
    
          with repo.transaction():
              ....
              if obsstore:
                  obsstore.createmarkers(...)
          if not obsstore:
              repair.strip(...)
    
    Things get more complex when you want to call something which may call strip
    under the hood. Like you cannot simply write:
    
          with repo.transaction():
              ....
              rebasemod.rebase(...) # may call "strip", so this doesn't work
    
    But you do want rebase to run inside a same transaction if possible, so the
    code may look like:
    
          with repo.transaction():
              ....
              if obsstore:
                  rebasemod.rebase(...)
                  obsstore.createmarkers(...)
          if not obsstore:
              rebasemod.rebase(...)
              repair.strip(...)
    
    That's ugly and error-prone. Ideally it's possible to just write:
    
          with repo.transaction():
              rebasemod.rebase(...)
              saferemovenodes(...)
    
    This patch is the first step towards that. It adds a "delayedstrip" method
    to repair.py which maintains a postclose callback in the transaction object.