jenkins-bot has submitted this change and it was merged.

Change subject: Remove requirement for Revision.parentid to exist
......................................................................


Remove requirement for Revision.parentid to exist

Revision parentid is only provided by the API v1.16+

Bug: T115438
Change-Id: I1b386430fc0a8cf08bf663f3866bd1fee825c316
---
M pywikibot/data/api.py
M pywikibot/page.py
M tests/page_tests.py
3 files changed, 19 insertions(+), 7 deletions(-)

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



diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index c932613..111a488 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -3062,8 +3062,6 @@
     if 'revisions' in pagedict:
         # TODO: T102735: Use the page content model for <1.21
         for rev in pagedict['revisions']:
-            assert 'parentid' in rev, 'parentid missing in revision %r' % rev
-
             revision = pywikibot.page.Revision(
                 revid=rev['revid'],
                 timestamp=pywikibot.Timestamp.fromISOformat(rev['timestamp']),
diff --git a/pywikibot/page.py b/pywikibot/page.py
index d17fc8f..cc2c1b5 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -638,6 +638,8 @@
         If the page has only one revision, it shall return -1.
 
         @return: long
+
+        @raise AssertionError: Use on MediaWiki prior to v1.16.
         """
         return self.latest_revision.parent_id or -1
 
@@ -649,6 +651,8 @@
         DEPRECATED: Use latest_revision.parent_id instead.
 
         @return: long
+
+        @raise AssertionError: Use on MediaWiki prior to v1.16.
         """
         return self.latest_revision.parent_id or -1
 
@@ -4523,6 +4527,14 @@
         @type comment: unicode
         @param minor: edit flagged as minor
         @type minor: bool
+        @param rollbacktoken: rollback token
+        @type rollbacktoken: unicode
+        @param parentid: id of parent Revision (v1.16+)
+        @type parentid: long
+        @param contentmodel: content model label (v1.21+)
+        @type contentmodel: unicode
+        @param sha1: sha1 of revision text (v1.19+)
+        @type sha1: unicode
 
         """
         self.revid = revid
diff --git a/tests/page_tests.py b/tests/page_tests.py
index 079fb3e..cf25ff0 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8  -*-
 """Tests for the page module."""
 #
-# (C) Pywikibot team, 2008-2014
+# (C) Pywikibot team, 2008-2015
 #
 # Distributed under the terms of the MIT license.
 #
@@ -16,6 +16,7 @@
 from pywikibot import InvalidTitle
 
 from pywikibot.tools import (
+    MediaWikiVersion,
     PY2,
     StringTypes as basestring,
     UnicodeType as unicode,
@@ -531,10 +532,11 @@
         self.assertDeprecation()
 
         self._reset_messages()
-        self.assertIsInstance(mainpage.previous_revision_id, int)
-        self.assertEqual(mainpage.previous_revision_id,
-                         mainpage.latest_revision.parent_id)
-        self.assertDeprecation()
+        if MediaWikiVersion(self.site.version()) >= MediaWikiVersion('1.16'):
+            self.assertIsInstance(mainpage.previous_revision_id, int)
+            self.assertEqual(mainpage.previous_revision_id,
+                             mainpage.latest_revision.parent_id)
+            self.assertDeprecation()
 
 
 class TestPageBaseUnicode(DefaultDrySiteTestCase):

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1b386430fc0a8cf08bf663f3866bd1fee825c316
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to