Show More
@@ -23,6 +23,7 b' from mercurial import (' | |||
|
23 | 23 | patch, |
|
24 | 24 | pycompat, |
|
25 | 25 | registrar, |
|
26 | scmutil, | |
|
26 | 27 | ) |
|
27 | 28 | |
|
28 | 29 | cmdtable = {} |
@@ -98,7 +99,7 b' def countrate(ui, repo, amap, *pats, **o' | |||
|
98 | 99 | exclude_pats=opts[b'exclude'], |
|
99 | 100 | ) |
|
100 | 101 | revs, makefilematcher = logcmdutil.makewalker(repo, wopts) |
|
101 |
for ctx in cm |
|
|
102 | for ctx in scmutil.walkchangerevs(repo, revs, makefilematcher, prep): | |
|
102 | 103 | continue |
|
103 | 104 | |
|
104 | 105 | progress.complete() |
@@ -2240,55 +2240,6 b' def finddate(ui, repo, date):' | |||
|
2240 | 2240 | return b'%d' % rev |
|
2241 | 2241 | |
|
2242 | 2242 | |
|
2243 | def increasingwindows(windowsize=8, sizelimit=512): | |
|
2244 | while True: | |
|
2245 | yield windowsize | |
|
2246 | if windowsize < sizelimit: | |
|
2247 | windowsize *= 2 | |
|
2248 | ||
|
2249 | ||
|
2250 | def walkchangerevs(repo, revs, makefilematcher, prepare): | |
|
2251 | '''Iterate over files and the revs in a "windowed" way. | |
|
2252 | ||
|
2253 | Callers most commonly need to iterate backwards over the history | |
|
2254 | in which they are interested. Doing so has awful (quadratic-looking) | |
|
2255 | performance, so we use iterators in a "windowed" way. | |
|
2256 | ||
|
2257 | We walk a window of revisions in the desired order. Within the | |
|
2258 | window, we first walk forwards to gather data, then in the desired | |
|
2259 | order (usually backwards) to display it. | |
|
2260 | ||
|
2261 | This function returns an iterator yielding contexts. Before | |
|
2262 | yielding each context, the iterator will first call the prepare | |
|
2263 | function on each context in the window in forward order.''' | |
|
2264 | ||
|
2265 | if not revs: | |
|
2266 | return [] | |
|
2267 | change = repo.__getitem__ | |
|
2268 | ||
|
2269 | def iterate(): | |
|
2270 | it = iter(revs) | |
|
2271 | stopiteration = False | |
|
2272 | for windowsize in increasingwindows(): | |
|
2273 | nrevs = [] | |
|
2274 | for i in pycompat.xrange(windowsize): | |
|
2275 | rev = next(it, None) | |
|
2276 | if rev is None: | |
|
2277 | stopiteration = True | |
|
2278 | break | |
|
2279 | nrevs.append(rev) | |
|
2280 | for rev in sorted(nrevs): | |
|
2281 | ctx = change(rev) | |
|
2282 | prepare(ctx, makefilematcher(ctx)) | |
|
2283 | for rev in nrevs: | |
|
2284 | yield change(rev) | |
|
2285 | ||
|
2286 | if stopiteration: | |
|
2287 | break | |
|
2288 | ||
|
2289 | return iterate() | |
|
2290 | ||
|
2291 | ||
|
2292 | 2243 | def add(ui, repo, match, prefix, uipathfn, explicitonly, **opts): |
|
2293 | 2244 | bad = [] |
|
2294 | 2245 |
@@ -3532,7 +3532,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
3532 | 3532 | |
|
3533 | 3533 | ui.pager(b'grep') |
|
3534 | 3534 | fm = ui.formatter(b'grep', opts) |
|
3535 |
for ctx in cm |
|
|
3535 | for ctx in scmutil.walkchangerevs( | |
|
3536 | 3536 | repo, revs, makefilematcher, searcher._prep |
|
3537 | 3537 | ): |
|
3538 | 3538 | rev = ctx.rev() |
@@ -760,6 +760,55 b' def revrange(repo, specs, localalias=Non' | |||
|
760 | 760 | return repo.anyrevs(allspecs, user=True, localalias=localalias) |
|
761 | 761 | |
|
762 | 762 | |
|
763 | def increasingwindows(windowsize=8, sizelimit=512): | |
|
764 | while True: | |
|
765 | yield windowsize | |
|
766 | if windowsize < sizelimit: | |
|
767 | windowsize *= 2 | |
|
768 | ||
|
769 | ||
|
770 | def walkchangerevs(repo, revs, makefilematcher, prepare): | |
|
771 | '''Iterate over files and the revs in a "windowed" way. | |
|
772 | ||
|
773 | Callers most commonly need to iterate backwards over the history | |
|
774 | in which they are interested. Doing so has awful (quadratic-looking) | |
|
775 | performance, so we use iterators in a "windowed" way. | |
|
776 | ||
|
777 | We walk a window of revisions in the desired order. Within the | |
|
778 | window, we first walk forwards to gather data, then in the desired | |
|
779 | order (usually backwards) to display it. | |
|
780 | ||
|
781 | This function returns an iterator yielding contexts. Before | |
|
782 | yielding each context, the iterator will first call the prepare | |
|
783 | function on each context in the window in forward order.''' | |
|
784 | ||
|
785 | if not revs: | |
|
786 | return [] | |
|
787 | change = repo.__getitem__ | |
|
788 | ||
|
789 | def iterate(): | |
|
790 | it = iter(revs) | |
|
791 | stopiteration = False | |
|
792 | for windowsize in increasingwindows(): | |
|
793 | nrevs = [] | |
|
794 | for i in pycompat.xrange(windowsize): | |
|
795 | rev = next(it, None) | |
|
796 | if rev is None: | |
|
797 | stopiteration = True | |
|
798 | break | |
|
799 | nrevs.append(rev) | |
|
800 | for rev in sorted(nrevs): | |
|
801 | ctx = change(rev) | |
|
802 | prepare(ctx, makefilematcher(ctx)) | |
|
803 | for rev in nrevs: | |
|
804 | yield change(rev) | |
|
805 | ||
|
806 | if stopiteration: | |
|
807 | break | |
|
808 | ||
|
809 | return iterate() | |
|
810 | ||
|
811 | ||
|
763 | 812 | def meaningfulparents(repo, ctx): |
|
764 | 813 | """Return list of meaningful (or all if debug) parentrevs for rev. |
|
765 | 814 |
General Comments 0
You need to be logged in to leave comments.
Login now