Mpaa has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/291587

Change subject: Improve diff algorithm
......................................................................

Improve diff algorithm

Use format indication for added lines only once.

Bug: T136511
Change-Id: I608f2c97565abe897404af2ccd33dc59e6a4619d
---
M pywikibot/diff.py
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/87/291587/1

diff --git a/pywikibot/diff.py b/pywikibot/diff.py
index 5c86c5d..6ea3acd 100644
--- a/pywikibot/diff.py
+++ b/pywikibot/diff.py
@@ -125,6 +125,10 @@
                 continue
             if line2.startswith('?'):
                 yield self.color_line(line1, line2)
+                # do not try to reuse line2 as format at next iteration
+                # if already used for an added line.
+                if line1.startswith('+'):
+                    line2 = ''
                 continue
             if line1.startswith('-'):
                 # Color whole line to be removed.

-- 
To view, visit https://gerrit.wikimedia.org/r/291587
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I608f2c97565abe897404af2ccd33dc59e6a4619d
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to