[PATCH 5 of 5] rebase: ensure rebase does not revive extinct revision

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Sep 18 16:49:17 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1348003962 -7200
# Node ID 10767a3a96e0b533e24e7bfd1be1fb50be4bf2e6
# Parent  411341243b68756b81ff10f3f1333e7da682e4d0
rebase: ensure rebase does not revive extinct revision

This changesets exclude hidden changeset from rebase operation. If we dont,
rewritten version of hidden changeset will be created by rebase. Those rewritten
version won't be hidden and will likely conflict with other rewriting or revive
pruned changeset. Moreover rewriting hidden revision will surprise the user who
did not expected them.

This changes 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.

When changelog level filtering will be up, hidden changelog will be
automatically excluded or included according the global --hidden flags. Plain
ignoring them is good enough for now.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -184,7 +184,8 @@
                 rebaseset = repo.revs(
                     '(children(ancestor(%ld, %d)) and ::(%ld))::',
                     base, dest, base)
-
+            # temporary top level filtering of extinct revision
+            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"
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
@@ -222,3 +222,61 @@
 
   $ cd ..
 
+Rebase set have hidden descendant
+---------------------------------
+
+We rebase a changeset which have hidden changeset. Those 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 ..


More information about the Mercurial-devel mailing list