jenkins-bot has submitted this change and it was merged.
Change subject: redirect.py: preserve section anchors when fixing double redirects. ......................................................................
redirect.py: preserve section anchors when fixing double redirects.
Change-Id: I13c7602979edda5016b46e808458037b425d4187 --- M scripts/redirect.py 1 file changed, 11 insertions(+), 1 deletion(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/redirect.py b/scripts/redirect.py index 233cad9..a49ff3c 100755 --- a/scripts/redirect.py +++ b/scripts/redirect.py @@ -561,9 +561,19 @@ except pywikibot.BadTitle: pywikibot.output(u"Bad Title Error") break + oldlink = self.site.redirectRegex().search(oldText).group(1) + if "#" in oldlink and targetPage.section() is None: + sectionlink = oldlink[oldlink.index("#"):] + targetlink = pywikibot.Page( + self.site, + targetPage.title() + sectionlink + ).title(asLink=True, textlink=True) + else: + targetlink = targetPage.title(asLink=True, textlink=True) + text = self.site.redirectRegex().sub( '#%s %s' % (self.site.redirect(True), - targetPage.title(asLink=True, textlink=True)), + targetlink), oldText) if redir.title() == targetPage.title() or text == oldText: pywikibot.output(u"Note: Nothing left to do on %s"