Mercurial > evolve
changeset 1568:52c276d2ddb2
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.
author | Shusen LIU <liushusen@fb.com> |
---|---|
date | Mon, 14 Dec 2015 17:21:11 -0800 |
parents | 536fdfa3c48b |
children | 0c8548df67fe |
files | hgext/evolve.py |
diffstat | 1 files changed, 21 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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)