Mercurial > hg > trac > jungle > src > mercurial-plugin
changeset 3:8af21bda2b3e 0.13
#10515: rework the way we retrieve the last change on directories.
Instead of going back through all revisions prior the starting
revision, we only consider its ancestors, staying on the same
branch.
This is not only even faster, but more correct.
author | Christian Boos <christian.boos@free.fr> |
---|---|
date | Sun, 10 Jun 2012 22:41:07 +0200 |
parents | bbb6e28dc488 |
children | f261cc084df2 eeb688e295ab |
files | tracext/hg/backend.py |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/tracext/hg/backend.py Sun Jun 10 00:36:16 2012 +0200 +++ b/tracext/hg/backend.py Sun Jun 10 22:41:07 2012 +0200 @@ -15,6 +15,7 @@ from bisect import bisect from datetime import datetime +from heapq import heappop, heappush import os import time import posixpath @@ -941,8 +942,15 @@ str_dirctxs = {} repo = self.repos.repo max_ctx = repo[max_rev] - for r in xrange(max_rev, -1, -1): + orevs = [-max_rev] + revs = set(orevs) + while orevs: + r = -heappop(orevs) ctx = repo[r] + for p in ctx.parents(): + if p and p.rev() not in revs: + revs.add(p.rev()) + heappush(orevs, -p.rev()) # lookup changes to str_dirnames in current cset for str_file in ctx.files(): for str_dir in str_dirnames[:]: @@ -972,10 +980,7 @@ str_files = str_entries[str_dir] dr = str_dirctxs.get(str_dir, 0) for f in str_files[:k]: - try: - dr = max(dr, max_ctx.filectx(f).linkrev()) - except LookupError: - pass # that file was not on this revision `r` + dr = max(dr, max_ctx.filectx(f).linkrev()) str_files = str_files[k:] if str_files: # not all files for str_dir seen yet,