changeset 4361:99c853a1408c

add mdiff.get_matching_blocks
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 16 Apr 2007 20:17:39 -0300
parents 10edaed7f909
children 465b9ea02868
files mercurial/mdiff.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/mdiff.py	Mon Apr 16 12:37:30 2007 -0500
+++ b/mercurial/mdiff.py	Mon Apr 16 20:17:39 2007 -0300
@@ -250,6 +250,10 @@
 def patch(a, bin):
     return mpatch.patches(a, [bin])
 
+# similar to difflib.SequenceMatcher.get_matching_blocks
+def get_matching_blocks(a, b):
+    return [(d[0], d[2], d[1] - d[0]) for d in bdiff.blocks(a, b)]
+
 patches = mpatch.patches
 patchedsize = mpatch.patchedsize
 textdiff = bdiff.bdiff