Mercurial > evolve
diff hgext/evolve.py @ 1592:f157ef7b1741
evolve: extract logic to new method _evolvemerge
This patch introduces a new method _evolvemerge to merge orig to dest in
relocate method.
This simplifies the code of the method relocate and allows us to re-use it
later in the scope of the rework of 'hg evolve --continue'
author | Shusen LIU <liushusen@fb.com> |
---|---|
date | Tue, 26 Jan 2016 15:42:01 -0800 |
parents | d6630a6bff86 |
children | 2f117c299325 |
line wrap: on
line diff
--- a/hgext/evolve.py Sat Jan 30 16:53:12 2016 +0100 +++ b/hgext/evolve.py Tue Jan 26 15:42:01 2016 -0800 @@ -949,26 +949,7 @@ tr = repo.transaction('relocate') try: try: - if repo['.'].rev() != dest.rev(): - merge.update(repo, dest, False, True, False) - if bmactive(repo): - repo.ui.status(_("(leaving bookmark %s)\n") % bmactive(repo)) - bmdeactivate(repo) - if keepbranch: - repo.dirstate.setbranch(orig.branch()) - - try: - r = merge.graft(repo, orig, pctx, ['local', 'graft'], True) - except TypeError: - # not using recent enough mercurial - if len(orig.parents()) == 2: - raise error.Abort( - _("no support for evolving merge changesets yet"), - hint=_("Redo the merge and use `hg prune <old> --succ " - "<new>` to obsolete the old one")) - - r = merge.graft(repo, orig, pctx, ['local', 'graft']) - + r = _evolvemerge(repo, orig, dest, pctx, keepbranch) if r[-1]: #some conflict raise error.Abort( 'unresolved merge conflicts (see hg help resolve)') @@ -3754,3 +3735,27 @@ repo._bookmarks[book] = dest.node() if oldbookmarks or destbookmarks: repo._bookmarks.recordchange(tr) + +def _evolvemerge(repo, orig, dest, pctx, keepbranch): + """Used by the evolve function to merge dest on top of pctx. + return the same tuple as merge.graft""" + if repo['.'].rev() != dest.rev(): + merge.update(repo, dest, False, True, False) + if bmactive(repo): + repo.ui.status(_("(leaving bookmark %s)\n") % bmactive(repo)) + bmdeactivate(repo) + if keepbranch: + repo.dirstate.setbranch(orig.branch()) + + try: + r = merge.graft(repo, orig, pctx, ['local', 'graft'], True) + except TypeError: + # not using recent enough mercurial + if len(orig.parents()) == 2: + raise error.Abort( + _("no support for evolving merge changesets yet"), + hint=_("Redo the merge and use `hg prune <old> --succ " + "<new>` to obsolete the old one")) + + r = merge.graft(repo, orig, pctx, ['local', 'graft']) + return r