changeset 17010:a6c64211acdb

transplant: convert applied() algorithm from nodes to revs After a recent switch from revlog.reachable to revlog.ancestors, clean up the code a bit to use revs rather than nodes.
author Joshua Redstone <joshua.redstone@fb.com>
date Fri, 08 Jun 2012 14:21:32 -0700
parents 0c18aed2fcca
children 25f7d40fe735
files hgext/transplant.py
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/transplant.py	Fri Jun 08 08:39:44 2012 -0700
+++ b/hgext/transplant.py	Fri Jun 08 14:21:32 2012 -0700
@@ -89,24 +89,21 @@
 
     def applied(self, repo, node, parent):
         '''returns True if a node is already an ancestor of parent
-        or has already been transplanted'''
+        or is parent or has already been transplanted'''
+        if hasnode(repo, parent):
+            parentrev = repo.changelog.rev(parent)
         if hasnode(repo, node):
-            reachablerevs = repo.changelog.incancestors(
-                [repo.changelog.rev(parent)],
-                stoprev=repo.changelog.rev(node))
-            reachable = (repo.changelog.node(rev) for rev in reachablerevs)
-            if node in reachable:
+            rev = repo.changelog.rev(node)
+            reachable = repo.changelog.incancestors([parentrev], rev)
+            if rev in reachable:
                 return True
         for t in self.transplants.get(node):
             # it might have been stripped
             if not hasnode(repo, t.lnode):
                 self.transplants.remove(t)
                 return False
-            reachablerevs = repo.changelog.incancestors(
-                [repo.changelog.rev(parent)],
-                stoprev=repo.changelog.rev(t.lnode))
-            reachable = (repo.changelog.node(rev) for rev in reachablerevs)
-            if t.lnode in reachable:
+            lnoderev = repo.changelog.rev(t.lnode)
+            if lnoderev in repo.changelog.incancestors([parentrev], lnoderev):
                 return True
         return False