##// END OF EJS Templates
cmdutil: implemented new lazy increasingwindows...
Lucas Moscovicz -
r20553:86cefb15 default
parent child Browse files
Show More
@@ -1133,17 +1133,9 def finddate(ui, repo, date):
1133 1133
1134 1134 raise util.Abort(_("revision matching date not found"))
1135 1135
1136 def increasingwindows(start, end, windowsize=8, sizelimit=512):
1137 if start < end:
1138 while start < end:
1139 yield start, min(windowsize, end - start)
1140 start += windowsize
1141 if windowsize < sizelimit:
1142 windowsize *= 2
1143 else:
1144 while start > end:
1145 yield start, min(windowsize, start - end - 1)
1146 start -= windowsize
1136 def increasingwindows(windowsize=8, sizelimit=512):
1137 while True:
1138 yield windowsize
1147 1139 if windowsize < sizelimit:
1148 1140 windowsize *= 2
1149 1141
@@ -1278,7 +1270,6 def walkchangerevs(repo, match, opts, pr
1278 1270 slowpath = match.anypats() or (match.files() and opts.get('removed'))
1279 1271 fncache = {}
1280 1272 change = repo.changectx
1281 revs = revset.baseset(revs)
1282 1273
1283 1274 # First step is to fill wanted, the set of revisions that we want to yield.
1284 1275 # When it does not induce extra cost, we also fill fncache for revisions in
@@ -1287,7 +1278,7 def walkchangerevs(repo, match, opts, pr
1287 1278
1288 1279 if not slowpath and not match.files():
1289 1280 # No files, no patterns. Display all revs.
1290 wanted = set(revs)
1281 wanted = revs
1291 1282
1292 1283 if not slowpath and match.files():
1293 1284 # We only have to read through the filelog to find wanted revisions
@@ -1389,14 +1380,7 def walkchangerevs(repo, match, opts, pr
1389 1380 stop = min(revs[0], revs[-1])
1390 1381 for x in xrange(rev, stop - 1, -1):
1391 1382 if ff.match(x):
1392 wanted.discard(x)
1393
1394 # Choose a small initial window if we will probably only visit a
1395 # few commits.
1396 limit = loglimit(opts)
1397 windowsize = 8
1398 if limit:
1399 windowsize = min(limit, windowsize)
1383 wanted = wanted - [x]
1400 1384
1401 1385 # Now that wanted is correctly initialized, we can iterate over the
1402 1386 # revision range, yielding only revisions in wanted.
@@ -1409,8 +1393,18 def walkchangerevs(repo, match, opts, pr
1409 1393 def want(rev):
1410 1394 return rev in wanted
1411 1395
1412 for i, window in increasingwindows(0, len(revs), windowsize):
1413 nrevs = [rev for rev in revs[i:i + window] if want(rev)]
1396 it = iter(revs)
1397 stopiteration = False
1398 for windowsize in increasingwindows():
1399 nrevs = []
1400 for i in xrange(windowsize):
1401 try:
1402 rev = it.next()
1403 if want(rev):
1404 nrevs.append(rev)
1405 except (StopIteration):
1406 stopiteration = True
1407 break
1414 1408 for rev in sorted(nrevs):
1415 1409 fns = fncache.get(rev)
1416 1410 ctx = change(rev)
@@ -1423,6 +1417,10 def walkchangerevs(repo, match, opts, pr
1423 1417 prepare(ctx, fns)
1424 1418 for rev in nrevs:
1425 1419 yield change(rev)
1420
1421 if stopiteration:
1422 break
1423
1426 1424 return iterate()
1427 1425
1428 1426 def _makegraphfilematcher(repo, pats, followfirst):
General Comments 0
You need to be logged in to leave comments. Login now