This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Identify Moved Lines with difflib
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: bkiefer, terry.reedy
Priority: normal Keywords:

Created on 2015-03-27 16:25 by bkiefer, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
python_diff_move.zip bkiefer, 2015-03-31 00:15 Basic tests to impliment difflib move feature
Messages (2)
msg239416 - (view) Author: Brian (bkiefer) Date: 2015-03-27 16:25
It would be a helpful feature to incorporate logic into the difflib module to optionally identify and ignore identical, but relocated lines when doing a diff. This would be used when the order of lines in a document is not critical, but rather just the overall content. The Notepad++ Compare plug-in has this feature for reference. 

I would be willing to help submit a patch for this change. The only drawbacks I see using this function is it will either have to increase processing time or increase memory usage.
msg239649 - (view) Author: Brian (bkiefer) Date: 2015-03-31 00:15
I have put together 5 basic tests to implement moved lines in difflib. All diffs should be compared against the 'diffmove_base.txt' file. Below is a short description of each test.

1) Basic reordering of lines
2) Reordering of lines with new lines added
3) Reordering of lines with one line removed
4) Reordering of lines with one character omitted from a line and character added to another line
5) Combination of all previous tests
History
Date User Action Args
2022-04-11 14:58:14adminsetgithub: 67979
2015-04-03 20:16:31terry.reedysetnosy: + terry.reedy
2015-03-31 00:15:49bkiefersetfiles: + python_diff_move.zip

messages: + msg239649
2015-03-27 21:34:21terry.reedysetstage: test needed
versions: - Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.6
2015-03-27 16:25:20bkiefercreate