diff hgext/histedit.py @ 18440:35513c59f376

histedit: proper phase conservation (issue3724) Before this changeset, histedit created all new changesets according phases.new-commit option without any regards for the phases of the original changesets. This changeset fix that using the phase of rewritten changeset to decide the phase of the resulting changeset. In case of reordering or folding, we keep secret item secret as it seems the safer path. temporary commit creation are not affected. They are head only and stripped at the end of the histedit. As for the resolution of issue3681 (obsolescence cycle prevention), we do not handle changesets created by edit command.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Wed, 16 Jan 2013 19:21:03 +0100
parents 358c23e8f1c6
children c795c9f87792
line wrap: on
line diff
--- a/hgext/histedit.py	Wed Jan 16 19:19:56 2013 +0100
+++ b/hgext/histedit.py	Wed Jan 16 19:21:03 2013 +0100
@@ -186,11 +186,17 @@
     Note that fold have its own separated logic because its handling is a bit
     different and not easily factored out of the fold method.
     """
+    phasemin = src.phase()
     def commitfunc(**kwargs):
-        extra = kwargs.get('extra', {}).copy()
-        extra['histedit_source'] = src.hex()
-        kwargs['extra'] = extra
-        return repo.commit(**kwargs)
+        phasebackup = repo.ui.backupconfig('phases', 'new-commit')
+        try:
+            repo.ui.setconfig('phases', 'new-commit', phasemin)
+            extra = kwargs.get('extra', {}).copy()
+            extra['histedit_source'] = src.hex()
+            kwargs['extra'] = extra
+            return repo.commit(**kwargs)
+        finally:
+            repo.ui.restoreconfig(phasebackup)
     return commitfunc
 
 
@@ -357,7 +363,13 @@
     #       This is sufficient to solve issue3681 anyway
     extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex())
     commitopts['extra'] = extra
-    n = collapse(repo, ctx, repo[newnode], commitopts)
+    phasebackup = repo.ui.backupconfig('phases', 'new-commit')
+    try:
+        phasemin = max(ctx.phase(), oldctx.phase())
+        repo.ui.setconfig('phases', 'new-commit', phasemin)
+        n = collapse(repo, ctx, repo[newnode], commitopts)
+    finally:
+        repo.ui.restoreconfig(phasebackup)
     if n is None:
         return ctx, []
     hg.update(repo, n)