hgext/shelve.py
changeset 27841 83995fdde225
parent 27838 60b850b7e4ef
child 27888 6c740218215d
equal deleted inserted replaced
27840:dc237afacbd4 27841:83995fdde225
   459     cwd = repo.getcwd()
   459     cwd = repo.getcwd()
   460     return [repo.pathto(f, cwd) for f in files]
   460     return [repo.pathto(f, cwd) for f in files]
   461 
   461 
   462 def unshelveabort(ui, repo, state, opts):
   462 def unshelveabort(ui, repo, state, opts):
   463     """subcommand that abort an in-progress unshelve"""
   463     """subcommand that abort an in-progress unshelve"""
   464     lock = None
   464     with repo.lock():
   465     try:
       
   466         checkparents(repo, state)
       
   467 
       
   468         util.rename(repo.join('unshelverebasestate'),
       
   469                     repo.join('rebasestate'))
       
   470         try:
   465         try:
   471             rebase.rebase(ui, repo, **{
   466             checkparents(repo, state)
   472                 'abort' : True
   467 
   473             })
   468             util.rename(repo.join('unshelverebasestate'),
   474         except Exception:
   469                         repo.join('rebasestate'))
   475             util.rename(repo.join('rebasestate'),
   470             try:
   476                         repo.join('unshelverebasestate'))
   471                 rebase.rebase(ui, repo, **{
   477             raise
   472                     'abort' : True
   478 
   473                 })
   479         lock = repo.lock()
   474             except Exception:
   480 
   475                 util.rename(repo.join('rebasestate'),
   481         mergefiles(ui, repo, state.wctx, state.pendingctx)
   476                             repo.join('unshelverebasestate'))
   482 
   477                 raise
   483         repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve')
   478 
   484     finally:
   479             mergefiles(ui, repo, state.wctx, state.pendingctx)
   485         shelvedstate.clear(repo)
   480             repair.strip(ui, repo, state.stripnodes, backup=False,
   486         ui.warn(_("unshelve of '%s' aborted\n") % state.name)
   481                          topic='shelve')
   487         lockmod.release(lock)
   482         finally:
       
   483             shelvedstate.clear(repo)
       
   484             ui.warn(_("unshelve of '%s' aborted\n") % state.name)
   488 
   485 
   489 def mergefiles(ui, repo, wctx, shelvectx):
   486 def mergefiles(ui, repo, wctx, shelvectx):
   490     """updates to wctx and merges the changes from shelvectx into the
   487     """updates to wctx and merges the changes from shelvectx into the
   491     dirstate."""
   488     dirstate."""
   492     oldquiet = ui.quiet
   489     oldquiet = ui.quiet