# HG changeset patch # User mpm@selenic.com # Date 1119471284 28800 # Node ID 6aeb4fee51f616aead8e13c9e93c0159c14d3443 # Parent e731d25ddab2d23297c6d85d847d29fe0d27dc65 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----- diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -63,19 +63,16 @@ class filelog(revlog): def annotate(self, node): def decorate(text, rev): - return [(rev, l) for l in text.splitlines(1)] - - def strip(annotation): - return "".join([e[1] for e in annotation]) + return ([rev] * len(text.splitlines()), text) def pair(parent, child): new = [] lb = 0 - for a1, a2, b1, b2 in bdiff.blocks(strip(parent), strip(child)): - new += child[lb:b1] - new += parent[a1:a2] + for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]): + new[lb:] = child[0][lb:b1] + new[b1:] = parent[0][a1:a2] lb = b2 - return new + return (new, child[1]) # find all ancestors needed = {node:1} @@ -108,7 +105,7 @@ class filelog(revlog): del hist[p] hist[n] = curr - return hist[n] + return zip(hist[n][0], hist[n][1].splitlines(1)) class manifest(revlog): def __init__(self, opener):