jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/584196 )
Change subject: [cleanup] Desupport Page.fullVersionHistory() method ......................................................................
[cleanup] Desupport Page.fullVersionHistory() method
fullVersionHistory has several breaking changes against compat: - getAll, skipFirst and revCount weren't supported and aren't deprecated yet - compat implementation always took up to 500 items whereas core implementation takes all revisions except total parameter is used. - rollback option/result wasn't supported in core The method was deprecated for 5 years. Throw a FutureWarning and announce their removal. Also update compat2core.py script.
Also desupport Revision.full_hist_entry method and Revision.FullHistEntry class attribute which are only used for getVersionHistory.
Bug: T151110 Change-Id: I63633c33a9b635880628dd097ecd2b08f435ac5b --- M pywikibot/page/__init__.py M scripts/maintenance/compat2core.py 2 files changed, 32 insertions(+), 16 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py index 2d96ab3..3816a8a 100644 --- a/pywikibot/page/__init__.py +++ b/pywikibot/page/__init__.py @@ -46,10 +46,10 @@ from pywikibot.family import Family from pywikibot.site import DataSite, Namespace, need_version from pywikibot.tools import ( - compute_file_hash, + classproperty, compute_file_hash, UnicodeMixin, ComparableMixin, DotReadableDict, deprecated, deprecate_arg, deprecated_args, issue_deprecation_warning, - add_full_name, manage_wrapping, + add_full_name, manage_wrapping, suppress_warnings, ModuleDeprecationWrapper as _ModuleDeprecationWrapper, PY2, first_upper, redirect_func, remove_last_args, UnicodeType, StringTypes @@ -1800,17 +1800,19 @@ result += '|}\n' return result
- @deprecated('Page.revisions(content=True)', since='20150206') + @deprecated('Page.revisions(content=True)', since='20150206', + future_warning=True) @deprecated_args(reverseOrder='reverse', rollback=None, step=None) def fullVersionHistory(self, reverse=False, total=None): - """Iterate previous versions including wikitext. - - Takes same arguments as getVersionHistory. - """ - return [rev.full_hist_entry() + """Return previous versions including content.""" + with suppress_warnings( + 'pywikibot.page.Revision.full_hist_entry is deprecated'): + revisions = [ + rev.full_hist_entry() for rev in self.revisions(content=True, reverse=reverse, total=total) - ] + ] + return revisions
@deprecated_args(step=None) def contributors(self, total=None, starttime=None, endtime=None): @@ -5802,11 +5804,11 @@ 'user', 'comment'])
- FullHistEntry = namedtuple('FullHistEntry', ['revid', - 'timestamp', - 'user', - 'text', - 'rollbacktoken']) + _FullHistEntry = namedtuple('FullHistEntry', ['revid', + 'timestamp', + 'user', + 'text', + 'rollbacktoken'])
def __init__(self, revid, timestamp, user, anon=False, comment='', text=None, minor=False, rollbacktoken=None, parentid=None, @@ -5855,6 +5857,12 @@ self._sha1 = sha1 self.slots = slots
+ @classproperty + @deprecated(since='20200329', future_warning=True) + def FullHistEntry(cls): + """Class property which returns deprecated FullHistEntry attribute.""" + return cls._FullHistEntry + @property def parent_id(self): """ @@ -5938,10 +5946,15 @@ return Revision.HistEntry(self.revid, self.timestamp, self.user, self.comment)
+ @deprecated(since='20200329', future_warning=True) def full_hist_entry(self): """Return a namedtuple with a Page full history record.""" - return Revision.FullHistEntry(self.revid, self.timestamp, self.user, - self.text, self.rollbacktoken) + with suppress_warnings( + 'pywikibot.page.Revision.FullHistEntry is deprecated'): + entry = Revision.FullHistEntry(self.revid, self.timestamp, + self.user, self.text, + self.rollbacktoken) + return entry
@staticmethod def _thank(revid, site, source='pywikibot'): diff --git a/scripts/maintenance/compat2core.py b/scripts/maintenance/compat2core.py index 2d4d558..0cb7c42 100755 --- a/scripts/maintenance/compat2core.py +++ b/scripts/maintenance/compat2core.py @@ -101,6 +101,9 @@ 'Page.getVersionHistory() returns a pywikibot.Timestamp object instead\n' 'of a MediaWiki one. It also returns a tuple of 4 items instead of 6:\n' 'size and tags items are missing. Use Page.revisions() instead.'), + ('.fullVersionHistory(', + 'Page.fullVersionHistory() has different behaviour in core\n' + 'use Page.revisions() instead.'), ('.contributions(', 'User.contributions() returns a pywikibot.Timestamp object instead of a\n' 'MediaWiki one'),
pywikibot-commits@lists.wikimedia.org