meld r1134 - trunk



Author: kaiw
Date: Sat Jan 24 21:50:23 2009
New Revision: 1134
URL: http://svn.gnome.org/viewvc/meld?rev=1134&view=rev

Log:
Refuse to highlight inline differences between very large change blocks

Inline highlighting of differences runs a second comparison between two change
blocks without line breaks. If the first comparison identifies large change
blocks, this can lead to comparison of very long sequences such that meld
appears hung (see for example, Red Hat bugzilla #466894). Since such long
sequences aren't likely to highlight very well anyway, we just give up if the
inline sequences pass some magic constant length.


Modified:
   trunk/filediff.py

Modified: trunk/filediff.py
==============================================================================
--- trunk/filediff.py	(original)
+++ trunk/filediff.py	Sat Jan 24 21:50:23 2009
@@ -705,9 +705,18 @@
                     text1 = struct.unpack("%iH"%(len(text1)/2), text1)[1:]
                     textn = "\n".join( self._get_texts(raw=1)[i*2][c[3]:c[4]] ).encode("utf16")
                     textn = struct.unpack("%iH"%(len(textn)/2), textn)[1:]
+
+                    tags = [b.get_tag_table().lookup("inline line") for b in bufs]
+                    # For very long sequences, bail rather than trying a very slow comparison
+                    inline_limit = 8000 # arbitrary constant
+                    if len(text1) > inline_limit and len(textn) > inline_limit:
+                        ends = [b.get_iter_at_line(l) for b, l in zip(bufs, (c[2], c[4]))]
+                        for i in range(2):
+                            bufs[i].apply_tag(tags[i], starts[i], ends[i])
+                        continue
+
                     matcher = difflib.SequenceMatcher(None, text1, textn)
                     #print "<<<\n%s\n---\n%s\n>>>" % (text1, textn)
-                    tags = [b.get_tag_table().lookup("inline line") for b in bufs]
                     back = (0,0)
                     for o in matcher.get_opcodes():
                         if o[0] == "equal":



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]