Mercurial > hg-stable
changeset 10624:432eb853a2c6
shrink-revlog: add accounting of suboptimal nodes to the new algorithms.
author | Greg Ward <greg-hg@gerg.ca> |
---|---|
date | Tue, 09 Mar 2010 21:25:37 -0500 |
parents | 64e286c22f29 |
children | add562abc28a |
files | contrib/shrink-revlog.py |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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