840 newphases = {} |
840 newphases = {} |
841 def phase(ctx): |
841 def phase(ctx): |
842 return newphases.get(ctx.node(), ctx.phase()) |
842 return newphases.get(ctx.node(), ctx.phase()) |
843 for newnode in allnewnodes: |
843 for newnode in allnewnodes: |
844 ctx = unfi[newnode] |
844 ctx = unfi[newnode] |
|
845 parentphase = max(phase(p) for p in ctx.parents()) |
845 if targetphase is None: |
846 if targetphase is None: |
846 oldphase = max(unfi[oldnode].phase() |
847 oldphase = max(unfi[oldnode].phase() |
847 for oldnode in precursors[newnode]) |
848 for oldnode in precursors[newnode]) |
848 parentphase = max(phase(p) for p in ctx.parents()) |
|
849 newphase = max(oldphase, parentphase) |
849 newphase = max(oldphase, parentphase) |
850 else: |
850 else: |
851 newphase = targetphase |
851 newphase = max(targetphase, parentphase) |
852 newphases[newnode] = newphase |
852 newphases[newnode] = newphase |
853 if newphase > ctx.phase(): |
853 if newphase > ctx.phase(): |
854 toretract.setdefault(newphase, []).append(newnode) |
854 toretract.setdefault(newphase, []).append(newnode) |
855 elif newphase < ctx.phase(): |
855 elif newphase < ctx.phase(): |
856 toadvance.setdefault(newphase, []).append(newnode) |
856 toadvance.setdefault(newphase, []).append(newnode) |