hggtk/history: fix diff hilite error on multi-byte charsets
authorTK Soh <teekaysoh@yahoo.com>
Thu, 24 Apr 2008 15:13:46 +0100
changeset 1136 611be9228485
parent 1135 05bdcfb888f5
child 1137 6bcc04ed89e1
hggtk/history: fix diff hilite error on multi-byte charsets
hggtk/changeset.py
--- a/hggtk/changeset.py	Wed Apr 23 15:21:21 2008 +0100
+++ b/hggtk/changeset.py	Thu Apr 24 15:13:46 2008 +0100
@@ -183,7 +183,7 @@
         offset = eob.get_offset()
         fileoffs, tags, lines, statmax = self.prepare_diff(lines, offset, file)
         for l in lines:
-            buf.insert(eob, toutf(l))
+            buf.insert(eob, l)
 
         # inserts the tags
         for name, p0, p1 in tags:
@@ -375,9 +375,10 @@
                 tags.append( [name, offset, offset+length] )
         stats = [0,0]
         statmax = 0
-        for i,l in enumerate(difflines):
+        for i,l1 in enumerate(difflines):
+            l = toutf(l1)
             if l.startswith("diff"):
-                txt = DIFFHDR % fname
+                txt = toutf(DIFFHDR % fname)
                 addtag( "greybg", offset, len(txt) )
                 outlines.append(txt)
                 markname = "file%d" % idx
@@ -385,7 +386,7 @@
                 statmax = max( statmax, stats[0]+stats[1] )
                 stats = [0,0]
                 filespos.append(( markname, offset, stats ))
-                offset += len(txt)
+                offset += len(txt.decode('utf-8'))
                 continue
             elif l.startswith("+++"):
                 continue
@@ -402,7 +403,7 @@
             else:
                 tag = "black"
             l = l+"\n"
-            length = len(l)
+            length = len(l.decode('utf-8'))
             addtag( tag, offset, length )
             outlines.append( l )
             offset += length