Mercurial > hg
changeset 13481:4eb1e9d6a7c9 stable
context: be even more careful about result order in ancestors() (issue2642)
The earlier patch could be confused by more complicated topologies.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 25 Feb 2011 15:31:32 -0600 |
parents | 69418d4525d1 |
children | 9c5aae633d5f |
files | mercurial/context.py |
diffstat | 1 files changed, 9 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Thu Feb 24 01:14:15 2011 +0530 +++ b/mercurial/context.py Fri Feb 25 15:31:32 2011 -0600 @@ -550,19 +550,15 @@ return None def ancestors(self): - seen = set() - visit = [self] - while visit: - parents = visit.pop(0).parents() - if len(parents) > 1 and parents[1].rev() > parents[0].rev(): - # make sure we return ancestors in reverse revision order - parents = reversed(parents) - for parent in parents: - s = str(parent) - if s not in seen: - visit.append(parent) - seen.add(s) - yield parent + visit = {} + c = self + while True: + for parent in c.parents(): + visit[(parent.rev(), parent.node())] = parent + if not visit: + break + c = visit.pop(max(visit)) + yield c class workingctx(changectx): """A workingctx object makes access to data related to