Mercurial > hg
comparison hgext/convert/filemap.py @ 13968:82845434e974 stable
convert: make filemap prune useless branch closing revs (issue2774)
A branch closing revision only applies if one of its parents belongs to the
branch being closed. Otherwise the filemap can prune it too.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 20 Apr 2011 23:15:18 +0200 |
parents | 7fefef3ce791 |
children | 2433525a9e1e |
comparison
equal
deleted
inserted
replaced
13963:3c753f9a2fbc | 13968:82845434e974 |
---|---|
207 c = self.commits[rev] = self.base.getcommit(rev) | 207 c = self.commits[rev] = self.base.getcommit(rev) |
208 for p in c.parents: | 208 for p in c.parents: |
209 self.children[p] = self.children.get(p, 0) + 1 | 209 self.children[p] = self.children.get(p, 0) + 1 |
210 return c | 210 return c |
211 | 211 |
212 def _cachedcommit(self, rev): | |
213 if rev in self.commits: | |
214 return self.commits[rev] | |
215 return self.base.getcommit(rev) | |
216 | |
212 def _discard(self, *revs): | 217 def _discard(self, *revs): |
213 for r in revs: | 218 for r in revs: |
214 if r is None: | 219 if r is None: |
215 continue | 220 continue |
216 self.seenchildren[r] = self.seenchildren.get(r, 0) + 1 | 221 self.seenchildren[r] = self.seenchildren.get(r, 0) + 1 |
306 if wp is None and parents: | 311 if wp is None and parents: |
307 wp = 0 | 312 wp = 0 |
308 | 313 |
309 self.origparents[rev] = parents | 314 self.origparents[rev] = parents |
310 | 315 |
311 closed = 'close' in self.commits[rev].extra | 316 closed = False |
317 if 'close' in self.commits[rev].extra: | |
318 # A branch closing revision is only useful if one of its | |
319 # parents belong to the branch being closed | |
320 branch = self.commits[rev].branch | |
321 pbranches = [self._cachedcommit(p).branch for p in mparents] | |
322 if branch in pbranches: | |
323 closed = True | |
312 | 324 |
313 if len(mparents) < 2 and not closed and not self.wanted(rev, wp): | 325 if len(mparents) < 2 and not closed and not self.wanted(rev, wp): |
314 # We don't want this revision. | 326 # We don't want this revision. |
315 # Update our state and tell the convert process to map this | 327 # Update our state and tell the convert process to map this |
316 # revision to the same revision its parent as mapped to. | 328 # revision to the same revision its parent as mapped to. |