bdiff: proxy through mdiff module
authorYuya Nishihara <yuya@tcha.org>
Wed, 26 Apr 2017 22:03:37 +0900
changeset 32202 ded48ad55146
parent 32201 4462a981e8df
child 32203 0c73634d0570
bdiff: proxy through mdiff module See the previous commit for why. mdiff seems a good place to host bdiff functions. bdiff.bdiff was already aliased as textdiff, so we use it.
contrib/bdiff-torture.py
contrib/perf.py
mercurial/mdiff.py
mercurial/similar.py
tests/test-bdiff.py
tests/test-check-code.t
tests/test-contrib-perf.t
--- a/contrib/bdiff-torture.py	Wed Apr 26 21:56:47 2017 +0900
+++ b/contrib/bdiff-torture.py	Wed Apr 26 22:03:37 2017 +0900
@@ -5,7 +5,7 @@
 import sys
 
 from mercurial import (
-    bdiff,
+    mdiff,
     mpatch,
 )
 
@@ -42,7 +42,7 @@
     sys.exit(0)
 
 def test1(a, b):
-    d = bdiff.bdiff(a, b)
+    d = mdiff.textdiff(a, b)
     if not d:
         raise ValueError("empty")
     c = mpatch.patches(a, [d])
--- a/contrib/perf.py	Wed Apr 26 21:56:47 2017 +0900
+++ b/contrib/perf.py	Wed Apr 26 22:03:37 2017 +0900
@@ -26,7 +26,6 @@
 import sys
 import time
 from mercurial import (
-    bdiff,
     changegroup,
     cmdutil,
     commands,
@@ -812,7 +811,7 @@
 
     def d():
         for pair in textpairs:
-            bdiff.bdiff(*pair)
+            mdiff.textdiff(*pair)
 
     timer, fm = gettimer(ui, opts)
     timer(d)
--- a/mercurial/mdiff.py	Wed Apr 26 21:56:47 2017 +0900
+++ b/mercurial/mdiff.py	Wed Apr 26 22:03:37 2017 +0900
@@ -20,6 +20,8 @@
     util,
 )
 
+blocks = bdiff.blocks
+fixws = bdiff.fixws
 patches = mpatch.patches
 patchedsize = mpatch.patchedsize
 textdiff = bdiff.bdiff
--- a/mercurial/similar.py	Wed Apr 26 21:56:47 2017 +0900
+++ b/mercurial/similar.py	Wed Apr 26 22:03:37 2017 +0900
@@ -9,7 +9,6 @@
 
 from .i18n import _
 from . import (
-    bdiff,
     mdiff,
 )
 
@@ -56,10 +55,10 @@
 def _score(fctx, otherdata):
     orig, lines = otherdata
     text = fctx.data()
-    # bdiff.blocks() returns blocks of matching lines
+    # mdiff.blocks() returns blocks of matching lines
     # count the number of bytes in each
     equal = 0
-    matches = bdiff.blocks(text, orig)
+    matches = mdiff.blocks(text, orig)
     for x1, x2, y1, y2 in matches:
         for line in lines[y1:y2]:
             equal += len(line)
--- a/tests/test-bdiff.py	Wed Apr 26 21:56:47 2017 +0900
+++ b/tests/test-bdiff.py	Wed Apr 26 22:03:37 2017 +0900
@@ -4,7 +4,7 @@
 import unittest
 
 from mercurial import (
-    bdiff,
+    mdiff,
     mpatch,
 )
 
@@ -16,7 +16,7 @@
 class BdiffTests(unittest.TestCase):
 
     def assert_bdiff_applies(self, a, b):
-        d = bdiff.bdiff(a, b)
+        d = mdiff.textdiff(a, b)
         c = a
         if d:
             c = mpatch.patches(a, [d])
@@ -54,7 +54,7 @@
             self.assert_bdiff(a, b)
 
     def showdiff(self, a, b):
-        bin = bdiff.bdiff(a, b)
+        bin = mdiff.textdiff(a, b)
         pos = 0
         q = 0
         actions = []
@@ -110,7 +110,7 @@
             ("", "", 0),
         ]
         for a, b, allws in cases:
-            c = bdiff.fixws(a, allws)
+            c = mdiff.fixws(a, allws)
             self.assertEqual(
                 c, b, 'fixws(%r) want %r got %r (allws=%r)' % (a, b, c, allws))
 
--- a/tests/test-check-code.t	Wed Apr 26 21:56:47 2017 +0900
+++ b/tests/test-check-code.t	Wed Apr 26 22:03:37 2017 +0900
@@ -9,7 +9,7 @@
 
   $ hg locate -X contrib/python-zstandard -X hgext/fsmonitor/pywatchman |
   > sed 's-\\-/-g' | "$check_code" --warnings --per-file=0 - || false
-  contrib/perf.py:869:
+  contrib/perf.py:868:
    >             r.revision(r.node(x))
    don't convert rev to node before passing to revision(nodeorrev)
   Skipping i18n/polib.py it has no-che?k-code (glob)
--- a/tests/test-contrib-perf.t	Wed Apr 26 21:56:47 2017 +0900
+++ b/tests/test-contrib-perf.t	Wed Apr 26 22:03:37 2017 +0900
@@ -165,7 +165,7 @@
   $ (hg files -r 1.2 glob:mercurial/*.c glob:mercurial/*.py;
   >  hg files -r tip glob:mercurial/*.c glob:mercurial/*.py) |
   > "$TESTDIR"/check-perf-code.py contrib/perf.py
-  contrib/perf.py:869:
+  contrib/perf.py:868:
    >             r.revision(r.node(x))
    don't convert rev to node before passing to revision(nodeorrev)
   [1]