Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 10262:eb243551cbd8 stable
copies: speed up copy detection
On some large repos, copy detection could spend > 10min using
fctx.ancestor() to determine if file revisions were actually related.
Because ancestor must traverse history to the root to determine the
GCA, it was doing a lot more work than necessary. With this
replacement, same status -r a:b takes ~3 seconds.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 19 Jan 2010 22:20:05 -0600 |
parents | d1043c2ffe6c |
children | 25e572394f5c |
comparison
equal
deleted
inserted
replaced
10261:5eae671c0b57 | 10262:eb243551cbd8 |
---|---|
492 if v: | 492 if v: |
493 f, n = v | 493 f, n = v |
494 return filectx(self._repo, f, fileid=n, filelog=flcache[f]) | 494 return filectx(self._repo, f, fileid=n, filelog=flcache[f]) |
495 | 495 |
496 return None | 496 return None |
497 | |
498 def ancestors(self): | |
499 seen = set(str(self)) | |
500 visit = [self] | |
501 while visit: | |
502 for parent in visit.pop(0).parents(): | |
503 s = str(parent) | |
504 if s not in seen: | |
505 visit.append(parent) | |
506 seen.add(s) | |
507 yield parent | |
497 | 508 |
498 class workingctx(changectx): | 509 class workingctx(changectx): |
499 """A workingctx object makes access to data related to | 510 """A workingctx object makes access to data related to |
500 the current working directory convenient. | 511 the current working directory convenient. |
501 parents - a pair of parent nodeids, or None to use the dirstate. | 512 parents - a pair of parent nodeids, or None to use the dirstate. |