##// END OF EJS Templates
convert --filemap: reduce memory usage
Alexis S. L. Carvalho -
r5401:4c555dd1 default
parent child Browse files
Show More
@@ -125,6 +125,8 b' class filemap_source(object):'
125 125 self.convertedorder = None
126 126 self._rebuilt = False
127 127 self.origparents = {}
128 self.children = {}
129 self.seenchildren = {}
128 130
129 131 def setrevmap(self, revmap, order):
130 132 # rebuild our state to make things restartable
@@ -161,19 +163,23 b' class filemap_source(object):'
161 163 if self._rebuilt:
162 164 return True
163 165 self._rebuilt = True
164 pmap = self.parentmap.copy()
165 166 self.parentmap.clear()
166 167 self.wantedancestors.clear()
168 self.seenchildren.clear()
167 169 for rev, wanted, arg in self.convertedorder:
168 parents = self.origparents.get(rev)
169 if parents is None:
170 parents = self.base.getcommit(rev).parents
170 if rev not in self.origparents:
171 self.origparents[rev] = self.getcommit(rev).parents
172 if arg is not None:
173 self.children[arg] = self.children.get(arg, 0) + 1
174
175 for rev, wanted, arg in self.convertedorder:
176 parents = self.origparents[rev]
171 177 if wanted:
172 178 self.mark_wanted(rev, parents)
173 179 else:
174 180 self.mark_not_wanted(rev, arg)
181 self._discard(arg, *parents)
175 182
176 assert pmap == self.parentmap
177 183 return True
178 184
179 185 def getheads(self):
@@ -182,8 +188,22 b' class filemap_source(object):'
182 188 def getcommit(self, rev):
183 189 # We want to save a reference to the commit objects to be able
184 190 # to rewrite their parents later on.
185 self.commits[rev] = self.base.getcommit(rev)
186 return self.commits[rev]
191 c = self.commits[rev] = self.base.getcommit(rev)
192 for p in c.parents:
193 self.children[p] = self.children.get(p, 0) + 1
194 return c
195
196 def _discard(self, *revs):
197 for r in revs:
198 if r is None:
199 continue
200 self.seenchildren[r] = self.seenchildren.get(r, 0) + 1
201 if self.seenchildren[r] == self.children[r]:
202 del self.wantedancestors[r]
203 del self.parentmap[r]
204 del self.seenchildren[r]
205 if self._rebuilt:
206 del self.children[r]
187 207
188 208 def wanted(self, rev, i):
189 209 # Return True if we're directly interested in rev.
@@ -281,6 +301,7 b' class filemap_source(object):'
281 301 p = parents[wp]
282 302 self.mark_not_wanted(rev, p)
283 303 self.convertedorder.append((rev, False, p))
304 self._discard(*parents)
284 305 return self.parentmap[rev]
285 306
286 307 # We want this revision.
@@ -288,6 +309,7 b' class filemap_source(object):'
288 309 self.commits[rev].parents = mparents
289 310 self.mark_wanted(rev, parents)
290 311 self.convertedorder.append((rev, True, None))
312 self._discard(*parents)
291 313
292 314 # Get the real changes and do the filtering/mapping.
293 315 # To be able to get the files later on in getfile and getmode,
General Comments 0
You need to be logged in to leave comments. Login now