From 6394fb44cc7c6cf599cfa08878efa4e3ae9e785f Mon Sep 17 00:00:00 2001
From: Holger Nahrstaedt <holgernahrstaedt@gmx.de>
Date: Sun, 25 Oct 2020 08:07:54 +0100
Subject: [PATCH] Add diff_match_patch dependency again, as the difflib
 implementation do not work

---
 .travis.yml                 |  2 +-
 CHANGELOG.rst               |  4 ++++
 appveyor.yml                |  2 +-
 beem/utils.py               | 12 ++++++------
 beem/version.py             |  2 +-
 beemapi/version.py          |  2 +-
 beembase/version.py         |  2 +-
 beemgraphenebase/version.py |  2 +-
 docs/requirements.txt       |  1 +
 requirements-test.txt       |  1 +
 setup.py                    |  3 ++-
 11 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 66a11e4d..24d79acc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -58,7 +58,7 @@ before_install:
   - pip install --upgrade wheel
   # Set numpy version first, other packages link against it
   - pip install six nose coverage codecov pytest pytest-cov coveralls codacy-coverage parameterized secp256k1prp cryptography scrypt
-  - pip install pycryptodomex  ruamel.yaml appdirs pylibscrypt tox asn1crypto
+  - pip install pycryptodomex  ruamel.yaml appdirs pylibscrypt tox asn1crypto diff_match_patch
   - pip install ecdsa requests websocket-client pytz six Click prettytable click_shell
 
 script:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 7583dfa7..650eb08b 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,5 +1,9 @@
 Changelog
 =========
+0.24.15
+-------
+* Add diff_match_patch dependency, as the difflib implementation do not work
+
 0.24.14
 -------
 * Add option add_tor to config storage, which allows it to use beempy in tails
diff --git a/appveyor.yml b/appveyor.yml
index e18f6d34..71825690 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -52,7 +52,7 @@ install:
 - cmd: conda install --yes conda-build setuptools pip parameterized cryptography
 - cmd: conda install --yes pycryptodomex ruamel.yaml pytest pytest-mock coverage mock appdirs pylibscrypt pywin32
 - cmd: pip install scrypt -U
-- cmd: conda install --yes ecdsa requests websocket-client pytz six Click prettytable pyinstaller click-shell asn1crypto
+- cmd: conda install --yes ecdsa requests websocket-client pytz six Click prettytable pyinstaller click-shell diff_match_patch asn1crypto
 
 
 build_script:
diff --git a/beem/utils.py b/beem/utils.py
index 48af3ecd..af863475 100644
--- a/beem/utils.py
+++ b/beem/utils.py
@@ -294,12 +294,12 @@ def remove_from_dict(obj, keys=list(), keep_keys=True):
         return {k: v for k, v in items if k not in keys}
 
 
-def make_patch(a, b, n=3):
-    diffs = difflib.unified_diff(a.splitlines(True),b.splitlines(True),n=0)
-    try: _,_ = next(diffs),next(diffs)
-    except StopIteration: pass
-    # diffs = list(diffs); print(diffs)
-    return ''.join([d if d[-1] == '\n' else d+'\n' for d in diffs])
+def make_patch(a, b):
+    import diff_match_patch as dmp_module
+    dmp = dmp_module.diff_match_patch()
+    patch = dmp.patch_make(a, b)
+    patch_text = dmp.patch_toText(patch)   
+    return patch_text
 
 
 def findall_patch_hunks(body=None):
diff --git a/beem/version.py b/beem/version.py
index fb2fa8f9..8406d0b8 100644
--- a/beem/version.py
+++ b/beem/version.py
@@ -1,2 +1,2 @@
 """THIS FILE IS GENERATED FROM beem SETUP.PY."""
-version = '0.24.14'
+version = '0.24.15'
diff --git a/beemapi/version.py b/beemapi/version.py
index fb2fa8f9..8406d0b8 100644
--- a/beemapi/version.py
+++ b/beemapi/version.py
@@ -1,2 +1,2 @@
 """THIS FILE IS GENERATED FROM beem SETUP.PY."""
-version = '0.24.14'
+version = '0.24.15'
diff --git a/beembase/version.py b/beembase/version.py
index fb2fa8f9..8406d0b8 100644
--- a/beembase/version.py
+++ b/beembase/version.py
@@ -1,2 +1,2 @@
 """THIS FILE IS GENERATED FROM beem SETUP.PY."""
-version = '0.24.14'
+version = '0.24.15'
diff --git a/beemgraphenebase/version.py b/beemgraphenebase/version.py
index fb2fa8f9..8406d0b8 100644
--- a/beemgraphenebase/version.py
+++ b/beemgraphenebase/version.py
@@ -1,2 +1,2 @@
 """THIS FILE IS GENERATED FROM beem SETUP.PY."""
-version = '0.24.14'
+version = '0.24.15'
diff --git a/docs/requirements.txt b/docs/requirements.txt
index cb480b03..f5ef49ff 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -7,6 +7,7 @@ pytz
 pycryptodomex>=3.4.6
 scrypt>=0.7.1
 ruamel.yaml
+diff_match_patch
 pytest
 pytest-mock
 coverage
diff --git a/requirements-test.txt b/requirements-test.txt
index ce77d1b8..c20b9428 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -28,4 +28,5 @@ tox
 codacy-coverage
 virtualenv
 codecov
+diff_match_patch
 asn1crypto
\ No newline at end of file
diff --git a/setup.py b/setup.py
index d8ee7485..1ee9de4f 100755
--- a/setup.py
+++ b/setup.py
@@ -16,7 +16,7 @@ except LookupError:
     ascii = codecs.lookup('ascii')
     codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs'))
 
-VERSION = '0.24.14'
+VERSION = '0.24.15'
 
 tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized']
 
@@ -32,6 +32,7 @@ requires = [
     "click_shell",
     "prettytable",
     "ruamel.yaml",
+    "diff_match_patch",
     "asn1crypto"
 ]
 
-- 
GitLab