[PATCH] amend: preserve phase of amended revision (issue3602)
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Aug 31 14:30:21 CDT 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1346338028 -7200
# Branch stable
# Node ID ce6eb58850a45f6a20cd3cfa6320369cc0f66273
# Parent b0aad9fb87f947e821f0381d461f1794e73833a7
amend: preserve phase of amended revision (issue3602)
New commit from the amend process were created without any phase contraint. If
the amended changeset had a different phase from it's parent, the phases data
were lost.
The changeset ensure the new commit are created in the same phase than the
original changeset.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -10,7 +10,7 @@
import os, sys, errno, re, tempfile
import util, scmutil, templater, patch, error, templatekw, revlog, copies
import match as matchmod
-import subrepo, context, repair, bookmarks, graphmod, revset
+import subrepo, context, repair, bookmarks, graphmod, revset, phases
def parsealiases(cmd):
return cmd.lstrip("^").split("|")
@@ -1668,7 +1668,12 @@
user=user,
date=date,
extra=extra)
- newid = repo.commitctx(new)
+ ph = repo.ui.config('phases', 'new-commit', phases.draft)
+ try:
+ repo.ui.setconfig('phases', 'new-commit', old.phase())
+ newid = repo.commitctx(new)
+ finally:
+ repo.ui.setconfig('phases', 'new-commit', ph)
if newid != old.node():
# Reroute the working copy parent to the new changeset
repo.setparents(newid, nullid)
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -355,3 +355,18 @@
$ hg log -r . --debug | grep extra
extra: branch=a
extra: source=2647734878ef0236dda712fae9c1651cf694ea8a
+
+Preserve phase
+
+ $ hg phase '.^::.'
+ 11: draft
+ 13: draft
+ $ hg phase --secret --force .
+ $ hg phase '.^::.'
+ 11: draft
+ 13: secret
+ $ hg commit --amend -m 'amend for phase' -q
+ $ hg phase '.^::.'
+ 11: draft
+ 13: secret
+
More information about the Mercurial-devel
mailing list