##// 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 self.convertedorder = None
125 self.convertedorder = None
126 self._rebuilt = False
126 self._rebuilt = False
127 self.origparents = {}
127 self.origparents = {}
128 self.children = {}
129 self.seenchildren = {}
128
130
129 def setrevmap(self, revmap, order):
131 def setrevmap(self, revmap, order):
130 # rebuild our state to make things restartable
132 # rebuild our state to make things restartable
@@ -161,19 +163,23 b' class filemap_source(object):'
161 if self._rebuilt:
163 if self._rebuilt:
162 return True
164 return True
163 self._rebuilt = True
165 self._rebuilt = True
164 pmap = self.parentmap.copy()
165 self.parentmap.clear()
166 self.parentmap.clear()
166 self.wantedancestors.clear()
167 self.wantedancestors.clear()
168 self.seenchildren.clear()
167 for rev, wanted, arg in self.convertedorder:
169 for rev, wanted, arg in self.convertedorder:
168 parents = self.origparents.get(rev)
170 if rev not in self.origparents:
169 if parents is None:
171 self.origparents[rev] = self.getcommit(rev).parents
170 parents = self.base.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 if wanted:
177 if wanted:
172 self.mark_wanted(rev, parents)
178 self.mark_wanted(rev, parents)
173 else:
179 else:
174 self.mark_not_wanted(rev, arg)
180 self.mark_not_wanted(rev, arg)
181 self._discard(arg, *parents)
175
182
176 assert pmap == self.parentmap
177 return True
183 return True
178
184
179 def getheads(self):
185 def getheads(self):
@@ -182,8 +188,22 b' class filemap_source(object):'
182 def getcommit(self, rev):
188 def getcommit(self, rev):
183 # We want to save a reference to the commit objects to be able
189 # We want to save a reference to the commit objects to be able
184 # to rewrite their parents later on.
190 # to rewrite their parents later on.
185 self.commits[rev] = self.base.getcommit(rev)
191 c = self.commits[rev] = self.base.getcommit(rev)
186 return self.commits[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 def wanted(self, rev, i):
208 def wanted(self, rev, i):
189 # Return True if we're directly interested in rev.
209 # Return True if we're directly interested in rev.
@@ -281,6 +301,7 b' class filemap_source(object):'
281 p = parents[wp]
301 p = parents[wp]
282 self.mark_not_wanted(rev, p)
302 self.mark_not_wanted(rev, p)
283 self.convertedorder.append((rev, False, p))
303 self.convertedorder.append((rev, False, p))
304 self._discard(*parents)
284 return self.parentmap[rev]
305 return self.parentmap[rev]
285
306
286 # We want this revision.
307 # We want this revision.
@@ -288,6 +309,7 b' class filemap_source(object):'
288 self.commits[rev].parents = mparents
309 self.commits[rev].parents = mparents
289 self.mark_wanted(rev, parents)
310 self.mark_wanted(rev, parents)
290 self.convertedorder.append((rev, True, None))
311 self.convertedorder.append((rev, True, None))
312 self._discard(*parents)
291
313
292 # Get the real changes and do the filtering/mapping.
314 # Get the real changes and do the filtering/mapping.
293 # To be able to get the files later on in getfile and getmode,
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