changeset 109:95699294f580

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.
author mpm@selenic.com
date Fri, 20 May 2005 17:22:02 -0800
parents 8d55c2d72c7c
children c37c7f784ee3
files mercurial/hg.py
diffstat 1 files changed, 7 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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):