Patchwork [3,of,4] rebase: honor prevent-unstable configuration option

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 28, 2012, 10:44 p.m.
Message ID <7a8371309613a664efd3.1356734696@yamac.lan>
Download mbox | patch
Permalink /patch/322/
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 1356723679 -3600
# Node ID 7a8371309613a664efd3fa6353e67b6659478f4f
# Parent  0a3cc84c25e6b74529c30cb51723921e5edc15c3
rebase: honor prevent-unstable configuration option

If configured properly, `rebase --rev` will works on changeset with children.
Unrebased children become unstable.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -192,12 +192,13 @@  def rebase(ui, repo, **opts):
                 root = None
 
             if not rebaseset:
                 repo.ui.debug('base is ancestor of destination\n')
                 result = None
-            elif not keepf and repo.revs('first(children(%ld) - %ld)-hidden()',
-                                         rebaseset, rebaseset):
+            elif ((not keepf) and obsolete.preventunstable(ui)
+                  and repo.revs('first(children(%ld) - %ld)-hidden()',
+                                rebaseset, rebaseset)):
                 raise util.Abort(
                     _("can't remove original changesets with"
                       " unrebased descendants"),
                     hint=_('use --keep to keep original changesets'))
             elif not keepf and not repo[root].mutable():
diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -277,6 +277,38 @@  not be rebased.
   $ hg debugobsolete
   5fddd98957c8a54a4d436dfe1da9d87f21a1b97b e273c5e7d2d29df783dce9f9eaa3ac4adc69c15d 0 {'date': '*', 'user': 'test'} (glob)
   32af7686d403cf45b5d95f2d70cebea587ac806a cf44d2f5a9f4297a62be94cbdd3dff7c7dc54258 0 {'date': '*', 'user': 'test'} (glob)
   42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 7c6027df6a99d93f461868e5433f63bde20b6dfb 0 {'date': '*', 'user': 'test'} (glob)
 
-  $ cd ..
+Test ui.prevent-unstable option
+------------------------------------
+
+  $ hg rebase -r 8
+  abort: can't remove original changesets with unrebased descendants
+  (use --keep to keep original changesets)
+  [255]
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > prevent-unstable=False
+  > EOF
+  $ hg rebase -r 8
+  $ hg log -G
+  @  11:0d8f238b634c C
+  |
+  o  10:7c6027df6a99 B
+  |
+  | o  9:cf44d2f5a9f4 D
+  | |
+  | x  8:e273c5e7d2d2 C
+  | |
+  o |  7:02de42196ebe H
+  | |
+  | o  6:eea13746799a G
+  |/|
+  o |  5:24b6387c8c8c F
+  | |
+  | o  4:9520eea781bc E
+  |/
+  o  0:cd010b8cd998 A
+  
+
+