jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/778675 )
Change subject: [bugfix]: Do not delete text when updating a Revision
......................................................................
[bugfix]: Do not delete text when updating a Revision
Do not overwrite existing Revision if it does not add text.
In tests:
- reset cached revisions to keep test uniform for Page and ItemPage;
Page and ItemPage have different side effects on page._revisions,
due to BotMayEdit() implementations, and loadrevisions() does not
necessarily reset Revision in cache.
Bug: T304786
Change-Id: I306291c50127594c6457e61e8d5b70daeead8557
---
M pywikibot/data/api.py
M tests/basepage.py
2 files changed, 8 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 4a89f13..f1b894b 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -3117,7 +3117,13 @@
def _update_revisions(page, revisions) -> None:
"""Update page revisions."""
for rev in revisions:
- page._revisions[rev['revid']] = pywikibot.page.Revision(**rev)
+ revid = rev['revid']
+ revision = pywikibot.page.Revision(**rev)
+ # do not overwrite an existing Revision if there is no content
+ if revid in page._revisions and revision.text is None:
+ pass
+ else:
+ page._revisions[revid] = revision
def _update_templates(page, templates) -> None:
diff --git a/tests/basepage.py b/tests/basepage.py
index 8a3fa70..fcd6bc8 100644
--- a/tests/basepage.py
+++ b/tests/basepage.py
@@ -53,6 +53,7 @@
custom_text = self.custom_text
page.text = custom_text
+ page._revisions = {}
self.site.loadrevisions(page, total=1)
self.assertTrue(hasattr(page, '_revid'))
@@ -66,7 +67,6 @@
self.assertFalse(hasattr(page, '_text'))
self.assertIsNone(page._revisions[page._revid].text)
- self.assertFalse(hasattr(page, '_text'))
self.assertIsNone(page._latest_cached_revision())
page.text = custom_text
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/778675
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I306291c50127594c6457e61e8d5b70daeead8557
Gerrit-Change-Number: 778675
Gerrit-PatchSet: 9
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/778996 )
Change subject: [IMPR] use default -always option instead of -ask
......................................................................
[IMPR] use default -always option instead of -ask
This inverts the behaviour when no option is given
and comes back to the common behaviour for framework scripts
Change-Id: I924b9b13d3c41ed7182ecfb2815fc96416db3940
---
M scripts/dataextend.py
1 file changed, 5 insertions(+), 10 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/dataextend.py b/scripts/dataextend.py
index e75aefe..b8e5acb 100644
--- a/scripts/dataextend.py
+++ b/scripts/dataextend.py
@@ -17,9 +17,8 @@
There is currently one argument defined:
- -ask If this is supplied, the bot will after each external link
- has been handled, show which changes it intends to make, and
- ask for permission.
+-always If this is supplied, the bot will not ask for permission after
+ each external link has been handled.
The bot will load the corresponding pages for these identifiers, and try
to the meaning of that string for the specified type of thing (for
@@ -81,10 +80,6 @@
QRE = re.compile(r'Q\d+$')
PQRE = re.compile(r'[PQ]\d+$')
- avaliable_options = {
- 'ask': False,
- }
-
def __init__(self, **kwargs):
"""Initializer."""
super().__init__(**kwargs)
@@ -761,7 +756,7 @@
if newclaims is None:
failedprops.append(prop)
newclaims = []
- if not self.opt.ask:
+ if self.opt.always:
result = ''
else:
pywikibot.output('Found here:')
@@ -15208,8 +15203,8 @@
item = arg
elif arg.startswith('P') or arg in ('Data', 'Wiki'):
prop = arg
- elif arg == '-ask':
- options['ask'] = True
+ elif arg == '-always':
+ options['always'] = True
else:
unknownarguments.append(arg)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/778996
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I924b9b13d3c41ed7182ecfb2815fc96416db3940
Gerrit-Change-Number: 778996
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged