Mercurial > hg
comparison hgext/transplant.py @ 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 | 5884812686f7 |
comparison
equal
deleted
inserted
replaced
17009:0c18aed2fcca | 17010:a6c64211acdb |
---|---|
87 opener=self.opener) | 87 opener=self.opener) |
88 self.editor = None | 88 self.editor = None |
89 | 89 |
90 def applied(self, repo, node, parent): | 90 def applied(self, repo, node, parent): |
91 '''returns True if a node is already an ancestor of parent | 91 '''returns True if a node is already an ancestor of parent |
92 or has already been transplanted''' | 92 or is parent or has already been transplanted''' |
93 if hasnode(repo, parent): | |
94 parentrev = repo.changelog.rev(parent) | |
93 if hasnode(repo, node): | 95 if hasnode(repo, node): |
94 reachablerevs = repo.changelog.incancestors( | 96 rev = repo.changelog.rev(node) |
95 [repo.changelog.rev(parent)], | 97 reachable = repo.changelog.incancestors([parentrev], rev) |
96 stoprev=repo.changelog.rev(node)) | 98 if rev in reachable: |
97 reachable = (repo.changelog.node(rev) for rev in reachablerevs) | |
98 if node in reachable: | |
99 return True | 99 return True |
100 for t in self.transplants.get(node): | 100 for t in self.transplants.get(node): |
101 # it might have been stripped | 101 # it might have been stripped |
102 if not hasnode(repo, t.lnode): | 102 if not hasnode(repo, t.lnode): |
103 self.transplants.remove(t) | 103 self.transplants.remove(t) |
104 return False | 104 return False |
105 reachablerevs = repo.changelog.incancestors( | 105 lnoderev = repo.changelog.rev(t.lnode) |
106 [repo.changelog.rev(parent)], | 106 if lnoderev in repo.changelog.incancestors([parentrev], lnoderev): |
107 stoprev=repo.changelog.rev(t.lnode)) | |
108 reachable = (repo.changelog.node(rev) for rev in reachablerevs) | |
109 if t.lnode in reachable: | |
110 return True | 107 return True |
111 return False | 108 return False |
112 | 109 |
113 def apply(self, repo, source, revmap, merges, opts={}): | 110 def apply(self, repo, source, revmap, merges, opts={}): |
114 '''apply the revisions in revmap one by one in revision order''' | 111 '''apply the revisions in revmap one by one in revision order''' |