evolve: extract logic to new method _finalizerelocate
This patch introduces a new method _finalizerelocate to finalize current state
after merge states in relocate method.
This simplifies the code of the method relocate and allows us to modify it
later to support a continued keywork to implement evolve state.
--- a/hgext/evolve.py Mon Dec 14 17:02:55 2015 -0800
+++ b/hgext/evolve.py Mon Dec 14 17:21:11 2015 -0800
@@ -966,20 +966,7 @@
exc.__class__ = LocalMergeFailure
raise
oldbookmarks = repo.nodebookmarks(nodesrc)
- if nodenew is not None:
- phases.retractboundary(repo, tr, destphase, [nodenew])
- obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))])
- for book in oldbookmarks:
- repo._bookmarks[book] = nodenew
- else:
- obsolete.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()
- if oldbookmarks or destbookmarks:
- repo._bookmarks.recordchange(tr)
+ _finalizerelocate(repo, orig, dest, nodenew, tr)
tr.close()
finally:
tr.release()
@@ -3685,3 +3672,23 @@
finally:
repo.ui.restoreconfig(backup)
return nodenew
+
+def _finalizerelocate(repo, orig, dest, nodenew, tr):
+ destbookmarks = repo.nodebookmarks(dest.node())
+ nodesrc = orig.node()
+ destphase = repo[nodesrc].phase()
+ oldbookmarks = repo.nodebookmarks(nodesrc)
+ if nodenew is not None:
+ phases.retractboundary(repo, tr, destphase, [nodenew])
+ obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))])
+ for book in oldbookmarks:
+ repo._bookmarks[book] = nodenew
+ else:
+ obsolete.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()
+ if oldbookmarks or destbookmarks:
+ repo._bookmarks.recordchange(tr)