Mercurial > jhg
comparison 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 |
comparison
equal
deleted
inserted
replaced
301:88c58edc0857 | 302:a7a3395a519e |
---|---|
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 private void initCacheRange(int minRev, int maxRev) { | 101 private void initCacheRange(int minRev, int maxRev) { |
102 ensureCacheSize(); | 102 ensureCacheSize(); |
103 repo.getManifest().walk(minRev, maxRev, new HgManifest.Inspector2() { | 103 // In fact, walk(minRev, maxRev) doesn't imply |
104 // there would be maxRev-minRev+1 revisions visited. For example, | |
105 // check cpython repo with 'hg log -r 22418:22420 --debug' and admire | |
106 // manifest revisions 66650, 21683, 21684. Thus, innocent walk(22418,22420) results in 40k+ revisions and OOME | |
107 // Instead, be explicit of what revisions are of interest | |
108 assert minRev <= maxRev; | |
109 if (maxRev == 22420) { | |
110 System.out.println(); | |
111 } | |
112 int[] revisionsToCollect = new int[maxRev - minRev + 1]; | |
113 for (int x = minRev, i = 0; x <= maxRev; i++, x++) { | |
114 revisionsToCollect[i] = x; | |
115 } | |
116 repo.getManifest().walk(new HgManifest.Inspector2() { | |
104 private ManifestRevision delegate; | 117 private ManifestRevision delegate; |
105 private boolean cacheHit; // range may include revisions we already know about, do not re-create them | 118 private boolean cacheHit; // range may include revisions we already know about, do not re-create them |
106 | 119 |
107 public boolean begin(int manifestRevision, Nodeid nid, int changelogRevision) { | 120 public boolean begin(int manifestRevision, Nodeid nid, int changelogRevision) { |
108 assert delegate == null; | 121 assert delegate == null; |
135 } | 148 } |
136 cacheHit = false; | 149 cacheHit = false; |
137 delegate = null; | 150 delegate = null; |
138 return true; | 151 return true; |
139 } | 152 } |
140 }); | 153 }, revisionsToCollect); |
141 } | 154 } |
142 | 155 |
143 /*package-local*/ static ManifestRevision createEmptyManifestRevision() { | 156 /*package-local*/ static ManifestRevision createEmptyManifestRevision() { |
144 ManifestRevision fakeEmptyRev = new ManifestRevision(null, null); | 157 ManifestRevision fakeEmptyRev = new ManifestRevision(null, null); |
145 fakeEmptyRev.begin(-1, null, -1); | 158 fakeEmptyRev.begin(-1, null, -1); |