Annotate was being too clever trying to work in place, and triggering
authormpm@selenic.com
Fri, 20 May 2005 17:22:02 -0800
changeset 109 95699294f580
parent 108 8d55c2d72c7c
child 110 c37c7f784ee3
Annotate was being too clever trying to work in place, and triggering its assert. Simplify it, fix it, and speed it up a tiny bit.
mercurial/hg.py
--- a/mercurial/hg.py	Fri May 20 17:20:39 2005 -0800
+++ b/mercurial/hg.py	Fri May 20 17:22:02 2005 -0800
@@ -38,22 +38,18 @@
         revs.reverse()
         prev = []
         annotate = []
+        
         for node in revs:
             curr = self.read(node).splitlines(1)
             linkrev = self.linkrev(node)
             sm = SequenceMatcher(None, prev, curr)
-            offset = 0
+            new = []
             for o, m, n, s, t in sm.get_opcodes():
-                if o in ('insert','replace'):
-                    annotate[m+offset:n+offset] = \
-                        [ (linkrev, l) for l in curr[s:t]]
-                    if o == 'insert':
-                        offset += m-n
-                elif o == 'delete':
-                    del annotate[m+offset:n+offset]
-                    offset -= m-n
-            assert len(annotate) == len(curr)
-            prev = curr
+                if o == 'equal':
+                    new += annotate[m:n]
+                else:
+                    new += [(linkrev, l) for l in curr[s:t]]
+            annotate, prev = new, curr
         return annotate
 
 class manifest(revlog):