Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/hg.py @ 436:6aeb4fee51f6
Optimize annotate a bit
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Optimize annotate a bit
Keep the original text around so we don't need to rejoin it
Use slice insert-in-place rather than += to construct new lists
Construct the decorated list with list multiply rather than comprehension
manifest hash: 8c0effb9777750d524d71ad3a2eade3c6ddd579e
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCuca0ywK+sNU5EO8RAtvQAJwOViomGCtlZx/R76i8/CZGvGPqUwCfdybd
nRUv1854GjzCbfygzXfeIes=
=6Q+E
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Wed, 22 Jun 2005 12:14:44 -0800 |
parents | 08f00b6494f4 |
children | e8af362cfb01 |
comparison
equal
deleted
inserted
replaced
435:e731d25ddab2 | 436:6aeb4fee51f6 |
---|---|
61 return self.addrevision(text, transaction, link, p1, p2) | 61 return self.addrevision(text, transaction, link, p1, p2) |
62 | 62 |
63 def annotate(self, node): | 63 def annotate(self, node): |
64 | 64 |
65 def decorate(text, rev): | 65 def decorate(text, rev): |
66 return [(rev, l) for l in text.splitlines(1)] | 66 return ([rev] * len(text.splitlines()), text) |
67 | |
68 def strip(annotation): | |
69 return "".join([e[1] for e in annotation]) | |
70 | 67 |
71 def pair(parent, child): | 68 def pair(parent, child): |
72 new = [] | 69 new = [] |
73 lb = 0 | 70 lb = 0 |
74 for a1, a2, b1, b2 in bdiff.blocks(strip(parent), strip(child)): | 71 for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]): |
75 new += child[lb:b1] | 72 new[lb:] = child[0][lb:b1] |
76 new += parent[a1:a2] | 73 new[b1:] = parent[0][a1:a2] |
77 lb = b2 | 74 lb = b2 |
78 return new | 75 return (new, child[1]) |
79 | 76 |
80 # find all ancestors | 77 # find all ancestors |
81 needed = {node:1} | 78 needed = {node:1} |
82 visit = [node] | 79 visit = [node] |
83 while visit: | 80 while visit: |
106 needed[p] -= 1 | 103 needed[p] -= 1 |
107 if not needed[p]: | 104 if not needed[p]: |
108 del hist[p] | 105 del hist[p] |
109 hist[n] = curr | 106 hist[n] = curr |
110 | 107 |
111 return hist[n] | 108 return zip(hist[n][0], hist[n][1].splitlines(1)) |
112 | 109 |
113 class manifest(revlog): | 110 class manifest(revlog): |
114 def __init__(self, opener): | 111 def __init__(self, opener): |
115 self.mapcache = None | 112 self.mapcache = None |
116 self.listcache = None | 113 self.listcache = None |