##// END OF EJS Templates
cmdutil: extract increasing_windows() from walkchangerevs()...
Patrick Mezard -
r16776:5088d0b9 default
parent child Browse files
Show More
@@ -958,6 +958,20 b' def finddate(ui, repo, date):'
958
958
959 raise util.Abort(_("revision matching date not found"))
959 raise util.Abort(_("revision matching date not found"))
960
960
961 def increasingwindows(start, end, windowsize=8, sizelimit=512):
962 if start < end:
963 while start < end:
964 yield start, min(windowsize, end - start)
965 start += windowsize
966 if windowsize < sizelimit:
967 windowsize *= 2
968 else:
969 while start > end:
970 yield start, min(windowsize, start - end - 1)
971 start -= windowsize
972 if windowsize < sizelimit:
973 windowsize *= 2
974
961 def walkchangerevs(repo, match, opts, prepare):
975 def walkchangerevs(repo, match, opts, prepare):
962 '''Iterate over files and the revs in which they changed.
976 '''Iterate over files and the revs in which they changed.
963
977
@@ -973,20 +987,6 b' def walkchangerevs(repo, match, opts, pr'
973 yielding each context, the iterator will first call the prepare
987 yielding each context, the iterator will first call the prepare
974 function on each context in the window in forward order.'''
988 function on each context in the window in forward order.'''
975
989
976 def increasing_windows(start, end, windowsize=8, sizelimit=512):
977 if start < end:
978 while start < end:
979 yield start, min(windowsize, end - start)
980 start += windowsize
981 if windowsize < sizelimit:
982 windowsize *= 2
983 else:
984 while start > end:
985 yield start, min(windowsize, start - end - 1)
986 start -= windowsize
987 if windowsize < sizelimit:
988 windowsize *= 2
989
990 follow = opts.get('follow') or opts.get('follow_first')
990 follow = opts.get('follow') or opts.get('follow_first')
991
991
992 if not len(repo):
992 if not len(repo):
@@ -1176,7 +1176,7 b' def walkchangerevs(repo, match, opts, pr'
1176 def want(rev):
1176 def want(rev):
1177 return rev in wanted
1177 return rev in wanted
1178
1178
1179 for i, window in increasing_windows(0, len(revs)):
1179 for i, window in increasingwindows(0, len(revs)):
1180 nrevs = [rev for rev in revs[i:i + window] if want(rev)]
1180 nrevs = [rev for rev in revs[i:i + window] if want(rev)]
1181 for rev in sorted(nrevs):
1181 for rev in sorted(nrevs):
1182 fns = fncache.get(rev)
1182 fns = fncache.get(rev)
General Comments 0
You need to be logged in to leave comments. Login now