# HG changeset patch # User Yuya Nishihara # Date 2017-04-26 13:03:37 # Node ID ded48ad5514626a319dc11eb5e198abb471f582a # Parent 4462a981e8df8046e4c49aeb02d501cd192607b0 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. diff --git a/contrib/bdiff-torture.py b/contrib/bdiff-torture.py --- a/contrib/bdiff-torture.py +++ b/contrib/bdiff-torture.py @@ -5,7 +5,7 @@ import random import sys from mercurial import ( - bdiff, + mdiff, mpatch, ) @@ -42,7 +42,7 @@ def reducetest(a, b): 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]) diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -26,7 +26,6 @@ import random import sys import time from mercurial import ( - bdiff, changegroup, cmdutil, commands, @@ -812,7 +811,7 @@ def perfbdiff(ui, repo, file_, rev=None, def d(): for pair in textpairs: - bdiff.bdiff(*pair) + mdiff.textdiff(*pair) timer, fm = gettimer(ui, opts) timer(d) diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -20,6 +20,8 @@ from . import ( util, ) +blocks = bdiff.blocks +fixws = bdiff.fixws patches = mpatch.patches patchedsize = mpatch.patchedsize textdiff = bdiff.bdiff diff --git a/mercurial/similar.py b/mercurial/similar.py --- a/mercurial/similar.py +++ b/mercurial/similar.py @@ -9,7 +9,6 @@ from __future__ import absolute_import from .i18n import _ from . import ( - bdiff, mdiff, ) @@ -56,10 +55,10 @@ def _ctxdata(fctx): 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) diff --git a/tests/test-bdiff.py b/tests/test-bdiff.py --- a/tests/test-bdiff.py +++ b/tests/test-bdiff.py @@ -4,7 +4,7 @@ import struct import unittest from mercurial import ( - bdiff, + mdiff, mpatch, ) @@ -16,7 +16,7 @@ class diffreplace( 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 @@ class BdiffTests(unittest.TestCase): 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 @@ class BdiffTests(unittest.TestCase): ("", "", 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)) diff --git a/tests/test-check-code.t b/tests/test-check-code.t --- a/tests/test-check-code.t +++ b/tests/test-check-code.t @@ -9,7 +9,7 @@ New errors are not allowed. Warnings are $ 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) diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t --- a/tests/test-contrib-perf.t +++ b/tests/test-contrib-perf.t @@ -165,7 +165,7 @@ Check perf.py for historical portability $ (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]