jenkins-bot has submitted this change and it was merged.
Change subject: [BREAKING] Change default behavior of set_redirect_target
......................................................................
[BREAKING] Change default behavior of set_redirect_target
Now there is another argument named 'save' and default is true.
If it's false, it doesn't save the page but when it's true, it saves page
immediately.
Any usage of this method which doesn't determine any additional
argument would change their behavior and saves immediately instead of
just changing the page.text.
It is useful since most of the time, we don't need more changes after
creating or changing a redirect page.
Change-Id: Iaadfa03d6ef7a8252ff4df7fc5281e222642ebc3
---
M pywikibot/page.py
M scripts/redirect.py
2 files changed, 7 insertions(+), 8 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
Ladsgroup: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index e089fc2..0136a32 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1946,15 +1946,12 @@
return result
def set_redirect_target(self, target_page, create=False, force=False,
- keep_section=False, **kwargs):
+ keep_section=False, save=True, **kwargs):
"""
Change the page's text to point to the redirect page.
@param target_page: target of the redirect, this argument is required.
@type target_page: pywikibot.Page or string
- @param summary: The edit summary which must be set if the page should
- be saved too. If omitted the page won't be saved.
- @type summary: string
@param create: if true, it creates the redirect even if the page
doesn't exist.
@type create: bool
@@ -1964,8 +1961,10 @@
@param keep_section: if the old redirect links to a section
and the new one doesn't it uses the old redirect's section.
@type keep_section: bool
+ @param save: if true, it saves the page immediately.
+ @type save: bool
@param kwargs: Arguments which are used for saving the page directly
- afterwards. If none are provided the page isn't saved.
+ afterwards, like 'summary' for edit summary.
"""
if isinstance(target_page, basestring):
target_page = pywikibot.Page(self.site, target_page)
@@ -1999,7 +1998,7 @@
allowInterwiki=False)
target_link = u'#{0} {1}'.format(self.site.redirect(), target_link)
self.text = prefix + target_link + suffix
- if kwargs:
+ if save:
self.save(**kwargs)
diff --git a/scripts/redirect.py b/scripts/redirect.py
index ec99198..2dcaa34 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -456,7 +456,7 @@
asLink=True)})
content = redir_page.get(get_redirect=True)
redir_page.set_redirect_target(
- movedTarget, keep_section=True)
+ movedTarget, keep_section=True, save=False)
pywikibot.showDiff(content, redir_page.text)
pywikibot.output(u'Summary - %s' % reason)
if self.user_confirm(
@@ -640,7 +640,7 @@
except pywikibot.BadTitle:
pywikibot.output(u"Bad Title Error")
break
- redir.set_redirect_target(targetPage, keep_section=True)
+ redir.set_redirect_target(targetPage, keep_section=True, save=False)
summary = i18n.twtranslate(self.site, 'redirect-fix-double',
{'to': targetPage.title(asLink=True)}
)
--
To view, visit
https://gerrit.wikimedia.org/r/206081
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaadfa03d6ef7a8252ff4df7fc5281e222642ebc3
Gerrit-PatchSet: 10
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>