Patchwork [2,of,4] amend: honor prevent-unstable configuration option

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 28, 2012, 10:44 p.m.
Message ID <0a3cc84c25e6b74529c3.1356734695@yamac.lan>
Download mbox | patch
Permalink /patch/321/
State Superseded, archived
Headers show

Comments

Pierre-Yves David - Dec. 28, 2012, 10:44 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356723214 -3600
# Node ID 0a3cc84c25e6b74529c30cb51723921e5edc15c3
# Parent  84a2e3e8a7123f6d2593a4c78cca4399d77538b8
amend: honor prevent-unstable configuration option

If configured properly, commit --amend will works on changeset with children.
Existing children become unstable.

Patch

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 obsolete.preventunstable(ui) 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,28 @@  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 commit --amend
+  abort: cannot amend changeset with children
+  [255]
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > prevent-unstable=False
+  > EOF
+  $ 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
+