contrib/shrink-revlog.py
changeset 10624 432eb853a2c6
parent 10623 64e286c22f29
child 10625 add562abc28a
--- 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