Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.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 | e2806b8613ca |
children | ca854cd4a26a |
comparison
equal
deleted
inserted
replaced
22404:12bc7f06fc41 | 22405:6f63c47cbb86 |
---|---|
481 rctx = scmutil.revsingle(repo, hex(parent)) | 481 rctx = scmutil.revsingle(repo, hex(parent)) |
482 if not opts.get('merge') and op1 != node: | 482 if not opts.get('merge') and op1 != node: |
483 try: | 483 try: |
484 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), | 484 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
485 'backout') | 485 'backout') |
486 repo.dirstate.beginparentchange() | |
486 stats = mergemod.update(repo, parent, True, True, False, | 487 stats = mergemod.update(repo, parent, True, True, False, |
487 node, False) | 488 node, False) |
488 repo.setparents(op1, op2) | 489 repo.setparents(op1, op2) |
490 repo.dirstate.endparentchange() | |
489 hg._showstats(repo, stats) | 491 hg._showstats(repo, stats) |
490 if stats[3]: | 492 if stats[3]: |
491 repo.ui.status(_("use 'hg resolve' to retry unresolved " | 493 repo.ui.status(_("use 'hg resolve' to retry unresolved " |
492 "file merges\n")) | 494 "file merges\n")) |
493 else: | 495 else: |
2748 r1 = scmutil.revsingle(repo, rev1).node() | 2750 r1 = scmutil.revsingle(repo, rev1).node() |
2749 r2 = scmutil.revsingle(repo, rev2, 'null').node() | 2751 r2 = scmutil.revsingle(repo, rev2, 'null').node() |
2750 | 2752 |
2751 wlock = repo.wlock() | 2753 wlock = repo.wlock() |
2752 try: | 2754 try: |
2755 repo.dirstate.beginparentchange() | |
2753 repo.setparents(r1, r2) | 2756 repo.setparents(r1, r2) |
2757 repo.dirstate.endparentchange() | |
2754 finally: | 2758 finally: |
2755 wlock.release() | 2759 wlock.release() |
2756 | 2760 |
2757 @command('debugdirstate|debugstate', | 2761 @command('debugdirstate|debugstate', |
2758 [('', 'nodates', None, _('do not display the saved mtime')), | 2762 [('', 'nodates', None, _('do not display the saved mtime')), |
3308 hint=_('use hg resolve and hg graft --continue')) | 3312 hint=_('use hg resolve and hg graft --continue')) |
3309 else: | 3313 else: |
3310 cont = False | 3314 cont = False |
3311 | 3315 |
3312 # drop the second merge parent | 3316 # drop the second merge parent |
3317 repo.dirstate.beginparentchange() | |
3313 repo.setparents(current.node(), nullid) | 3318 repo.setparents(current.node(), nullid) |
3314 repo.dirstate.write() | 3319 repo.dirstate.write() |
3315 # fix up dirstate for copies and renames | 3320 # fix up dirstate for copies and renames |
3316 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev()) | 3321 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev()) |
3322 repo.dirstate.endparentchange() | |
3317 | 3323 |
3318 # commit | 3324 # commit |
3319 node = repo.commit(text=message, user=user, | 3325 node = repo.commit(text=message, user=user, |
3320 date=date, extra=extra, editor=editor) | 3326 date=date, extra=extra, editor=editor) |
3321 if node is None: | 3327 if node is None: |
3920 | 3926 |
3921 | 3927 |
3922 try: | 3928 try: |
3923 try: | 3929 try: |
3924 wlock = repo.wlock() | 3930 wlock = repo.wlock() |
3931 repo.dirstate.beginparentchange() | |
3925 if not opts.get('no_commit'): | 3932 if not opts.get('no_commit'): |
3926 lock = repo.lock() | 3933 lock = repo.lock() |
3927 tr = repo.transaction('import') | 3934 tr = repo.transaction('import') |
3928 parents = repo.parents() | 3935 parents = repo.parents() |
3929 for patchurl in patches: | 3936 for patchurl in patches: |
3960 | 3967 |
3961 if tr: | 3968 if tr: |
3962 tr.close() | 3969 tr.close() |
3963 if msgs: | 3970 if msgs: |
3964 repo.savecommitmessage('\n* * *\n'.join(msgs)) | 3971 repo.savecommitmessage('\n* * *\n'.join(msgs)) |
3972 repo.dirstate.endparentchange() | |
3965 return ret | 3973 return ret |
3966 except: # re-raises | 3974 except: # re-raises |
3967 # wlock.release() indirectly calls dirstate.write(): since | 3975 # wlock.release() indirectly calls dirstate.write(): since |
3968 # we're crashing, we do not want to change the working dir | 3976 # we're crashing, we do not want to change the working dir |
3969 # parent after all, so make sure it writes nothing | 3977 # parent after all, so make sure it writes nothing |