comparison hgext/evolve.py @ 516:18854dbc92e7 stable

evolve: simplify locking in _solveconflicting()
author Patrick Mezard <patrick@mezard.eu>
date Sat, 25 Aug 2012 09:32:05 +0200
parents 0b60c28d9c43
children 0bc0c9edcb15
comparison
equal deleted inserted replaced
515:0b60c28d9c43 516:18854dbc92e7
1552 ui.write('hg up -C %s &&\n' % base) 1552 ui.write('hg up -C %s &&\n' % base)
1553 ui.write('hg revert --all --rev tip &&\n') 1553 ui.write('hg revert --all --rev tip &&\n')
1554 ui.write('hg commit -m "`hg log -r %s --template={desc}`";\n' % conflicting) 1554 ui.write('hg commit -m "`hg log -r %s --template={desc}`";\n' % conflicting)
1555 return 1555 return
1556 #oldphase = max(conflicting.phase(), other.phase()) 1556 #oldphase = max(conflicting.phase(), other.phase())
1557 wlock = repo.wlock() 1557 wlock = lock = None
1558 try: 1558 try:
1559 wlock = repo.wlock()
1559 lock = repo.lock() 1560 lock = repo.lock()
1561 if conflicting not in repo[None].parents():
1562 repo.ui.status(_('updating to "local" conflict\n'))
1563 hg.update(repo, conflicting.rev())
1564 repo.ui.note(_('merging conflicting changeset\n'))
1565 stats = merge.update(repo,
1566 other.node(),
1567 branchmerge=True,
1568 force=False,
1569 partial=None,
1570 ancestor=base.node(),
1571 mergeancestor=True)
1572 hg._showstats(repo, stats)
1573 if stats[3]:
1574 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
1575 "or 'hg update -C .' to abandon\n"))
1576 #repo.dirstate.write()
1577 if stats[3] > 0:
1578 raise util.Abort('GASP! Merge Conflict! You are on you own chap!',
1579 hint='/!\\ hg evolve --continue will NOT work /!\\')
1580 tr = repo.transaction('stabilize-conflicting')
1560 try: 1581 try:
1561 if conflicting not in repo[None].parents(): 1582 repo.dirstate.setparents(conflicting.node(), node.nullid)
1562 repo.ui.status(_('updating to "local" conflict\n')) 1583 oldlen = len(repo)
1563 hg.update(repo, conflicting.rev()) 1584 amend(ui, repo)
1564 repo.ui.note(_('merging conflicting changeset\n')) 1585 if oldlen == len(repo):
1565 stats = merge.update(repo, 1586 new = conflicting
1566 other.node(), 1587 # no changes
1567 branchmerge=True, 1588 else:
1568 force=False, 1589 new = repo['.']
1569 partial=None, 1590 createmarkers(repo, [(other, (new,))])
1570 ancestor=base.node(), 1591 phases.retractboundary(repo, other.phase(), [new.node()])
1571 mergeancestor=True) 1592 tr.close()
1572 hg._showstats(repo, stats)
1573 if stats[3]:
1574 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
1575 "or 'hg update -C .' to abandon\n"))
1576 #repo.dirstate.write()
1577 if stats[3] > 0:
1578 raise util.Abort('GASP! Merge Conflict! You are on you own chap!',
1579 hint='/!\\ hg evolve --continue will NOT work /!\\')
1580 tr = repo.transaction('stabilize-conflicting')
1581 try:
1582 repo.dirstate.setparents(conflicting.node(), node.nullid)
1583 oldlen = len(repo)
1584 amend(ui, repo)
1585 if oldlen == len(repo):
1586 new = conflicting
1587 # no changes
1588 else:
1589 new = repo['.']
1590 createmarkers(repo, [(other, (new,))])
1591 phases.retractboundary(repo, other.phase(), [new.node()])
1592 tr.close()
1593 finally:
1594 tr.release()
1595 finally: 1593 finally:
1596 lock.release() 1594 tr.release()
1597 finally: 1595 finally:
1598 wlock.release() 1596 lockmod.release(lock, wlock)
1599 1597
1600 1598
1601 def conflictingdata(ctx): 1599 def conflictingdata(ctx):
1602 """return base, other part of a conflict 1600 """return base, other part of a conflict
1603 1601