jenkins-bot has submitted this change and it was merged.
Change subject: Release 2.0rc5
......................................................................
Release 2.0rc5
Change-Id: If00943f8e64df231716ce67163b65ed2cba3f81d
---
M ChangeLog
M pywikibot/__init__.py
M setup.py
3 files changed, 37 insertions(+), 2 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ChangeLog b/ChangeLog
index 17a191d..00fa7f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+Release 2.0rc5 (17 August 2016)
+===============================
+
+Bugfixes
+--------
+de630d8 Establish the project's name, once and for all
+fcca7ad setup.py: Add Python 3.4 and 3.5 to pypi classifiers
+e8be996 Remove item count output in page generators
+de75825 Test Python 3.5 on Travis
+f39c8fa Fix docstring capitalization in return types and behavior
+0e9ecb0 Stop reading 'cookieprefix' upon login
+65d62ae Fix travis global environment variables
+18a1574 Fix notifications building from JSON
+c846932 pywikibot: Store ImportError in imported variable
+99d789b Use default tox pip install
+eba4d95 Add asteroids that are being used as locations
+2b95d9e [bugfix] Fix test_translateMagicWords test
+76fa79c Fix ID for Rhea
+4491ed7 [bugfix] pass User page object to NotEmailableError
+ea0c637 Allow pywikibot to run on Windows 10 as well
+8864e34 listpages.py: Fix help docstring
+697b4f6 pwb.py: make sure pywikibot is correctly loaded before starting a script
+c66c463 win32_unicode: force truetype font in console
+16d8ff0 Update main copyright year to 2016
+ae0ddfc [L10N] add "sco" to redirected category pages
+10dc22a date.py: fix Hungarian day-month title
+b47b202 Prevent <references.../> from being destroyed
+c414088 [FIX] Page: Use repr-like if it can't be encoded
+ab2b9cc pywikibot.WARNING -> pywikibot.logging.WARNING
+c4f950c Do not expand text by default in getCategoryLinks
+435f6c4 Typo fix
+2c5944f Prevent AttributeError for when filename is None
+02872b7 Split TestUserContribs between user and non-user
+
+
Release 2.0rc4 (15 December 2015)
=================================
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index e26392a..c4ccfae 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -7,7 +7,7 @@
#
from __future__ import unicode_literals
-__release__ = '2.0rc4'
+__release__ = '2.0rc5'
__version__ = '$Id$'
import datetime
diff --git a/setup.py b/setup.py
index 09f1353..57d50f4 100644
--- a/setup.py
+++ b/setup.py
@@ -160,7 +160,7 @@
from setuptools import setup, find_packages
name = 'pywikibot'
-version = '2.0rc4'
+version = '2.0rc5'
github_url = 'https://github.com/wikimedia/pywikibot-core'
setup(
--
To view, visit https://gerrit.wikimedia.org/r/305331
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If00943f8e64df231716ce67163b65ed2cba3f81d
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Establish the project's name, once and for all
......................................................................
Establish the project's name, once and for all
Change-Id: Ib8d24777ce91e5f5ded21324a784147e92b4804d
(cherry picked from commit 116b6f5b164e27c1aa00742499bb8f7d0e53547d)
---
M pywikibot/cosmetic_changes.py
M scripts/weblinkchecker.py
M setup.py
M tests/interwiki_link_tests.py
M tests/link_tests.py
5 files changed, 5 insertions(+), 5 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 31de09d..aab60fe 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -349,7 +349,7 @@
interwikiLinks = None
allstars = []
- # The PyWikipediaBot is no longer allowed to touch categories on the
+ # Pywikibot is no longer allowed to touch categories on the
# German Wikipedia. See
# https://de.wikipedia.org/wiki/Hilfe_Diskussion:Personendaten/Archiv/1#Posit…
# ignoring nn-wiki of cause of the comment line above iw section
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index 175b8a2..e3c8caf 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -275,7 +275,7 @@
# 'User-agent': pywikibot.useragent,
# we fake being Firefox because some webservers block unknown
# clients, e.g. https://images.google.de/images?q=Albit gives a 403
- # when using the PyWikipediaBot user agent.
+ # when using the Pywikibot user agent.
'User-agent': 'Mozilla/5.0 (X11; U; Linux i686; de; rv:1.8) Gecko/20051128 SUSE/1.5-0.1 Firefox/1.5',
'Accept': 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Accept-Language': 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3',
diff --git a/setup.py b/setup.py
index 265a915..09f1353 100644
--- a/setup.py
+++ b/setup.py
@@ -169,7 +169,7 @@
description='Python MediaWiki Bot Framework',
long_description=open('README.rst').read(),
maintainer='The Pywikibot team',
- maintainer_email='pywikipedia-l(a)lists.wikimedia.org',
+ maintainer_email='pywikibot(a)lists.wikimedia.org',
license='MIT License',
packages=['pywikibot'] + [package
for package in find_packages()
diff --git a/tests/interwiki_link_tests.py b/tests/interwiki_link_tests.py
index 0ddee67..8b07ead 100644
--- a/tests/interwiki_link_tests.py
+++ b/tests/interwiki_link_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Test Interwiki Link functionality."""
#
-# (C) Pywikipedia bot team, 2014
+# (C) Pywikibot team, 2014
#
# Distributed under the terms of the MIT license.
#
diff --git a/tests/link_tests.py b/tests/link_tests.py
index aa25b16..eee70c5 100644
--- a/tests/link_tests.py
+++ b/tests/link_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Test Link functionality."""
#
-# (C) Pywikipedia bot team, 2014
+# (C) Pywikibot team, 2014
#
# Distributed under the terms of the MIT license.
#
--
To view, visit https://gerrit.wikimedia.org/r/305332
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib8d24777ce91e5f5ded21324a784147e92b4804d
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: History merge API support
......................................................................
History merge API support
Page history merging API support.
- Site.merge_history and Page.merge_history added
- Unit tests for above
Bug: T123198
Change-Id: I52694309483451aed3b8c57ac025f0d3e965c23e
---
M pywikibot/page.py
M pywikibot/site.py
M tests/edit_tests.py
3 files changed, 236 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 4a7f1b9..cdcfac5 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1736,6 +1736,23 @@
return [{'user': rev.user, 'timestamp': unicode(rev.timestamp.isoformat())}
for rev in self.revisions(total=total)]
+ def merge_history(self, dest, timestamp=None, reason=None):
+ """
+ Merge revisions from this page into another page.
+
+ See L{APISite.merge_history} for details.
+
+ @param dest: Destination page to which revisions will be merged
+ @type dest: pywikibot.Page
+ @param timestamp: Revisions from this page dating up to this timestamp
+ will be merged into the destination page (if not given or False,
+ all revisions will be merged)
+ @type timestamp: pywikibot.Timestamp
+ @param reason: Optional reason for the history merge
+ @type reason: str
+ """
+ self.site.merge_history(self, dest, timestamp, reason)
+
@deprecate_arg("throttle", None)
def move(self, newtitle, reason=None, movetalkpage=True, sysop=False,
deleteAndMove=False, safe=True):
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 8789299..cfa4a04 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -60,6 +60,8 @@
NoCreateError,
UserBlocked,
EntityTypeUnknownException,
+ FatalServerError,
+ PageSaveRelatedError,
)
from pywikibot.family import WikimediaFamily
from pywikibot.throttle import Throttle
@@ -4950,6 +4952,114 @@
return False
OnErrorExc = namedtuple('OnErrorExc', 'exception on_new_page')
+
+ # catalog of merge history errors for use in error messages
+ _mh_errors = {
+ 'noapiwrite': 'API editing not enabled on {site} wiki',
+ 'writeapidenied':
+ 'User {user} is not authorized to edit on {site} wiki',
+ 'mergehistory-fail-invalid-source': 'Source {source} is invalid '
+ '(this may be caused by an invalid page ID in the database)',
+ 'mergehistory-fail-invalid-dest': 'Destination {dest} is invalid '
+ '(this may be caused by an invalid page ID in the database)',
+ 'mergehistory-fail-no-change':
+ 'History merge did not merge any revisions; '
+ 'please recheck the page and timestamp parameters',
+ 'mergehistory-fail-permission':
+ 'User {user} has insufficient permissions to merge history',
+ 'mergehistory-fail-timestamps-overlap':
+ 'Source revisions from {source} overlap or come after '
+ 'destination revisions of {dest}'
+ }
+
+ @must_be(group='sysop', right='mergehistory')
+ def merge_history(self, source, dest, timestamp=None, reason=None):
+ """Merge revisions from one page into another.
+
+ Revisions dating up to the given timestamp in the source will be
+ moved into the destination page history. History merge fails if
+ the timestamps of source and dest revisions overlap (all source
+ revisions must be dated before the earliest dest revision).
+
+ @param source: Source page from which revisions will be merged
+ @type source: pywikibot.Page
+ @param dest: Destination page to which revisions will be merged
+ @type dest: pywikibot.Page
+ @param timestamp: Revisions from this page dating up to this timestamp
+ will be merged into the destination page (if not given or False,
+ all revisions will be merged)
+ @type timestamp: pywikibot.Timestamp
+ @param reason: Optional reason for the history merge
+ @type reason: str
+ """
+ # Check wiki version to see if action=mergehistory is supported
+ min_version = MediaWikiVersion('1.27.0-wmf.13')
+ if MediaWikiVersion(self.version()) < min_version:
+ raise FatalServerError(str(self) + ' version must be '
+ '1.27.0-wmf.13 or newer to support the '
+ 'history merge API.')
+
+ # Data for error messages
+ errdata = {
+ 'site': self,
+ 'source': source,
+ 'dest': dest,
+ 'user': self.user(),
+ }
+
+ # Check if pages exist before continuing
+ if not source.exists():
+ raise NoPage(source,
+ 'Cannot merge revisions from source {source} because '
+ 'it does not exist on {site}'
+ .format(**errdata))
+ if not dest.exists():
+ raise NoPage(dest,
+ 'Cannot merge revisions to destination {dest} '
+ 'because it does not exist on {site}'
+ .format(**errdata))
+
+ if source == dest: # Same pages
+ raise PageSaveRelatedError('Cannot merge revisions of {source} to itself'
+ .format(**errdata))
+
+ # Send the merge API request
+ token = self.tokens['csrf']
+ req = self._simple_request(action='mergehistory',
+ token=token)
+ req['from'] = source
+ req['to'] = dest
+ if reason:
+ req['reason'] = reason
+ if timestamp:
+ req['timestamp'] = timestamp
+
+ self.lock_page(source)
+ self.lock_page(dest)
+ try:
+ result = req.submit()
+ pywikibot.debug('mergehistory response: {result}'
+ .format(result=result),
+ _logger)
+ except api.APIError as err:
+ if err.code in self._mh_errors:
+ on_error = self._mh_errors[err.code]
+ raise Error(on_error.format(**errdata))
+ else:
+ pywikibot.debug(
+ "mergehistory: Unexpected error code '{code}' received"
+ .format(code=err.code),
+ _logger
+ )
+ raise
+ finally:
+ self.unlock_page(source)
+ self.unlock_page(dest)
+
+ if 'mergehistory' not in result:
+ pywikibot.error('mergehistory: {error}'.format(error=result))
+ raise Error('mergehistory: unexpected response')
+
# catalog of move errors for use in error messages
_mv_errors = {
"noapiwrite": "API editing not enabled on %(site)s wiki",
diff --git a/tests/edit_tests.py b/tests/edit_tests.py
index 0702125..d7fb930 100644
--- a/tests/edit_tests.py
+++ b/tests/edit_tests.py
@@ -16,6 +16,7 @@
from pywikibot import config
from pywikibot import page_put_queue
+from pywikibot.tools import MediaWikiVersion
from tests.aspects import unittest, TestCase
from tests.oauth_tests import OAuthSiteTestCase
@@ -74,6 +75,114 @@
self.assertTrue(p.text != ts)
+class TestSiteMergeHistory(TestCase):
+ """Test history merge action."""
+
+ family = 'test'
+ code = 'test'
+
+ write = True
+ sysop = True
+
+ def setup_test_pages(self):
+ """Helper function to set up pages that we will use in these tests."""
+ site = self.get_site()
+ source = pywikibot.Page(site, 'User:Sn1per/MergeTest1')
+ dest = pywikibot.Page(site, 'User:Sn1per/MergeTest2')
+
+ # Make sure the wiki supports action=mergehistory
+ if MediaWikiVersion(site.version()) < MediaWikiVersion('1.27.0-wmf.13'):
+ raise unittest.SkipTest('Wiki version must be 1.27.0-wmf.13 or '
+ 'newer to support the history merge API.')
+
+ if source.exists():
+ source.delete('Pywikibot merge history unit test')
+ if dest.exists():
+ dest.delete('Pywikibot merge history unit test')
+
+ source.text = 'Lorem ipsum dolor sit amet'
+ source.save()
+ first_rev = source.editTime()
+
+ source.text = 'Lorem ipsum dolor sit amet is a common test phrase'
+ source.save()
+ second_rev = source.editTime()
+
+ dest.text = 'Merge history page unit test destination'
+ dest.save()
+
+ return first_rev, second_rev
+
+ def test_merge_history_validation(self):
+ """Test Site.merge_history validity checks."""
+ site = self.get_site()
+
+ page_source = pywikibot.Page(site, 'User:Sn1per/MergeTest1')
+ page_nonexist = pywikibot.Page(site, 'User:Sn1per/Nonexistent')
+
+ # Test source and dest validation
+ test_errors = [
+ (
+ { # source same as dest
+ 'source': page_source,
+ 'dest': page_source,
+ },
+ 'Cannot merge revisions of [[test:User:Sn1per/MergeTest1]] '
+ 'to itself'
+ ),
+ (
+ { # nonexistent source
+ 'source': page_nonexist,
+ 'dest': page_source,
+ },
+ 'Cannot merge revisions from source '
+ '[[test:User:Sn1per/Nonexistent]] because it does not exist '
+ 'on test:test'
+ ),
+ (
+ { # nonexistent dest
+ 'source': page_source,
+ 'dest': page_nonexist,
+ },
+ 'Cannot merge revisions to destination '
+ '[[test:User:Sn1per/Nonexistent]] because it does not exist '
+ 'on test:test'
+ ),
+ ]
+
+ self.setup_test_pages()
+ for params, error_msg in test_errors:
+ try:
+ site.merge_history(**params)
+ except pywikibot.Error as err:
+ self.assertEqual(str(err), error_msg)
+
+ def test_merge_history(self):
+ """Test Site.merge_history functionality."""
+ site = self.get_site()
+ source = pywikibot.Page(site, 'User:Sn1per/MergeTest1')
+ dest = pywikibot.Page(site, 'User:Sn1per/MergeTest2')
+
+ # Without timestamp
+ self.setup_test_pages()
+ site.merge_history(source, dest)
+ self.assertEqual(dest.revision_count(), 3)
+
+ # With latest timestamp
+ revs = self.setup_test_pages()
+ source.clear_cache() # clear revision cache when page is recreated
+ dest.clear_cache()
+ site.merge_history(source, dest, revs[1])
+ self.assertEqual(dest.revision_count(), 3)
+
+ # With middle timestamp
+ revs = self.setup_test_pages()
+ source.clear_cache()
+ dest.clear_cache()
+ site.merge_history(source, dest, revs[0])
+ self.assertEqual(dest.revision_count(), 2)
+
+
class OAuthEditTest(OAuthSiteTestCase):
"""Run edit test with OAuth enabled."""
--
To view, visit https://gerrit.wikimedia.org/r/265448
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I52694309483451aed3b8c57ac025f0d3e965c23e
Gerrit-PatchSet: 21
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Sn1per <geofbot(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Sn1per <geofbot(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>