mercurial/pure/bdiff.py
changeset 15530 eeac5e179243
parent 14066 14fac6c0536a
child 27335 c4e3ff497f89
--- a/mercurial/pure/bdiff.py	Fri Nov 18 14:16:47 2011 +0100
+++ b/mercurial/pure/bdiff.py	Fri Nov 18 14:23:03 2011 +0100
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import struct, difflib
+import struct, difflib, re
 
 def splitnewlines(text):
     '''like str.splitlines, but only split on newlines.'''
@@ -78,3 +78,10 @@
     d = _normalizeblocks(an, bn, d)
     return [(i, i + n, j, j + n) for (i, j, n) in d]
 
+def fixws(text, allws):
+    if allws:
+        text = re.sub('[ \t\r]+', '', text)
+    else:
+        text = re.sub('[ \t\r]+', ' ', text)
+        text = text.replace(' \n', '\n')
+    return text