Mercurial > evolve
changeset 1023:7c8e3941241f
relocate: add transaction around phase movement
cheap way to acces access to the transaction object
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 06 Aug 2014 18:10:00 -0700 |
parents | 6f4fd3e49d1c |
children | 9d538ebf3985 |
files | hgext/evolve.py |
diffstat | 1 files changed, 32 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/evolve.py Wed Aug 06 17:14:00 2014 -0700 +++ b/hgext/evolve.py Wed Aug 06 18:10:00 2014 -0700 @@ -852,35 +852,40 @@ destbookmarks = repo.nodebookmarks(dest.node()) nodesrc = orig.node() destphase = repo[nodesrc].phase() + tr = repo.transaction('relocate') try: - r = rebase.rebasenode(repo, orig.node(), dest.node(), - {node.nullrev: node.nullrev}, False) - if r[-1]: #some conflict - raise util.Abort( - 'unresolved merge conflicts (see hg help resolve)') - cmdutil.duplicatecopies(repo, orig.node(), dest.node()) - nodenew = rebase.concludenode(repo, orig.node(), dest.node(), - node.nullid) - except util.Abort, exc: - class LocalMergeFailure(MergeFailure, exc.__class__): - pass - exc.__class__ = LocalMergeFailure - raise - oldbookmarks = repo.nodebookmarks(nodesrc) - if nodenew is not None: - retractboundary(repo, destphase, [nodenew]) - createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))]) - for book in oldbookmarks: - repo._bookmarks[book] = nodenew - else: - createmarkers(repo, [(repo[nodesrc], ())]) - # Behave like rebase, move bookmarks to dest - for book in oldbookmarks: + try: + r = rebase.rebasenode(repo, orig.node(), dest.node(), + {node.nullrev: node.nullrev}, False) + if r[-1]: #some conflict + raise util.Abort( + 'unresolved merge conflicts (see hg help resolve)') + cmdutil.duplicatecopies(repo, orig.node(), dest.node()) + nodenew = rebase.concludenode(repo, orig.node(), dest.node(), + node.nullid) + except util.Abort, exc: + class LocalMergeFailure(MergeFailure, exc.__class__): + pass + exc.__class__ = LocalMergeFailure + raise + oldbookmarks = repo.nodebookmarks(nodesrc) + if nodenew is not None: + retractboundary(repo, destphase, [nodenew]) + createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))]) + for book in oldbookmarks: + repo._bookmarks[book] = nodenew + else: + createmarkers(repo, [(repo[nodesrc], ())]) + # Behave like rebase, move bookmarks to dest + for book in oldbookmarks: + repo._bookmarks[book] = dest.node() + for book in destbookmarks: # restore bookmark that rebase move repo._bookmarks[book] = dest.node() - for book in destbookmarks: # restore bookmark that rebase move - repo._bookmarks[book] = dest.node() - if oldbookmarks or destbookmarks: - repo._bookmarks.write() + if oldbookmarks or destbookmarks: + repo._bookmarks.write() + tr.close() + finally: + tr.release() return nodenew def _bookmarksupdater(repo, oldid):