comparison mercurial/commands.py @ 16473:7adc521259d4 stable

commands: add missing wlock to graft
author Idan Kamara <idankk86@gmail.com>
date Thu, 19 Apr 2012 18:11:48 +0300
parents 85c7602e283a
children c8ee34917045
comparison
equal deleted inserted replaced
16472:14a4e17f0817 16473:7adc521259d4
2671 '(was grafted from %d)\n') % (r, ctx.rev())) 2671 '(was grafted from %d)\n') % (r, ctx.rev()))
2672 revs.remove(r) 2672 revs.remove(r)
2673 if not revs: 2673 if not revs:
2674 return -1 2674 return -1
2675 2675
2676 for pos, ctx in enumerate(repo.set("%ld", revs)): 2676 wlock = repo.wlock()
2677 current = repo['.'] 2677 try:
2678 2678 for pos, ctx in enumerate(repo.set("%ld", revs)):
2679 ui.status(_('grafting revision %s\n') % ctx.rev()) 2679 current = repo['.']
2680 if opts.get('dry_run'): 2680
2681 continue 2681 ui.status(_('grafting revision %s\n') % ctx.rev())
2682 2682 if opts.get('dry_run'):
2683 # we don't merge the first commit when continuing 2683 continue
2684 if not cont: 2684
2685 # perform the graft merge with p1(rev) as 'ancestor' 2685 # we don't merge the first commit when continuing
2686 try: 2686 if not cont:
2687 # ui.forcemerge is an internal variable, do not document 2687 # perform the graft merge with p1(rev) as 'ancestor'
2688 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) 2688 try:
2689 stats = mergemod.update(repo, ctx.node(), True, True, False, 2689 # ui.forcemerge is an internal variable, do not document
2690 ctx.p1().node()) 2690 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
2691 finally: 2691 stats = mergemod.update(repo, ctx.node(), True, True, False,
2692 ui.setconfig('ui', 'forcemerge', '') 2692 ctx.p1().node())
2693 # drop the second merge parent 2693 finally:
2694 repo.dirstate.setparents(current.node(), nullid) 2694 ui.setconfig('ui', 'forcemerge', '')
2695 repo.dirstate.write() 2695 # drop the second merge parent
2696 # fix up dirstate for copies and renames 2696 repo.dirstate.setparents(current.node(), nullid)
2697 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev()) 2697 repo.dirstate.write()
2698 # report any conflicts 2698 # fix up dirstate for copies and renames
2699 if stats and stats[3] > 0: 2699 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
2700 # write out state for --continue 2700 # report any conflicts
2701 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] 2701 if stats and stats[3] > 0:
2702 repo.opener.write('graftstate', ''.join(nodelines)) 2702 # write out state for --continue
2703 raise util.Abort( 2703 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
2704 _("unresolved conflicts, can't continue"), 2704 repo.opener.write('graftstate', ''.join(nodelines))
2705 hint=_('use hg resolve and hg graft --continue')) 2705 raise util.Abort(
2706 else: 2706 _("unresolved conflicts, can't continue"),
2707 cont = False 2707 hint=_('use hg resolve and hg graft --continue'))
2708 2708 else:
2709 # commit 2709 cont = False
2710 source = ctx.extra().get('source') 2710
2711 if not source: 2711 # commit
2712 source = ctx.hex() 2712 source = ctx.extra().get('source')
2713 extra = {'source': source} 2713 if not source:
2714 user = ctx.user() 2714 source = ctx.hex()
2715 if opts.get('user'): 2715 extra = {'source': source}
2716 user = opts['user'] 2716 user = ctx.user()
2717 date = ctx.date() 2717 if opts.get('user'):
2718 if opts.get('date'): 2718 user = opts['user']
2719 date = opts['date'] 2719 date = ctx.date()
2720 repo.commit(text=ctx.description(), user=user, 2720 if opts.get('date'):
2721 date=date, extra=extra, editor=editor) 2721 date = opts['date']
2722 repo.commit(text=ctx.description(), user=user,
2723 date=date, extra=extra, editor=editor)
2724 finally:
2725 wlock.release()
2722 2726
2723 # remove state when we complete successfully 2727 # remove state when we complete successfully
2724 if not opts.get('dry_run') and os.path.exists(repo.join('graftstate')): 2728 if not opts.get('dry_run') and os.path.exists(repo.join('graftstate')):
2725 util.unlinkpath(repo.join('graftstate')) 2729 util.unlinkpath(repo.join('graftstate'))
2726 2730