# HG changeset patch # User Sean Farley # Date 1376280350 18000 # Node ID 0670422d58c6b08a755fdf3f080d9d089b4e91a6 # Parent 4e72ffec8c2d3d55a480c116d7263e2a8c464fae basefilectx: move ancestors from filectx diff -r 4e72ffec8c2d -r 0670422d58c6 mercurial/context.py --- a/mercurial/context.py Sun Aug 11 23:05:08 2013 -0500 +++ b/mercurial/context.py Sun Aug 11 23:05:50 2013 -0500 @@ -710,6 +710,18 @@ return None + def ancestors(self, followfirst=False): + visit = {} + c = self + cut = followfirst and 1 or None + while True: + for parent in c.parents()[:cut]: + visit[(parent.rev(), parent.node())] = parent + if not visit: + break + c = visit.pop(max(visit)) + yield c + class filectx(basefilectx): """A filecontext object makes access to data related to a particular filerevision convenient.""" @@ -801,18 +813,6 @@ return [filectx(self._repo, self._path, fileid=x, filelog=self._filelog) for x in c] - def ancestors(self, followfirst=False): - visit = {} - c = self - cut = followfirst and 1 or None - while True: - for parent in c.parents()[:cut]: - visit[(parent.rev(), parent.node())] = parent - if not visit: - break - c = visit.pop(max(visit)) - yield c - def copies(self, c2): if not util.safehasattr(self, "_copycache"): self._copycache = {}