comparison hgext/rebase.py @ 22405:6f63c47cbb86

dirstate: wrap setparent calls with begin/endparentchange (issue4353) This wraps all the locations of dirstate.setparent with the appropriate begin/endparentchange calls. This will prevent exceptions during those calls from causing incoherent dirstates (issue4353).
author Durham Goode <durham@fb.com>
date Fri, 05 Sep 2014 11:36:20 -0700
parents 0f0b204b399c
children 5f4934487382
comparison
equal deleted inserted replaced
22404:12bc7f06fc41 22405:6f63c47cbb86
364 editor = cmdutil.getcommiteditor(editform=editform, **opts) 364 editor = cmdutil.getcommiteditor(editform=editform, **opts)
365 newrev = concludenode(repo, rev, p1, p2, extrafn=extrafn, 365 newrev = concludenode(repo, rev, p1, p2, extrafn=extrafn,
366 editor=editor) 366 editor=editor)
367 else: 367 else:
368 # Skip commit if we are collapsing 368 # Skip commit if we are collapsing
369 repo.dirstate.beginparentchange()
369 repo.setparents(repo[p1].node()) 370 repo.setparents(repo[p1].node())
371 repo.dirstate.endparentchange()
370 newrev = None 372 newrev = None
371 # Update the state 373 # Update the state
372 if newrev is not None: 374 if newrev is not None:
373 state[rev] = repo[newrev].rev() 375 state[rev] = repo[newrev].rev()
374 else: 376 else:
470 ', '.join(str(p) for p in sorted(parents)))) 472 ', '.join(str(p) for p in sorted(parents))))
471 473
472 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None): 474 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None):
473 'Commit the changes and store useful information in extra' 475 'Commit the changes and store useful information in extra'
474 try: 476 try:
477 repo.dirstate.beginparentchange()
475 repo.setparents(repo[p1].node(), repo[p2].node()) 478 repo.setparents(repo[p1].node(), repo[p2].node())
479 repo.dirstate.endparentchange()
476 ctx = repo[rev] 480 ctx = repo[rev]
477 if commitmsg is None: 481 if commitmsg is None:
478 commitmsg = ctx.description() 482 commitmsg = ctx.description()
479 extra = {'rebase_source': ctx.hex()} 483 extra = {'rebase_source': ctx.hex()}
480 if extrafn: 484 if extrafn: