2

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!

SanMelkote
  • 228
  • 2
  • 12

2 Answers2

4

"Revert" is not a well-defined concept so it depends on how you define it. (See https://phabricator.wikimedia.org/T152434 for some relevant discussion.) The most capable revert detection tool today is probably mwrevert.

Tgr
  • 27,442
  • 12
  • 81
  • 118
3

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.

AXO
  • 8,198
  • 6
  • 62
  • 63
  • Hash method however seems to indicate more number of revert edits than what wikipedia statistics page shows. For example, consider this page: https://xtools.wmflabs.org/articleinfo/en.wikipedia.org/Rue_du_Brexit. It suggests 2 reverts. But, the sha1 on all revisions (https://en.wikipedia.org/w/index.php?title=Rue_du_Brexit&action=history) suggests 3 reverts. Not sure why this discrepancy. – SanMelkote Mar 03 '20 at 12:28