[MediaWiki-commits] [Gerrit] Changes are wrongly detected in the last langlink - change (pywikibot/core)

2015-10-06 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Changes are wrongly detected in the last langlink
..


Changes are wrongly detected in the last langlink

This was first detected in cosmetic_changes.py, where pages not needing any
cosmetic changes were still being updated, and the supposed changed was an
unchanged langlink (the last one). Then I realized this also happens in
interwiki.py, but only when changes are supposed to be made to the page.
After checking textlib.py, I noticed that removeLanguageLinks() returns a
stripped version of the text whereas replaceLanguageLinks() does not. So
the actual difference is related to blank space.
This explains why cosmetic_changes.py detects a change and updates the page,
but interwiki.py does not: interwiki.py does not rely in differences in the
final text to make an update, but when it does need to make an update, it
outputs that diff.

This patch strips the text in replaceLanguageLinks() before returning if the
original text is stripped itself.

Conflicts:
pywikibot/textlib.py

Change-Id: Icd7252be8dbccf3fb04a4b4a465f6b057e3a8e3a
(manually cherry picked from 097245e7e34)
---
M pywikibot/textlib.py
1 file changed, 8 insertions(+), 2 deletions(-)

Approvals:
  XZise: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index b40aba4..42a9e62 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -31,7 +31,10 @@
 
 from pywikibot import config2 as config
 from pywikibot.family import Family
-from pywikibot.tools import OrderedDict
+from pywikibot.tools import (
+OrderedDict,
+issue_deprecation_warning
+)
 
 # cache for replaceExcept to avoid recompile or regexes each call
 _regex_cache = {}
@@ -595,6 +598,9 @@
 cseparator = site.family.category_text_separator
 separatorstripped = separator.strip()
 cseparatorstripped = cseparator.strip()
+do_not_strip = oldtext.strip() != oldtext
+if do_not_strip:
+issue_deprecation_warning('Using unstripped text', 'stripped text', 2)
 if addOnly:
 s2 = oldtext
 else:
@@ -662,7 +668,7 @@
 newtext = s2.replace(marker, '').strip() + separator + s
 else:
 newtext = s2.replace(marker, '')
-return newtext
+return newtext if do_not_strip else newtext.strip()
 
 
 def interwikiFormat(links, insite=None):

-- 
To view, visit https://gerrit.wikimedia.org/r/243514
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icd7252be8dbccf3fb04a4b4a465f6b057e3a8e3a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Merlijn van Deen 
Gerrit-Reviewer: John Vandenberg 
Gerrit-Reviewer: Ladsgroup 
Gerrit-Reviewer: Malafaya 
Gerrit-Reviewer: XZise 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Changes are wrongly detected in the last langlink - change (pywikibot/core)

2015-10-04 Thread Merlijn van Deen (Code Review)
Merlijn van Deen has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/243514

Change subject: Changes are wrongly detected in the last langlink
..

Changes are wrongly detected in the last langlink

This was first detected in cosmetic_changes.py, where pages not needing any
cosmetic changes were still being updated, and the supposed changed was an
unchanged langlink (the last one). Then I realized this also happens in
interwiki.py, but only when changes are supposed to be made to the page.
After checking textlib.py, I noticed that removeLanguageLinks() returns a
stripped version of the text whereas replaceLanguageLinks() does not. So
the actual difference is related to blank space.
This explains why cosmetic_changes.py detects a change and updates the page,
but interwiki.py does not: interwiki.py does not rely in differences in the
final text to make an update, but when it does need to make an update, it
outputs that diff.

This patch strips the text in replaceLanguageLinks() before returning if the
original text is stripped itself.

Conflicts:
pywikibot/textlib.py

Change-Id: Icd7252be8dbccf3fb04a4b4a465f6b057e3a8e3a
---
M pywikibot/textlib.py
1 file changed, 9 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/14/243514/1

diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index b40aba4..206a86d 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -31,7 +31,11 @@
 
 from pywikibot import config2 as config
 from pywikibot.family import Family
-from pywikibot.tools import OrderedDict
+from pywikibot.tools import (
+DeprecatedRegex,
+OrderedDict,
+issue_deprecation_warning
+)
 
 # cache for replaceExcept to avoid recompile or regexes each call
 _regex_cache = {}
@@ -595,6 +599,9 @@
 cseparator = site.family.category_text_separator
 separatorstripped = separator.strip()
 cseparatorstripped = cseparator.strip()
+do_not_strip = oldtext.strip() != oldtext
+if do_not_strip:
+issue_deprecation_warning('Using unstripped text', 'stripped text', 2)
 if addOnly:
 s2 = oldtext
 else:
@@ -662,7 +669,7 @@
 newtext = s2.replace(marker, '').strip() + separator + s
 else:
 newtext = s2.replace(marker, '')
-return newtext
+return newtext if do_not_strip else newtext.strip()
 
 
 def interwikiFormat(links, insite=None):

-- 
To view, visit https://gerrit.wikimedia.org/r/243514
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd7252be8dbccf3fb04a4b4a465f6b057e3a8e3a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Merlijn van Deen 
Gerrit-Reviewer: Malafaya 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Changes are wrongly detected in the last langlink - change (pywikibot/core)

2015-09-15 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Changes are wrongly detected in the last langlink
..


Changes are wrongly detected in the last langlink

This was first detected in cosmetic_changes.py, where pages not needing any
cosmetic changes were still being updated, and the supposed changed was an
unchanged langlink (the last one). Then I realized this also happens in
interwiki.py, but only when changes are supposed to be made to the page.
After checking textlib.py, I noticed that removeLanguageLinks() returns a
stripped version of the text whereas replaceLanguageLinks() does not. So
the actual difference is related to blank space.
This explains why cosmetic_changes.py detects a change and updates the page,
but interwiki.py does not: interwiki.py does not rely in differences in the
final text to make an update, but when it does need to make an update, it
outputs that diff.

This patch strips the text in replaceLanguageLinks() before returning if the
original text is stripped itself.

Change-Id: Icd7252be8dbccf3fb04a4b4a465f6b057e3a8e3a
---
M pywikibot/textlib.py
1 file changed, 9 insertions(+), 2 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 5c13101..72d68b6 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -38,7 +38,11 @@
 from pywikibot import config2 as config
 from pywikibot.exceptions import InvalidTitle
 from pywikibot.family import Family
-from pywikibot.tools import OrderedDict, DeprecatedRegex
+from pywikibot.tools import (
+DeprecatedRegex,
+OrderedDict,
+issue_deprecation_warning
+)
 
 # cache for replaceExcept to avoid recompile or regexes each call
 _regex_cache = {}
@@ -843,6 +847,9 @@
 cseparator = site.family.category_text_separator
 separatorstripped = separator.strip()
 cseparatorstripped = cseparator.strip()
+do_not_strip = oldtext.strip() != oldtext
+if do_not_strip:
+issue_deprecation_warning('Using unstripped text', 'stripped text', 2)
 if addOnly:
 s2 = oldtext
 else:
@@ -910,7 +917,7 @@
 newtext = s2.replace(marker, '').strip() + separator + s
 else:
 newtext = s2.replace(marker, '')
-return newtext
+return newtext if do_not_strip else newtext.strip()
 
 
 def interwikiFormat(links, insite=None):

-- 
To view, visit https://gerrit.wikimedia.org/r/238149
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icd7252be8dbccf3fb04a4b4a465f6b057e3a8e3a
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Malafaya 
Gerrit-Reviewer: John Vandenberg 
Gerrit-Reviewer: Ladsgroup 
Gerrit-Reviewer: Malafaya 
Gerrit-Reviewer: Merlijn van Deen 
Gerrit-Reviewer: Mpaa 
Gerrit-Reviewer: XZise 
Gerrit-Reviewer: Xqt 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Changes are wrongly detected in the last langlink - change (pywikibot/core)

2015-09-14 Thread Malafaya (Code Review)
Malafaya has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/238149

Change subject: Changes are wrongly detected in the last langlink
..

Changes are wrongly detected in the last langlink

This was first detected in cosmetic_changes.py, where pages not undergoing any
cosmetic changes were being updated, and the supposed changed was an unchanged
langlink (the last one). Then I realized this also happens in interwiki.py, but
only when changes are supposed to be made to the page.
After checking textlib.py, I noticed that removeLanguageLinks() returns a
stripped version of the text whereas replaceLanguageLinks() does not. So the
actual difference is related to blank space.
This explains why cosmetic_changes.py detects a change and updates the page,
but interwiki.py does not: interwiki.py does not rely in differences in the
final text to make an update, but when it does need to make an update, it
outputs that diff.

This patch strips the text in replaceLanguageLinks() before returning.

Change-Id: Icd7252be8dbccf3fb04a4b4a465f6b057e3a8e3a
---
M pywikibot/textlib.py
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/49/238149/1

diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 5c13101..bc93290 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -910,7 +910,7 @@
 newtext = s2.replace(marker, '').strip() + separator + s
 else:
 newtext = s2.replace(marker, '')
-return newtext
+return newtext.strip()
 
 
 def interwikiFormat(links, insite=None):

-- 
To view, visit https://gerrit.wikimedia.org/r/238149
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd7252be8dbccf3fb04a4b4a465f6b057e3a8e3a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Malafaya 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits