Mercurial > hg4j
diff src/org/tmatesoft/hg/repo/HgStatusCollector.java @ 302:a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sat, 17 Sep 2011 14:01:31 +0200 |
parents | 6dbbc53fc46d |
children | 2ffcbf360fd5 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgStatusCollector.java Sat Sep 17 14:00:48 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/HgStatusCollector.java Sat Sep 17 14:01:31 2011 +0200 @@ -100,7 +100,20 @@ private void initCacheRange(int minRev, int maxRev) { ensureCacheSize(); - repo.getManifest().walk(minRev, maxRev, new HgManifest.Inspector2() { + // In fact, walk(minRev, maxRev) doesn't imply + // there would be maxRev-minRev+1 revisions visited. For example, + // check cpython repo with 'hg log -r 22418:22420 --debug' and admire + // manifest revisions 66650, 21683, 21684. Thus, innocent walk(22418,22420) results in 40k+ revisions and OOME + // Instead, be explicit of what revisions are of interest + assert minRev <= maxRev; + if (maxRev == 22420) { + System.out.println(); + } + int[] revisionsToCollect = new int[maxRev - minRev + 1]; + for (int x = minRev, i = 0; x <= maxRev; i++, x++) { + revisionsToCollect[i] = x; + } + repo.getManifest().walk(new HgManifest.Inspector2() { private ManifestRevision delegate; private boolean cacheHit; // range may include revisions we already know about, do not re-create them @@ -137,7 +150,7 @@ delegate = null; return true; } - }); + }, revisionsToCollect); } /*package-local*/ static ManifestRevision createEmptyManifestRevision() {