In terminal I see
it is difficult to spot the difference, but after the apply in webbrowser it easier:
| vitaly-zdanevich | |
| Fri, Jan 23, 3:35 PM |
| F71610100: image.png | |
| Mon, Jan 26, 1:44 PM |
| F71606157: image.png | |
| Sun, Jan 25, 5:49 PM |
| F71603448: image.png | |
| Sun, Jan 25, 12:49 AM |
| F71598056: image.png | |
| Fri, Jan 23, 5:56 PM |
| F71597614: image.png | |
| Fri, Jan 23, 3:35 PM |
| F71597613: image.png | |
| Fri, Jan 23, 3:35 PM |
In terminal I see
it is difficult to spot the difference, but after the apply in webbrowser it easier:
Implemented locally:
def _git_word_diff(oldtext: str, newtext: str, context: int = 0) -> None:
with tempfile.TemporaryDirectory() as tmp_dir:
old_path = Path(tmp_dir) / 'old.txt'
new_path = Path(tmp_dir) / 'new.txt'
old_path.write_text(oldtext, encoding='utf-8')
new_path.write_text(newtext, encoding='utf-8')
subprocess.run(
[
'git', 'diff', '--no-index',
f'--unified={context}',
'--color=always',
'--color-words=.',
'--',
str(old_path),
str(new_path),
],
check=False,
)
pywikibot.showDiff = _git_word_diffWe cannot assume that git bash is always preinstalled. Pywikibot can be installed from nightly dump or installed as package from pypi.
Change #1231794 had a related patch set uploaded (by Xqt; author: Xqt):
[pywikibot/core@master] IMPR: Improve PatchManager
@vitaly-zdanevich: I've changed the showDiff() behaviour; could you please check it if it looks better now.
CI tests may fail in the current state because the by_letter comparison has a breaking change but this doesn't care a lot because that feature is not used within the framework.
PYTHONPATH=/tmp/core/ ./globustut_fix.py
and my script prints Pywikibot version 11.0.0.dev10
No great ideas yet. Maybe using textlib.extract_sections would be a better approach instead using splitlines.
Change #1232593 had a related patch set uploaded (by Xqt; author: Xqt):
[pywikibot/core@master] textlib: Add textlib.Content.as_list method
Change #1232667 had a related patch set uploaded (by Xqt; author: Xqt):
[pywikibot/core@master] IMPR: Use textlib.extract_sections for showing text differences
But a site parameter must be used with pywikibot.showDiff like:
pywikibot.showDiff(text, new_text, site=page.site)
You are right. A better approach would be to
Change #1233173 had a related patch set uploaded (by Xqt; author: Xqt):
[pywikibot/core@master] textlib: add replace_within helper to replace text only inside tags
url-status= is not changed :(
And space to the new line: would it be possible to use some symbol for that? For example ↵
U+21B5 DOWNWARDS ARROW WITH CORNER LEFTWARDS