# HG changeset patch # User Shusen LIU # Date 1450141375 28800 # Node ID 536fdfa3c48b1942a68fe14b517a954c23a22eb2 # Parent 25254b2f811671adec50bc9e359d231fe29e4848 evolve: extract logic to new method _relocatecommit This patch introduces a new method _relocatecommit to commit 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. diff -r 25254b2f8116 -r 536fdfa3c48b hgext/evolve.py --- a/hgext/evolve.py Thu Dec 17 16:00:32 2015 +0000 +++ b/hgext/evolve.py Mon Dec 14 17:02:55 2015 -0800 @@ -953,22 +953,7 @@ if r[-1]: #some conflict raise error.Abort( 'unresolved merge conflicts (see hg help resolve)') - if commitmsg is None: - commitmsg = orig.description() - extra = dict(orig.extra()) - if 'branch' in extra: - del extra['branch'] - extra['rebase_source'] = orig.hex() - - backup = repo.ui.backupconfig('phases', 'new-commit') - try: - targetphase = max(orig.phase(), phases.draft) - repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase') - # Commit might fail if unresolved files exist - nodenew = repo.commit(text=commitmsg, user=orig.user(), - date=orig.date(), extra=extra) - finally: - repo.ui.restoreconfig(backup) + nodenew = _relocatecommit(repo, orig, commitmsg) except error.Abort as exc: repo.dirstate.beginparentchange() repo.setparents(repo['.'].node(), nullid) @@ -3681,3 +3666,22 @@ help.helptable.append((["evolution"], _("Safely Rewriting History"), _helploader)) help.helptable.sort() + +def _relocatecommit(repo, orig, commitmsg): + if commitmsg is None: + commitmsg = orig.description() + extra = dict(orig.extra()) + if 'branch' in extra: + del extra['branch'] + extra['rebase_source'] = orig.hex() + + backup = repo.ui.backupconfig('phases', 'new-commit') + try: + targetphase = max(orig.phase(), phases.draft) + repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase') + # Commit might fail if unresolved files exist + nodenew = repo.commit(text=commitmsg, user=orig.user(), + date=orig.date(), extra=extra) + finally: + repo.ui.restoreconfig(backup) + return nodenew