changeset 17615:9e2dc0d292cd

rebase: ensure rebase does not revive extinct revision Here, we exclude hidden changesets from a rebase operation. If we don't, a rewritten version of the hidden changesets will be created by rebase. Those rewritten versions won't be hidden and will likely conflict with other rewriting or revive pruned changeset. Moreover, rewriting hidden revisions will surprise the user. This change would not be necessary if changelog filtering were already in core. But it's fairly cheap and helps to increase the test-suite for such filtering. Once changelog level filtering is added, hidden changes will be automatically excluded or included according to the global --hidden flags. Plain ignoring them is good enough for now.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 18 Sep 2012 23:32:42 +0200
parents d417986e5e05
children 9535a0dc41f2
files hgext/rebase.py tests/test-rebase-obsolete.t
diffstat 2 files changed, 61 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Sep 18 23:29:05 2012 +0200
+++ b/hgext/rebase.py	Tue Sep 18 23:32:42 2012 +0200
@@ -184,7 +184,8 @@
                 rebaseset = repo.revs(
                     '(children(ancestor(%ld, %d)) and ::(%ld))::',
                     base, dest, base)
-
+            # temporary top level filtering of extinct revisions
+            rebaseset = repo.revs('%ld - hidden()', rebaseset)
             if rebaseset:
                 root = min(rebaseset)
             else:
@@ -193,7 +194,7 @@
             if not rebaseset:
                 repo.ui.debug('base is ancestor of destination\n')
                 result = None
-            elif not keepf and repo.revs('first(children(%ld) - %ld)',
+            elif not keepf and repo.revs('first(children(%ld) - %ld)-hidden()',
                                          rebaseset, rebaseset):
                 raise util.Abort(
                     _("can't remove original changesets with"
--- a/tests/test-rebase-obsolete.t	Tue Sep 18 23:29:05 2012 +0200
+++ b/tests/test-rebase-obsolete.t	Tue Sep 18 23:32:42 2012 +0200
@@ -222,3 +222,61 @@
 
   $ cd ..
 
+Rebase set has hidden descendants
+---------------------------------
+
+We rebase a changeset which has a hidden changeset. The hidden changeset must
+not be rebased.
+
+  $ hg clone base hidden
+  updating to branch default
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd hidden
+  $ hg rebase -s 5fddd98957c8 -d eea13746799a
+  $ hg rebase -s 42ccdea3bb16 -d 02de42196ebe
+  $ hg log -G
+  @  10:7c6027df6a99 B
+  |
+  | o  9:cf44d2f5a9f4 D
+  | |
+  | o  8:e273c5e7d2d2 C
+  | |
+  o |  7:02de42196ebe H
+  | |
+  | o  6:eea13746799a G
+  |/|
+  o |  5:24b6387c8c8c F
+  | |
+  | o  4:9520eea781bc E
+  |/
+  o  0:cd010b8cd998 A
+  
+  $ hg log --hidden -G
+  @  10:7c6027df6a99 B
+  |
+  | o  9:cf44d2f5a9f4 D
+  | |
+  | o  8:e273c5e7d2d2 C
+  | |
+  o |  7:02de42196ebe H
+  | |
+  | o  6:eea13746799a G
+  |/|
+  o |  5:24b6387c8c8c F
+  | |
+  | o  4:9520eea781bc E
+  |/
+  | x  3:32af7686d403 D
+  | |
+  | x  2:5fddd98957c8 C
+  | |
+  | x  1:42ccdea3bb16 B
+  |/
+  o  0:cd010b8cd998 A
+  
+  $ hg debugobsolete
+  5fddd98957c8a54a4d436dfe1da9d87f21a1b97b e273c5e7d2d29df783dce9f9eaa3ac4adc69c15d 0 {'date': '*', 'user': 'test'} (glob)
+  32af7686d403cf45b5d95f2d70cebea587ac806a cf44d2f5a9f4297a62be94cbdd3dff7c7dc54258 0 {'date': '*', 'user': 'test'} (glob)
+  42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 7c6027df6a99d93f461868e5433f63bde20b6dfb 0 {'date': '*', 'user': 'test'} (glob)
+
+  $ cd ..