comparison mercurial/hg.py @ 471:4c7f687e4313

Minor annotate performance tweaks -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Minor annotate performance tweaks manifest hash: 2edd508182c7b3dfb2e0b9b90baebdd364cb29f0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCvfQeywK+sNU5EO8RAsYSAJ0R8SuWnyQxVgauoaEuezOe3Taq/wCbBnEs +VG0LNrXnQM9khQyc0+pCeg= =U5gX -----END PGP SIGNATURE-----
author mpm@selenic.com
date Sat, 25 Jun 2005 16:17:34 -0800
parents 58d57594b802
children 520540fd6b64 934279f3ca53
comparison
equal deleted inserted replaced
470:0ab093b473c5 471:4c7f687e4313
48 48
49 def decorate(text, rev): 49 def decorate(text, rev):
50 return ([rev] * len(text.splitlines()), text) 50 return ([rev] * len(text.splitlines()), text)
51 51
52 def pair(parent, child): 52 def pair(parent, child):
53 new = []
54 lb = 0
55 for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]): 53 for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]):
56 new[lb:] = child[0][lb:b1] 54 child[0][b1:b2] = parent[0][a1:a2]
57 new[b1:] = parent[0][a1:a2] 55 return child
58 lb = b2
59 return (new, child[1])
60 56
61 # find all ancestors 57 # find all ancestors
62 needed = {node:1} 58 needed = {node:1}
63 visit = [node] 59 visit = [node]
64 while visit: 60 while visit:
70 else: 66 else:
71 # count how many times we'll use this 67 # count how many times we'll use this
72 needed[p] += 1 68 needed[p] += 1
73 69
74 # sort by revision which is a topological order 70 # sort by revision which is a topological order
75 visit = needed.keys() 71 visit = [ (self.rev(n), n) for n in needed.keys() ]
76 visit = [ (self.rev(n), n) for n in visit ]
77 visit.sort() 72 visit.sort()
78 visit = [ p[1] for p in visit ]
79 hist = {} 73 hist = {}
80 74
81 for n in visit: 75 for r,n in visit:
82 curr = decorate(self.read(n), self.linkrev(n)) 76 curr = decorate(self.read(n), self.linkrev(n))
83 for p in self.parents(n): 77 for p in self.parents(n):
84 if p != nullid: 78 if p != nullid:
85 curr = pair(hist[p], curr) 79 curr = pair(hist[p], curr)
86 # trim the history of unneeded revs 80 # trim the history of unneeded revs