How can I get details about reverted edits of a wiki page?

Viewed 135

I am using pywikibot in python to get all revisions of a Wikipedia page.

import pywikibot as pw wikiPage='Narthaki' page = pw.Page(pw.Site('en'), wikiPage) revs = page.revisions(content=True)

How do I know which of the revisions were reverts? I see from https://xtools.wmflabs.org/articleinfo/en.wikipedia.org/Narthaki that the page has one revert edit. Not sure how to get more information about this from the revision object.

Request your help. Many thanks!

2 Answers

You can compare text of revision directly, or look for the revisions that have the same sha1 hash:

>>> rev = next(revs)
>>> rev.sha1
'1b02fc4cbcfd1298770b16f85afe0224fad4b3ca'

If two revision have the same text/hash it means that the newer one is a revert to the older one. Of-course there are some special cases like sha1hidden, or how to handle multiple reverts to the same revision that one needs to consider.

Related