[states] fix a bug with rebase --detach
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 13 Sep 2011 00:58:18 +0200
changeset 65 7c8f992d567e
parent 64 6a7dc5ca05b8
child 66 b1e64d8783f0
[states] fix a bug with rebase --detach There is unexpected (for me) content in state.
hgext/states.py
tests/test-published.t
--- a/hgext/states.py	Tue Sep 13 00:45:42 2011 +0200
+++ b/hgext/states.py	Tue Sep 13 00:58:18 2011 +0200
@@ -648,8 +648,10 @@
 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')
--- a/tests/test-published.t	Tue Sep 13 00:45:42 2011 +0200
+++ b/tests/test-published.t	Tue Sep 13 00:58:18 2011 +0200
@@ -19,9 +19,6 @@
   $ 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
@@ -30,8 +27,14 @@
   $ 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
 
@@ -54,6 +57,8 @@
 
 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