Mercurial > public > mercurial-scm > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/context.py Mon Dec 28 12:14:26 2009 +0900 +++ b/mercurial/context.py Tue Jan 19 22:20:05 2010 -0600 @@ -495,6 +495,17 @@ return None + def ancestors(self): + seen = set(str(self)) + visit = [self] + while visit: + for parent in visit.pop(0).parents(): + s = str(parent) + if s not in seen: + visit.append(parent) + seen.add(s) + yield parent + class workingctx(changectx): """A workingctx object makes access to data related to the current working directory convenient.