# HG changeset patch # User Sushil khanchi # Date 1551796643 -19800 # Node ID 144cd06029de774b031894698c77c9494720b84b # Parent a56caab87e376116b43050d634697c567d170d6f split: use ui.configoverride to preserve phase while commiting As we need to preserve the phase of revision which is going to be splitted into multiple revision. This patch use ui.configoverrides to temporarily overwrite the phases.new-commit config option at the time of committing a new node. diff -r a56caab87e37 -r 144cd06029de hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Mon Mar 04 11:54:49 2019 +0100 +++ b/hgext3rd/evolve/cmdrewrite.py Tue Mar 05 20:07:23 2019 +0530 @@ -1181,11 +1181,9 @@ cmdutil.bailifchanged(repo) rewriteutil.precheck(repo, [rev], action='split') tr = repo.transaction('split') + # make sure we respect the phase while splitting + overrides = {('phases', 'new-commit'): ctx.phase()} - # make sure we respect the revision current phase while splitting - phasestr = ctx.phasestr() - if phasestr == 'secret': - opts['secret'] = True if len(ctx.parents()) > 1: raise error.Abort(_("cannot split merge commits")) prev = ctx.p1() @@ -1223,8 +1221,10 @@ if haschanges(matcher): if iselect: - cmdutil.dorecord(ui, repo, commands.commit, 'commit', False, - cmdutil.recordfilter, *pats, **opts) + with repo.ui.configoverride(overrides, 'split'): + cmdutil.dorecord(ui, repo, commands.commit, 'commit', + False, cmdutil.recordfilter, *pats, + **opts) # TODO: Does no seem like the best way to do this # We should make dorecord return the newly created commit newcommits.append(repo['.']) @@ -1233,7 +1233,8 @@ hint = _("do you want --interactive") raise error.Abort(msg, hint=hint) else: - commands.commit(ui, repo, *pats, **opts) + with repo.ui.configoverride(overrides, 'split'): + commands.commit(ui, repo, *pats, **opts) newcommits.append(repo['.']) if pats: # refresh the wctx used for the matcher @@ -1246,7 +1247,8 @@ while nextaction is None: nextaction = ui.prompt('continue splitting? [Ycdq?]', default='y') if nextaction == 'c': - commands.commit(ui, repo, **opts) + with repo.ui.configoverride(overrides, 'split'): + commands.commit(ui, repo, **opts) newcommits.append(repo['.']) break elif nextaction == 'q': @@ -1284,7 +1286,8 @@ if haschanges(): # XXX: Should we show a message for informing the user # that we create another commit with remaining changes? - commands.commit(ui, repo, **opts) + with repo.ui.configoverride(overrides, 'split'): + commands.commit(ui, repo, **opts) newcommits.append(repo['.']) if newcommits: tip = repo[newcommits[-1]]