diff --git a/hgext/shelve.py b/hgext/shelve.py
index c425b678df7c9ebeae2cf8cf982d20add0626700_aGdleHQvc2hlbHZlLnB5..3980b2e061f0f326df7649701f13a4f6b85821c5_aGdleHQvc2hlbHZlLnB5 100644
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -681,7 +681,7 @@
             raise
 
         shelvectx = repo['tip']
-        if not shelvectx in state.pendingctx.children():
+        if state.pendingctx not in shelvectx.parents():
             # rebase was a no-op, so it produced no child commit
             shelvectx = state.pendingctx
         else:
@@ -758,7 +758,7 @@
     # refresh ctx after rebase completes
     shelvectx = repo['tip']
 
-    if not shelvectx in tmpwctx.children():
+    if tmpwctx not in shelvectx.parents():
         # rebase was a no-op, so it produced no child commit
         shelvectx = tmpwctx
     return shelvectx