# HG changeset patch # User Martin von Zweigbergk # Date 1585758089 25200 # Node ID 299d86c15b5538e7386c13f2289b83f3a71354f8 # Parent 2570d2d4a268ece829b1b8a11bedfd1665d63b11 evolve: extract function for relocating divergent commit There was some duplication here, so let's extract to a function. I'm going to add a little bit more shared code next. diff -r 2570d2d4a268 -r 299d86c15b55 hgext3rd/evolve/evolvecmd.py --- a/hgext3rd/evolve/evolvecmd.py Sun May 03 01:01:19 2020 +0200 +++ b/hgext3rd/evolve/evolvecmd.py Wed Apr 01 09:21:29 2020 -0700 @@ -444,6 +444,11 @@ return (True, divergent, other, resolutionparent, relocatereq) +def _relocatedivergent(repo, orig, dest, evolvestate): + """relocates a divergent commit and saves the evolve state""" + with state.saver(evolvestate, {b'current': orig.node()}): + return _relocate(repo, orig, dest, evolvestate, keepbranch=True) + def _solvedivergent(ui, repo, divergent, evolvestate, displayer, dryrun=False, confirm=False, progresscb=None): """tries to solve content-divergence of a changeset @@ -521,9 +526,8 @@ evolvestate[b'relocating-div'] = True ui.status(_(b'rebasing "divergent" content-divergent changeset %s on' b' %s\n' % (divergent, repo[succsdivp1]))) - with state.saver(evolvestate, {b'current': divergent.node()}): - newdivergent = _relocate(repo, divergent, repo[succsdivp1], - evolvestate, keepbranch=True) + newdivergent = _relocatedivergent(repo, divergent, repo[succsdivp1], + evolvestate) evolvestate[b'old-divergent'] = divergent.node() divergent = repo[newdivergent] evolvestate[b'relocating-div'] = False @@ -543,9 +547,7 @@ evolvestate[b'relocating-other'] = True ui.status(_(b'rebasing "other" content-divergent changeset %s on' b' %s\n' % (other, divergent.p1()))) - with state.saver(evolvestate, {b'current': other.node()}): - newother = _relocate(repo, other, divergent.p1(), evolvestate, - keepbranch=True) + newother = _relocatedivergent(repo, other, divergent.p1(), evolvestate) evolvestate[b'old-other'] = other.node() other = repo[newother] evolvestate[b'relocating-other'] = False @@ -2059,9 +2061,8 @@ evolvestate[b'relocating-other'] = True ui.status(_(b'rebasing "other" content-divergent changeset %s on' b' %s\n' % (other, divergent.p1()))) - with state.saver(evolvestate, {b'current': other.node()}): - newother = _relocate(repo, other, divergent.p1(), - evolvestate, keepbranch=True) + newother = _relocatedivergent(repo, other, divergent.p1(), + evolvestate) evolvestate[b'old-other'] = other.node() other = repo[newother] evolvestate[b'relocating-other'] = False