##// END OF EJS Templates
Add revlog.reachable to find a graph of ancestors for a given rev
mason@suse.com -
r1074:55bf5cfd default
parent child Browse files
Show More
@@ -170,6 +170,28 b' class revlog:'
170 170 def end(self, rev): return self.start(rev) + self.length(rev)
171 171 def base(self, rev): return self.index[rev][2]
172 172
173 def reachable(self, rev, stop=None):
174 reachable = {}
175 visit = [rev]
176 reachable[rev] = 1
177 if stop:
178 stopn = self.rev(stop)
179 else:
180 stopn = 0
181 while visit:
182 n = visit.pop(0)
183 if n == stop:
184 continue
185 if n == nullid:
186 continue
187 for p in self.parents(n):
188 if self.rev(p) < stopn:
189 continue
190 if p not in reachable:
191 reachable[p] = 1
192 visit.append(p)
193 return reachable
194
173 195 def heads(self, stop=None):
174 196 p = {}
175 197 h = []
General Comments 0
You need to be logged in to leave comments. Login now