Commit a81d6f73 authored by Jelmer Vernooij's avatar Jelmer Vernooij

Import upstream version 0.0.4

parents 44a60b65 c438baff
build
patiencediff.egg-info
language: python
sudo: false
cache: pip
python:
- 2.7
- 3.4
- 3.5
- 3.5-dev
- 3.6
- 3.6-dev
- pypy3.3-5.2-alpha1
- pypy3.5
env:
- PYTHONHASHSEED=random
install:
- travis_retry pip install -U pip setuptools
script:
- python -m unittest patiencediff.test_patiencediff
John Arbash Meinel <john@arbash-meinel.com>
Lukáš Lalinský <lalinsky@gmail.com>
Martin Pool <mbp@sourcefrog.net>
Jelmer Vernooij <jelmer@jelmer.uk>
This diff is collapsed.
AUTHORS
README.rst
Metadata-Version: 2.1
Name: patiencediff
Version: 0.0.4
Summary: Python implementation of the patiencediff algorithm.
Home-page: https://www.breezy-vcs.org/
Maintainer: Breezy Developers
Maintainer-email: team@breezy-vcs.org
License: GNU GPLv2 or later
Description: This package contains the implementation of the ``patiencediff`` algorithm, as
`first described <https://bramcohen.livejournal.com/73318.html>`_ by Bram Cohen.
Like Python's ``difflib``, this module provides both a convience ``unified_diff``
function for the generation of unified diffs of text files
as well as a SequenceMatcher that can be used on arbitrary lists.
Patiencediff provides a good balance of performance, nice output for humans,
and implementation simplicity.
The code in this package was extracted from the `Bazaar <https://www.bazaar-vcs.org/>`_
code base.
The package comes with two implementations:
* A Python implementation (_patiencediff_py.py); this implementation only
requires a Python interpreter and is the more readable version of the two
* A C implementation implementation (_patiencediff_c.c); this implementation
is faster, but requires a C compiler and is less readable
Usage
=====
To invoke patiencediff from the command-line::
python -m patiencediff file_a file_b
Or from Python:
>>> import patiencediff
>>> print ''.join(patiencediff.unified_diff(
... ['a\n', 'b\n', 'b\n', 'c\n'],
... ['a\n', 'c\n', 'b\n']))
---
+++
@@ -1,4 +1,3 @@
a
+c
b
-b
-c
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Operating System :: POSIX
Description-Content-Type: text/x-rst
Metadata-Version: 2.1
Name: patiencediff
Version: 0.0.4
Summary: Python implementation of the patiencediff algorithm.
Home-page: https://www.breezy-vcs.org/
Maintainer: Breezy Developers
Maintainer-email: team@breezy-vcs.org
License: GNU GPLv2 or later
Description: This package contains the implementation of the ``patiencediff`` algorithm, as
`first described <https://bramcohen.livejournal.com/73318.html>`_ by Bram Cohen.
Like Python's ``difflib``, this module provides both a convience ``unified_diff``
function for the generation of unified diffs of text files
as well as a SequenceMatcher that can be used on arbitrary lists.
Patiencediff provides a good balance of performance, nice output for humans,
and implementation simplicity.
The code in this package was extracted from the `Bazaar <https://www.bazaar-vcs.org/>`_
code base.
The package comes with two implementations:
* A Python implementation (_patiencediff_py.py); this implementation only
requires a Python interpreter and is the more readable version of the two
* A C implementation implementation (_patiencediff_c.c); this implementation
is faster, but requires a C compiler and is less readable
Usage
=====
To invoke patiencediff from the command-line::
python -m patiencediff file_a file_b
Or from Python:
>>> import patiencediff
>>> print ''.join(patiencediff.unified_diff(
... ['a\n', 'b\n', 'b\n', 'c\n'],
... ['a\n', 'c\n', 'b\n']))
---
+++
@@ -1,4 +1,3 @@
a
+c
b
-b
-c
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Operating System :: POSIX
Description-Content-Type: text/x-rst
MANIFEST.in
README.rst
setup.py
patiencediff/__init__.py
patiencediff/_patiencediff_c.c
patiencediff/_patiencediff_py.py
patiencediff/test_patiencediff.py
patiencediff.egg-info/PKG-INFO
patiencediff.egg-info/SOURCES.txt
patiencediff.egg-info/dependency_links.txt
patiencediff.egg-info/top_level.txt
\ No newline at end of file
......@@ -25,6 +25,8 @@ import difflib
__all__ = ['PatienceSequenceMatcher', 'unified_diff', 'unified_diff_files']
__version__ = (0, 0, 4)
# This is a version of unified_diff which only adds a factory parameter
# so that you can override the default SequenceMatcher
......
......@@ -466,55 +466,67 @@ class TestPatienceDiffLibFiles(unittest.TestCase):
unified_diff_files = patiencediff.unified_diff_files
psm = self._PatienceSequenceMatcher
self.assertEqual(['--- a1\n',
'+++ b1\n',
'@@ -1,3 +1,2 @@\n',
' hello there\n',
'-world\n',
' how are you today?\n',
]
, list(unified_diff_files('a1', 'b1',
sequencematcher=psm)))
old_pwd = os.getcwd()
os.chdir(self.test_dir)
try:
self.assertEqual(['--- a1\n',
'+++ b1\n',
'@@ -1,3 +1,2 @@\n',
' hello there\n',
'-world\n',
' how are you today?\n',
]
, list(unified_diff_files('a1', 'b1',
sequencematcher=psm)))
finally:
os.chdir(old_pwd)
txt_a = [x+'\n' for x in 'abcdefghijklmnop']
txt_b = [x+'\n' for x in 'abcdefxydefghijklmnop']
with open('a2', 'w') as f: f.writelines(txt_a)
with open('b2', 'w') as f: f.writelines(txt_b)
with open(os.path.join(self.test_dir, 'a2'), 'w') as f:
f.writelines(txt_a)
with open(os.path.join(self.test_dir, 'b2'), 'w') as f:
f.writelines(txt_b)
# This is the result with LongestCommonSubstring matching
self.assertEqual(['--- a2\n',
'+++ b2\n',
'@@ -1,6 +1,11 @@\n',
' a\n',
' b\n',
' c\n',
'+d\n',
'+e\n',
'+f\n',
'+x\n',
'+y\n',
' d\n',
' e\n',
' f\n']
, list(unified_diff_files('a2', 'b2')))
# And the patience diff
self.assertEqual(['--- a2\n',
'+++ b2\n',
'@@ -4,6 +4,11 @@\n',
' d\n',
' e\n',
' f\n',
'+x\n',
'+y\n',
'+d\n',
'+e\n',
'+f\n',
' g\n',
' h\n',
' i\n'],
list(unified_diff_files('a2', 'b2',
sequencematcher=psm)))
os.chdir(self.test_dir)
try:
self.assertEqual(['--- a2\n',
'+++ b2\n',
'@@ -1,6 +1,11 @@\n',
' a\n',
' b\n',
' c\n',
'+d\n',
'+e\n',
'+f\n',
'+x\n',
'+y\n',
' d\n',
' e\n',
' f\n']
, list(unified_diff_files('a2', 'b2')))
# And the patience diff
self.assertEqual(['--- a2\n',
'+++ b2\n',
'@@ -4,6 +4,11 @@\n',
' d\n',
' e\n',
' f\n',
'+x\n',
'+y\n',
'+d\n',
'+e\n',
'+f\n',
' g\n',
' h\n',
' i\n'],
list(unified_diff_files('a2', 'b2',
sequencematcher=psm)))
finally:
os.chdir(old_pwd)
class TestPatienceDiffLibFiles_c(TestPatienceDiffLibFiles):
......
[egg_info]
tag_build =
tag_date = 0
......@@ -10,7 +10,7 @@ setup(name="patiencediff",
description="Python implementation of the patiencediff algorithm.",
long_description=long_description,
long_description_content_type='text/x-rst',
version="0.0.3",
version="0.0.4",
maintainer="Breezy Developers",
maintainer_email="team@breezy-vcs.org",
license="GNU GPLv2 or later",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment