Commits

Pierre-Yves David committed 7c8f992

[states] fix a bug with rebase --detach

There is unexpected (for me) content in state.

Comments (0)

Files changed (2)

 def wraprebasebuildstate(orig, repo, *args, **kwargs):
    result = orig(repo, *args, **kwargs)
    if result is not None:
-        revs = result[2]
-        base = repo.changelog.node(min(result[2]))
+        # rebase.nullmerge is issued in the detach case
+        rebase = extensions.find('rebase')
+        rebased = [rev for rev, rbst in result[2].items() if rbst != rebase.nullmerge]
+        base = repo.changelog.node(min(rebased))
         state = repo.nodestate(base)
         if not state.properties & _MUTABLE:
             raise util.Abort(_('can not rebase published changeset %s')

tests/test-published.t

   $ hg ci -m "add babar"
   $ echo "la veille dame" > babar
   $ hg ci -m "add dame"
-  $ hg log --template='{rev}:{node|short}: {state}\n'
-  1:710fe444b3b0: published
-  0:5caa672bac26: published
   $ hg up 0 -q
   $ echo "Rataxes" > rhino
   $ hg add rhino
   $ hg published 1 2
   $ hg up 1 -q
   $ hg states draft
-  $ echo "flore" > babar
-  $ hg ci -m "add daughter"
+  $ echo "avion" > vehicule
+  $ hg add vehicule
+  $ hg ci -m "add some plane"
+  $ hg log --template='{rev}:{node|short}: {state}\n'
+  3:4ee052f12c59: draft
+  2:5468aa9f5c63: published
+  1:710fe444b3b0: published
+  0:5caa672bac26: published
 
 test you can't qimport published changeset
 
 
 test you still can rebase other one
 
-  $ hg rebase --dest 2 -s 3
-  saved backup bundle to $TESTTMP/local/.hg/strip-backup/b7f6698b7ad7-backup.hg
+  $ hg rebase --dest 2 -s 3 --detach
+  saved backup bundle to $TESTTMP/local/.hg/strip-backup/4ee052f12c59-backup.hg
+  $ hg rebase --dest 1 -s 3 
+  saved backup bundle to $TESTTMP/local/.hg/strip-backup/f708bc50a098-backup.hg