view tests/test-bdiff.py.out @ 30429:38ed54888617

bdiff: adjust criteria for getting optimal longest match in the A side middle We prefer matches closer to the middle to balance recursion, as introduced in f1ca249696ed. For ranges with uneven length, matches starting exactly in the middle should have preference. That will be optimal for matches of length 1. We will thus accept equality in the half check. For ranges with even length, half was ceil'ed when calculated but we got the preference for low matches from the 'less than half' check. To get the same result as before when we also accept equality, floor it. Without that, test-annotate.t would show some different (still correct but less optimal) results. This will change the heuristics. Tests shows a slightly different output - and sometimes slightly smaller bundles. The bundle size for 4.0 (hg bundle --base null -r 4.0 x.hg) happens to go from 22804885 to 22803824 bytes - an 0.005% reduction.
author Mads Kiilerich <madski@unity3d.com>
date Tue, 08 Nov 2016 18:37:33 +0100
parents 3743e5dbb824
children 8c0c75aa3ff4
line wrap: on
line source

test 'a\nc\n\n\n\n' 'a\nb\n\n\n'
test 'a\nb\nc\n' 'a\nc\n'
test '' ''
test 'a\nb\nc' 'a\nb\nc'
test 'a\nb\nc\nd\n' 'a\nd\n'
test 'a\nb\nc\nd\n' 'a\nc\ne\n'
test 'a\nb\nc\n' 'a\nc\n'
test 'a\n' 'c\na\nb\n'
test 'a\n' ''
test 'a\n' 'b\nc\n'
test 'a\n' 'c\na\n'
test '' 'adjfkjdjksdhfksj'
test '' 'ab'
test '' 'abc'
test 'a' 'a'
test 'ab' 'ab'
test 'abc' 'abc'
test 'a\n' 'a\n'
test 'a\nb' 'a\nb'
showdiff(
  'x\n\nx\n\nx\n\nx\n\nz\n',
  'x\n\nx\n\ny\n\nx\n\nx\n\nz\n'):
 'x\n\nx\n\n'
 6 6 '' -> 'y\n\n'
 'x\n\nx\n\nz\n'
showdiff(
  'x\n\nx\n\nx\n\nx\n\nz\n',
  'x\n\nx\n\ny\n\nx\n\ny\n\nx\n\nz\n'):
 'x\n\nx\n\n'
 6 6 '' -> 'y\n\n'
 'x\n\n'
 9 9 '' -> 'y\n\n'
 'x\n\nz\n'
showdiff(
  'a\nb\nb\nb\nc\n.\nd\ne\n.\nf\n',
  'a\nb\nb\na\nb\nb\nb\nc\n.\nb\nc\n.\nd\ne\nf\n'):
 0 0 '' -> 'a\nb\nb\n'
 'a\nb\nb\nb\nc\n.\n'
 12 12 '' -> 'b\nc\n.\n'
 'd\ne\n'
 16 18 '.\n' -> ''
 'f\n'
done
done
Odd diff for a trivial change:
showdiff(
  '<0\n-\n<1\n-\n<2\n-\n<3\n-\n<4\n-\n',
  '>0\n-\n>1\n-\n>2\n-\n>3\n-\n>4\n-\n'):
 0 8 '<0\n-\n<1\n' -> '>0\n'
 '-\n'
 10 13 '<2\n' -> '>1\n'
 '-\n'
 15 18 '<3\n' -> '>2\n'
 '-\n'
 20 23 '<4\n' -> '>3\n'
 '-\n'
 25 25 '' -> '>4\n-\n'
Diff 1 to 3 lines - preference for adding / removing at the end of sequences:
showdiff(
  'a\n',
  'a\na\na\n'):
 'a\n'
 2 2 '' -> 'a\na\n'
Diff 1 to 5 lines - preference for adding / removing at the end of sequences:
showdiff(
  'a\n',
  'a\na\na\na\na\n'):
 'a\n'
 2 2 '' -> 'a\na\na\na\n'
Diff 3 to 1 lines - preference for balanced recursion:
showdiff(
  'a\na\na\n',
  'a\n'):
 0 2 'a\n' -> ''
 'a\n'
 4 6 'a\n' -> ''
Diff 5 to 1 lines - preference for balanced recursion:
showdiff(
  'a\na\na\na\na\n',
  'a\n'):
 0 4 'a\na\n' -> ''
 'a\n'
 6 10 'a\na\n' -> ''