Mercurial > hg
diff contrib/bdiff-torture.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | e05c141511dd |
children | 6000f5b25c9b |
line wrap: on
line diff
--- a/contrib/bdiff-torture.py Sat Oct 05 10:29:34 2019 -0400 +++ b/contrib/bdiff-torture.py Sun Oct 06 09:45:02 2019 -0400 @@ -9,15 +9,20 @@ pycompat, ) + def reducetest(a, b): tries = 0 reductions = 0 print("reducing...") while tries < 1000: - a2 = "\n".join(l for l in a.splitlines() - if random.randint(0, 100) > 0) + "\n" - b2 = "\n".join(l for l in b.splitlines() - if random.randint(0, 100) > 0) + "\n" + a2 = ( + "\n".join(l for l in a.splitlines() if random.randint(0, 100) > 0) + + "\n" + ) + b2 = ( + "\n".join(l for l in b.splitlines() if random.randint(0, 100) > 0) + + "\n" + ) if a2 == a and b2 == b: continue if a2 == b2: @@ -32,8 +37,7 @@ a = a2 b = b2 - print("reduced:", reductions, len(a) + len(b), - repr(a), repr(b)) + print("reduced:", reductions, len(a) + len(b), repr(a), repr(b)) try: test1(a, b) except Exception as inst: @@ -41,6 +45,7 @@ sys.exit(0) + def test1(a, b): d = mdiff.textdiff(a, b) if not d: @@ -49,6 +54,7 @@ if c != b: raise ValueError("bad") + def testwrap(a, b): try: test1(a, b) @@ -57,10 +63,12 @@ print("exception:", inst) reducetest(a, b) + def test(a, b): testwrap(a, b) testwrap(b, a) + def rndtest(size, noise): a = [] src = " aaaaaaaabbbbccd" @@ -82,6 +90,7 @@ test(a, b) + maxvol = 10000 startsize = 2 while True: