Mercurial > hg > pyhgsh
comparison mercurial/hg.py @ 200:8450c18f2a45
annotate: memory efficiency
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
annotate: memory efficiency
Keep track of how many times a given ancestor is referenced and delete
the annotation information after it's no longer relevant. This tends
to reduce the number of cached revisions to just a couple.
manifest hash: 281e48b67ce310e355bed1615e0f16a643850f56
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCnJjyywK+sNU5EO8RAkZ1AKCugPjkRgwVB+71amZf8H5dLCbNvgCfePIB
4FHI1c9IOEzHUNkYPDGqt+0=
=OnFo
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Tue, 31 May 2005 09:03:46 -0800 |
parents | 2424676edd8c |
children | 0b486b5e0796 |
comparison
equal
deleted
inserted
replaced
199:2424676edd8c | 200:8450c18f2a45 |
---|---|
39 new += parent[m:n] | 39 new += parent[m:n] |
40 else: | 40 else: |
41 new += child[s:t] | 41 new += child[s:t] |
42 return new | 42 return new |
43 | 43 |
44 # find all ancestors | |
44 needed = {} | 45 needed = {} |
45 visit = [node] | 46 visit = [node] |
46 while visit: | 47 while visit: |
47 n = visit.pop(0) | 48 n = visit.pop(0) |
48 for p in self.parents(n): | 49 for p in self.parents(n): |
49 if p not in needed: | 50 if p not in needed: |
50 needed[p] = 1 | 51 needed[p] = 1 |
51 visit.append(p) | 52 visit.append(p) |
52 | 53 else: |
54 # count how many times we'll use this | |
55 needed[p] += 1 | |
56 | |
57 # sort by revision which is a topological order | |
53 visit = needed.keys() | 58 visit = needed.keys() |
54 visit = [ (self.rev(n), n) for n in visit ] | 59 visit = [ (self.rev(n), n) for n in visit ] |
55 visit.sort() | 60 visit.sort() |
56 visit = [ p[1] for p in visit ] | 61 visit = [ p[1] for p in visit ] |
57 hist = {} | 62 hist = {} |
59 for n in visit: | 64 for n in visit: |
60 curr = decorate(self.read(n), self.linkrev(n)) | 65 curr = decorate(self.read(n), self.linkrev(n)) |
61 for p in self.parents(n): | 66 for p in self.parents(n): |
62 if p != nullid: | 67 if p != nullid: |
63 curr = pair(hist[p], curr) | 68 curr = pair(hist[p], curr) |
69 # trim the history of unneeded revs | |
70 needed[p] -= 1 | |
71 if not needed[p]: | |
72 del hist[p] | |
64 hist[n] = curr | 73 hist[n] = curr |
65 | 74 |
66 return hist[n] | 75 return hist[n] |
67 | 76 |
68 class manifest(revlog): | 77 class manifest(revlog): |