diff mercurial/hg.py @ 98:3dde7c87e36d

Add paranoia to diff code
author mpm@selenic.com
date Wed, 18 May 2005 16:59:54 -0800
parents fce47326677c
children 707a7481a861
line wrap: on
line diff
--- a/mercurial/hg.py	Wed May 18 16:47:49 2005 -0800
+++ b/mercurial/hg.py	Wed May 18 16:59:54 2005 -0800
@@ -78,7 +78,11 @@
     def diff(self, a, b):
         # this is sneaky, as we're not actually using a and b
         if self.listcache and len(self.listcache[0]) == len(a):
-            return mdiff.diff(self.listcache[1], self.addlist, 1)
+            d = mdiff.diff(self.listcache[1], self.addlist, 1)
+            if mdiff.patch(a, d) != b:
+                sys.stderr.write("*** sortdiff failed, falling back ***\n")
+                return mdiff.textdiff(a, b)
+            return d
         else:
             return mdiff.textdiff(a, b)