changeset 17613:aafc521668d8

rebase: properly handle --collapse when creating obsolescence marker In collapse mode, that content of state is not suitable to compute obsolescence markers. We explicitly pass the resulting revision instead and use it as the successors for all elements of the rebased set.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 18 Sep 2012 23:42:27 +0200
parents fc2a6114f0a0
children d417986e5e05
files hgext/rebase.py tests/test-rebase-obsolete.t
diffstat 2 files changed, 60 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Sep 18 23:13:31 2012 +0200
+++ b/hgext/rebase.py	Tue Sep 18 23:42:27 2012 +0200
@@ -310,7 +310,10 @@
                     nstate[repo[k].node()] = repo[v].node()
 
         if not keepf:
-            clearrebased(ui, repo, state)
+            collapsedas = None
+            if collapsef:
+                collapsedas = newrev
+            clearrebased(ui, repo, state, collapsedas)
 
         if currentbookmarks:
             updatebookmarks(repo, nstate, currentbookmarks, **opts)
@@ -656,12 +659,17 @@
         state.update(dict.fromkeys(detachset, nullmerge))
     return repo['.'].rev(), dest.rev(), state
 
-def clearrebased(ui, repo, state):
-    """dispose of rebased revision at the end of the rebase"""
+def clearrebased(ui, repo, state, collapsedas=None):
+    """dispose of rebased revision at the end of the rebase
+
+    If `collapsedas` is not None, the rebase was a collapse whose result if the
+    `collapsedas` node."""
     if obsolete._enabled:
         markers = []
         for rev, newrev in sorted(state.items()):
             if newrev >= 0:
+                if collapsedas is not None:
+                    newrev = collapsedas
                 markers.append((repo[rev], (repo[newrev],)))
         if markers:
             obsolete.createmarkers(repo, markers)
--- a/tests/test-rebase-obsolete.t	Tue Sep 18 23:13:31 2012 +0200
+++ b/tests/test-rebase-obsolete.t	Tue Sep 18 23:42:27 2012 +0200
@@ -173,3 +173,52 @@
 
   $ cd ..
 
+collapse rebase
+---------------------------------
+
+  $ hg clone base collapse
+  updating to branch default
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd collapse
+  $ hg rebase  -s 42ccdea3bb16 -d eea13746799a --collapse
+  $ hg log -G
+  @  8:4dc2197e807b Collapsed revision
+  |
+  | o  7:02de42196ebe H
+  | |
+  o |  6:eea13746799a G
+  |\|
+  | o  5:24b6387c8c8c F
+  | |
+  o |  4:9520eea781bc E
+  |/
+  o  0:cd010b8cd998 A
+  
+  $ hg log --hidden -G
+  @  8:4dc2197e807b Collapsed revision
+  |
+  | 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 id --debug
+  4dc2197e807bae9817f09905b50ab288be2dbbcf tip
+  $ hg debugobsolete
+  42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 4dc2197e807bae9817f09905b50ab288be2dbbcf 0 {'date': '*', 'user': 'test'} (glob)
+  5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 4dc2197e807bae9817f09905b50ab288be2dbbcf 0 {'date': '*', 'user': 'test'} (glob)
+  32af7686d403cf45b5d95f2d70cebea587ac806a 4dc2197e807bae9817f09905b50ab288be2dbbcf 0 {'date': '*', 'user': 'test'} (glob)
+
+  $ cd ..
+