jenkins-bot has submitted this change and it was merged.
Change subject: Don't duplicate category names in CFD move edit summaries
......................................................................
Don't duplicate category names in CFD move edit summaries
The built-in category moving functionality that MediaWiki now has
already includes links to the relevant categories by default, so it
no longer makes sense to use the same edit summary from the page
edits (which do need to link to the category pages).
Bug: T135298
Change-Id: I03e8975d00221a5d53b78b73149f6e830bd66eec
---
M scripts/category.py
M scripts/cfd.py
2 files changed, 25 insertions(+), 13 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/category.py b/scripts/category.py
index b3281e0..2a9cae0 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -414,6 +414,7 @@
inplace=False, move_oldcat=True, delete_oldcat=True,
title_regex=None, history=False, pagesonly=False,
deletion_comment=DELETION_COMMENT_AUTOMATIC,
+ move_comment=None,
wikibase=True, allow_split=False, move_together=False,
keep_sortkey=None):
"""Store all given parameters in the objects attributes.
@@ -421,8 +422,8 @@
@param oldcat: The move source.
@param newcat: The move target.
@param batch: If True the user has not to confirm the deletion.
- @param comment: The edit summary for all pages where the
- category is changed.
+ @param comment: The edit summary for all pages where the category is
+ changed, and also for moves and deletions if not overridden.
@param inplace: If True the categories are not reordered.
@param move_oldcat: If True the category page (and talkpage) is
copied to the new category.
@@ -436,9 +437,12 @@
@param deletion_comment: Either string or special value:
DELETION_COMMENT_AUTOMATIC: use a generated message,
DELETION_COMMENT_SAME_AS_EDIT_COMMENT: use the same message for
- delete that is also used for move.
- If the value is not recognized, it's interpreted as
- DELETION_COMMENT_AUTOMATIC.
+ delete that is used for the edit summary of the pages whose
+ category was changed (see the comment param above). If the value
+ is not recognized, it's interpreted as DELETION_COMMENT_AUTOMATIC.
+ @param move_comment: If set, uses this as the edit summary on the
+ actual move of the category page. Otherwise, defaults to the value
+ of the comment parameter.
@param wikibase: If True, update the Wikibase item of the
old category.
@param allow_split: If False only moves page and talk page together.
@@ -513,6 +517,7 @@
# Category is deleted.
self.deletion_comment = i18n.twtranslate(self.site,
'category-was-disbanded')
+ self.move_comment = move_comment if move_comment else self.comment
def run(self):
"""The main bot function that does all the work.
@@ -545,7 +550,7 @@
old_cat_title = self.oldcat.title()
old_cat_text = self.oldcat.text
self.newcat = self.oldcat.move(self.newcat.title(),
- reason=self.comment,
+ reason=self.move_comment,
movetalkpage=can_move_talk)
# Copy over the article text so it can be stripped of
# CFD templates and re-saved. This is faster than
diff --git a/scripts/cfd.py b/scripts/cfd.py
index 4655b57..b301919 100755
--- a/scripts/cfd.py
+++ b/scripts/cfd.py
@@ -90,9 +90,10 @@
page = pywikibot.Page(pywikibot.Site(), cfdPage)
# Variable declarations
- day = "None"
- mode = "None"
- summary = ""
+ day = 'None'
+ mode = 'None'
+ summary = ''
+ action_summary = ''
robot = None
m = ReCheck()
@@ -130,26 +131,30 @@
summary = (
'Robot - Moving category ' + src + ' to [[:Category:' +
dest + ']] per [[WP:CFD|CFD]] at ' + thisDay + '.')
+ action_summary = 'Robot - Result of [[WP:CFD|CFD]] at ' + thisDay + '.'
elif mode == "Speedy":
summary = (
'Robot - Speedily moving category ' + src +
' to [[:Category:' + dest + ']] per [[WP:CFDS|CFDS]].')
+ action_summary = 'Robot - Speedily moved per [[WP:CFDS|CFDS]].'
else:
continue
# If the category is redirect, we do NOT want to move articles to
# it. The safest thing to do here is abort and wait for human
# intervention.
- destpage = pywikibot.Page(
- pywikibot.Site(), dest, ns=14)
+ destpage = pywikibot.Page(page.site, dest, ns=14)
if destpage.isCategoryRedirect():
summary = 'CANCELED. Destination is redirect: ' + summary
pywikibot.stdout(summary)
robot = None
else:
+ deletion_comment_same = (
+ CategoryMoveBot.DELETION_COMMENT_SAME_AS_EDIT_COMMENT)
robot = CategoryMoveBot(oldcat=src, newcat=dest, batch=True,
comment=summary, inplace=True,
move_oldcat=True, delete_oldcat=True,
- deletion_comment=True)
+ deletion_comment=deletion_comment_same,
+ move_comment=action_summary)
elif m.check(deletecat, line):
src = m.result.group(1)
# I currently don't see any reason to handle these two cases
@@ -161,10 +166,12 @@
summary = (
'Robot - Removing category {0} per [[WP:CFD|CFD]] '
'at {1}.'.format(src, thisDay))
+ action_summary = 'Robot - Result of [[WP:CFD|CFD]] at ' + thisDay + '.'
else:
continue
robot = CategoryMoveBot(oldcat=src, batch=True, comment=summary,
- deletion_comment=True, inplace=True)
+ deletion_comment=action_summary,
+ inplace=True)
else:
# This line does not fit any of our regular expressions,
# so ignore it.
--
To view, visit https://gerrit.wikimedia.org/r/283838
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I03e8975d00221a5d53b78b73149f6e830bd66eec
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Cyde <cydeweys(a)gmail.com>
Gerrit-Reviewer: Cyde <cydeweys(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: diff: do not highlight entire line when only text is removed
......................................................................
diff: do not highlight entire line when only text is removed
When the last changed-to line in a hunk lacks formatting, reuse the format
indication of the changed-from line.
Bug: T130572
Change-Id: If91bc6de20d8634c5adf8b18aee4937a663fa925
---
M pywikibot/diff.py
1 file changed, 30 insertions(+), 9 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/diff.py b/pywikibot/diff.py
index f83033f..4acc645 100644
--- a/pywikibot/diff.py
+++ b/pywikibot/diff.py
@@ -118,20 +118,41 @@
"""Color diff lines."""
diff = iter(self.diff)
- l1, l2 = '', next(diff)
+ fmt, line1, line2 = '', '', next(diff)
for line in diff:
- l1, l2 = l2, line
+ fmt, line1, line2 = line1, line2, line
# do not show lines starting with '?'.
- if l1.startswith('?'):
+ if line1.startswith('?'):
continue
- if l2.startswith('?'):
- yield self.color_line(l1, l2)
- else:
- yield self.color_line(l1)
+ if line2.startswith('?'):
+ yield self.color_line(line1, line2)
+ continue
+ if line1.startswith('-'):
+ # Color whole line to be removed.
+ yield self.color_line(line1)
+ elif line1.startswith('+'):
+ # Reuse last available fmt as diff line, if possible,
+ # or color whole line to be added.
+ fmt = fmt if fmt.startswith('?') else ''
+ fmt = fmt[:min(len(fmt), len(line1))]
+ fmt = fmt if fmt else None
+ yield self.color_line(line1, fmt)
# handle last line
- if not l2.startswith('?'):
- yield self.color_line(l2)
+ # If line line2 is removed, color the whole line.
+ # If line line2 is added, check if line1 is a '?-type' line, to prevent
+ # the entire line line2 to be colored (see T130572).
+ # The case where line2 start with '?' has been covered already.
+ if line2.startswith('-'):
+ # Color whole line to be removed.
+ yield self.color_line(line2)
+ elif line2.startswith('+'):
+ # Reuse last available line1 as diff line, if possible,
+ # or color whole line to be added.
+ fmt = line1 if line1.startswith('?') else ''
+ fmt = fmt[:min(len(fmt), len(line2))]
+ fmt = fmt if fmt else None
+ yield self.color_line(line2, fmt)
def color_line(self, line, line_ref=None):
"""Color line characters.
--
To view, visit https://gerrit.wikimedia.org/r/278967
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If91bc6de20d8634c5adf8b18aee4937a663fa925
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>