diff --git a/hgext/transplant.py b/hgext/transplant.py
index 298c9f346dde7300f99d3806d6b1631dd8d4f71f_aGdleHQvdHJhbnNwbGFudC5weQ==..8c2f1e2a11ff2dd87f920b19f56ca06441fa294a_aGdleHQvdHJhbnNwbGFudC5weQ== 100644
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -568,4 +568,5 @@
         if not heads:
             heads = repo.heads()
         ancestors = []
+        ctx = repo[dest]
         for head in heads:
@@ -571,5 +572,5 @@
         for head in heads:
-            ancestors.append(repo.changelog.ancestor(dest, head))
+            ancestors.append(ctx.ancestor(repo[head]).node())
         for node in repo.changelog.nodesbetween(ancestors, heads)[0]:
             if match(node):
                 yield node