context: be even more careful about result order in ancestors() (
issue2642)
The earlier patch could be confused by more complicated topologies.
--- 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