Mercurial > evolve
comparison hgext/evolve.py @ 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 |
comparison
equal
deleted
inserted
replaced
1022:6f4fd3e49d1c | 1023:7c8e3941241f |
---|---|
850 'no support for evolving merge changesets yet', | 850 'no support for evolving merge changesets yet', |
851 hint="Redo the merge a use `hg prune` to obsolete the old one") | 851 hint="Redo the merge a use `hg prune` to obsolete the old one") |
852 destbookmarks = repo.nodebookmarks(dest.node()) | 852 destbookmarks = repo.nodebookmarks(dest.node()) |
853 nodesrc = orig.node() | 853 nodesrc = orig.node() |
854 destphase = repo[nodesrc].phase() | 854 destphase = repo[nodesrc].phase() |
855 tr = repo.transaction('relocate') | |
855 try: | 856 try: |
856 r = rebase.rebasenode(repo, orig.node(), dest.node(), | 857 try: |
857 {node.nullrev: node.nullrev}, False) | 858 r = rebase.rebasenode(repo, orig.node(), dest.node(), |
858 if r[-1]: #some conflict | 859 {node.nullrev: node.nullrev}, False) |
859 raise util.Abort( | 860 if r[-1]: #some conflict |
860 'unresolved merge conflicts (see hg help resolve)') | 861 raise util.Abort( |
861 cmdutil.duplicatecopies(repo, orig.node(), dest.node()) | 862 'unresolved merge conflicts (see hg help resolve)') |
862 nodenew = rebase.concludenode(repo, orig.node(), dest.node(), | 863 cmdutil.duplicatecopies(repo, orig.node(), dest.node()) |
863 node.nullid) | 864 nodenew = rebase.concludenode(repo, orig.node(), dest.node(), |
864 except util.Abort, exc: | 865 node.nullid) |
865 class LocalMergeFailure(MergeFailure, exc.__class__): | 866 except util.Abort, exc: |
866 pass | 867 class LocalMergeFailure(MergeFailure, exc.__class__): |
867 exc.__class__ = LocalMergeFailure | 868 pass |
868 raise | 869 exc.__class__ = LocalMergeFailure |
869 oldbookmarks = repo.nodebookmarks(nodesrc) | 870 raise |
870 if nodenew is not None: | 871 oldbookmarks = repo.nodebookmarks(nodesrc) |
871 retractboundary(repo, destphase, [nodenew]) | 872 if nodenew is not None: |
872 createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))]) | 873 retractboundary(repo, destphase, [nodenew]) |
873 for book in oldbookmarks: | 874 createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))]) |
874 repo._bookmarks[book] = nodenew | 875 for book in oldbookmarks: |
875 else: | 876 repo._bookmarks[book] = nodenew |
876 createmarkers(repo, [(repo[nodesrc], ())]) | 877 else: |
877 # Behave like rebase, move bookmarks to dest | 878 createmarkers(repo, [(repo[nodesrc], ())]) |
878 for book in oldbookmarks: | 879 # Behave like rebase, move bookmarks to dest |
880 for book in oldbookmarks: | |
881 repo._bookmarks[book] = dest.node() | |
882 for book in destbookmarks: # restore bookmark that rebase move | |
879 repo._bookmarks[book] = dest.node() | 883 repo._bookmarks[book] = dest.node() |
880 for book in destbookmarks: # restore bookmark that rebase move | 884 if oldbookmarks or destbookmarks: |
881 repo._bookmarks[book] = dest.node() | 885 repo._bookmarks.write() |
882 if oldbookmarks or destbookmarks: | 886 tr.close() |
883 repo._bookmarks.write() | 887 finally: |
888 tr.release() | |
884 return nodenew | 889 return nodenew |
885 | 890 |
886 def _bookmarksupdater(repo, oldid): | 891 def _bookmarksupdater(repo, oldid): |
887 """Return a callable update(newid) updating the current bookmark | 892 """Return a callable update(newid) updating the current bookmark |
888 and bookmarks bound to oldid to newid. | 893 and bookmarks bound to oldid to newid. |