# HG changeset patch # User Greg Ward # Date 1268187937 18000 # Node ID 432eb853a2c691a1f3fb9968ae53a39e8ecbff7c # Parent 64e286c22f29847dbd923799ad42dfa725c25a93 shrink-revlog: add accounting of suboptimal nodes to the new algorithms. diff -r 64e286c22f29 -r 432eb853a2c6 contrib/shrink-revlog.py --- a/contrib/shrink-revlog.py Tue Mar 09 21:22:01 2010 -0500 +++ b/contrib/shrink-revlog.py Tue Mar 09 21:25:37 2010 -0500 @@ -111,6 +111,7 @@ visit = list(heads) visit.sort(reverse=True) finished = set() + suboptimal = 0 while visit: cur = visit[-1] @@ -119,9 +120,16 @@ visit.append(p) break else: + curparents = rl.parentrevs(cur) + if result and result[-1] != curparents[0]: + suboptimal += 1 + result.append(cur) finished.add(cur) visit.pop() + + ui.note(_('%d suboptimal nodes\n') % suboptimal) + return result def toposort_postorderreverse(ui, rl): @@ -151,6 +159,8 @@ visit = list(roots) visit.sort() finished = set() + suboptimal = 0 + while visit: cur = visit[-1] for p in children[cur]: @@ -158,9 +168,19 @@ visit.append(p) break else: + # if cur is not the first parent of its successor, then the + # successor is a suboptimal node + if result: + succparents = rl.parentrevs(result[-1]) + if succparents[0] != cur: + suboptimal += 1 + result.append(cur) finished.add(cur) visit.pop() + + ui.note(_('%d suboptimal nodes\n') % suboptimal) + result.reverse() return result