jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1122287?usp=email )

Change subject: [bugfix] ensure that -from and -to arguments are not equal
......................................................................

[bugfix] ensure that -from and -to arguments are not equal

verify that -from and -to arguments are not equal for move action.
otherwise ask for new values. If the given answer for -from is empty,
leave the script.

Bug: T384753
Change-Id: Ib23dba9d8e69571b272ce460312c7ca79baa3922
---
M scripts/category.py
1 file changed, 19 insertions(+), 7 deletions(-)

Approvals:
  Matěj Suchánek: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/scripts/category.py b/scripts/category.py
index 15200be..9b758c6 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -153,7 +153,7 @@
    :mod:`pagegenerators` are supported with "move" and "remove" action.
 """
 #
-# (C) Pywikibot team, 2004-2024
+# (C) Pywikibot team, 2004-2025
 #
 # Distributed under the terms of the MIT license.
 #
@@ -1638,12 +1638,24 @@
                                 deletion_comment=use_deletion_summary,
                                 generator=gen)
     elif action == 'move':
-        if 'from' not in options:
-            options['from'] = pywikibot.input(
-                'Please enter the old name of the category:')
-        if 'to' not in options:
-            options['to'] = pywikibot.input(
-                'Please enter the new name of the category:')
+        while True:
+            if 'from' not in options:
+                options['from'] = pywikibot.input(
+                    'Please enter the old name of the category:')
+                if not options['from']:
+                    return
+
+            if 'to' not in options:
+                options['to'] = pywikibot.input(
+                    'Please enter the new name of the category:')
+
+            if options['from'] != options['to']:
+                break
+
+            pywikibot.error('-from and -to arguments are equal, please retry.')
+            del options['from']
+            del options['to']
+
         if use_deletion_summary:
             deletion_comment = \
                 CategoryMoveRobot.DELETION_COMMENT_SAME_AS_EDIT_COMMENT

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1122287?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ib23dba9d8e69571b272ce460312c7ca79baa3922
Gerrit-Change-Number: 1122287
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: Vladis13 <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to