changeset 18163:c5bd753c5bc6

amend: allow amend of non-head when obsolete is enabled Obsolescence marker can represent this situation just fine. The old version is marked as precursor of the new changeset. All its descendants become "unstable". If obsolescence is not enabled we keep the current behavior of aborting. This new behavior only applies when obsolete is enabled and is subject to future discussion and changes.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 31 Dec 2012 17:44:18 -0600
parents df1b37c8ae67
children bacf55bd8f90
files mercurial/commands.py tests/test-commit-amend.t
diffstat 2 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Dec 21 22:58:59 2012 +0100
+++ b/mercurial/commands.py	Mon Dec 31 17:44:18 2012 -0600
@@ -1296,7 +1296,7 @@
             raise util.Abort(_('cannot amend merge changesets'))
         if len(repo[None].parents()) > 1:
             raise util.Abort(_('cannot amend while merging'))
-        if old.children():
+        if (not obsolete._enabled) and old.children():
             raise util.Abort(_('cannot amend changeset with children'))
 
         e = cmdutil.commiteditor
--- a/tests/test-commit-amend.t	Fri Dec 21 22:58:59 2012 +0100
+++ b/tests/test-commit-amend.t	Mon Dec 31 17:44:18 2012 -0600
@@ -458,3 +458,23 @@
   $ hg commit --amend
   $ hg id
   b99e5df575f7 (a) tip
+
+Test ui.prevent-unstable
+---------------------------------------------------------------------
+
+  $ hg up '.^'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo 'b' >> a
+  $ hg log --style compact -r 'children(.)'
+  18[tip]:11   b99e5df575f7   1970-01-01 00:00 +0000   test
+    babar
+  
+  $ hg commit --amend
+  $ hg log -r 'unstable()'
+  changeset:   18:b99e5df575f7
+  branch:      a
+  parent:      11:3334b7925910
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     babar
+