[PATCH 1 of 3 V2] amend: allow amend of non-head when obsolete is enabled

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat Dec 29 04:27:21 UTC 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356754640 -3600
# Node ID 84678279bda502d901eff3198553a7158e12b829
# Parent  8019f96ec4ce96f97dde775fe6f45007f29dabc3
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 descendant becomes
"unstable".

If obsolescence is not enabled we keep aborting. This new default behavior only
apply when obsolete is enabled and is subject to future discussion and changes.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1294,11 +1294,11 @@ def commit(ui, repo, *pats, **opts):
             raise util.Abort(_('cannot amend public changesets'))
         if len(old.parents()) > 1:
             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
         if opts.get('force_editor'):
             e = cmdutil.commitforceeditor
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
@@ -456,5 +456,25 @@ Test that amend does not make it easy to
   $ hg revert -ar 14
   reverting a
   $ 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
+  



More information about the Mercurial-devel mailing list