##// END OF EJS Templates
shrink-revlog: add accounting of suboptimal nodes to the new algorithms.
Greg Ward -
r10624:432eb853 default
parent child Browse files
Show More
@@ -111,6 +111,7 b' def toposort_reversepostorder(ui, rl):'
111 111 visit = list(heads)
112 112 visit.sort(reverse=True)
113 113 finished = set()
114 suboptimal = 0
114 115
115 116 while visit:
116 117 cur = visit[-1]
@@ -119,9 +120,16 b' def toposort_reversepostorder(ui, rl):'
119 120 visit.append(p)
120 121 break
121 122 else:
123 curparents = rl.parentrevs(cur)
124 if result and result[-1] != curparents[0]:
125 suboptimal += 1
126
122 127 result.append(cur)
123 128 finished.add(cur)
124 129 visit.pop()
130
131 ui.note(_('%d suboptimal nodes\n') % suboptimal)
132
125 133 return result
126 134
127 135 def toposort_postorderreverse(ui, rl):
@@ -151,6 +159,8 b' def toposort_postorderreverse(ui, rl):'
151 159 visit = list(roots)
152 160 visit.sort()
153 161 finished = set()
162 suboptimal = 0
163
154 164 while visit:
155 165 cur = visit[-1]
156 166 for p in children[cur]:
@@ -158,9 +168,19 b' def toposort_postorderreverse(ui, rl):'
158 168 visit.append(p)
159 169 break
160 170 else:
171 # if cur is not the first parent of its successor, then the
172 # successor is a suboptimal node
173 if result:
174 succparents = rl.parentrevs(result[-1])
175 if succparents[0] != cur:
176 suboptimal += 1
177
161 178 result.append(cur)
162 179 finished.add(cur)
163 180 visit.pop()
181
182 ui.note(_('%d suboptimal nodes\n') % suboptimal)
183
164 184 result.reverse()
165 185 return result
166 186
General Comments 0
You need to be logged in to leave comments. Login now