Add ability to disable revert detection

Also add test to ensure functionality works.

Signed-off-by: Will Beason <willbeason@gmail.com>
This commit is contained in:
Will Beason
2025-05-29 11:59:10 -05:00
parent 9009bb6fa4
commit c0e629a313
3 changed files with 27809 additions and 7 deletions

19
wikiq
View File

@@ -523,7 +523,11 @@ class WikiqParser:
if namespace not in self.namespace_filter:
continue
rev_detector = mwreverts.Detector(radius=self.revert_radius)
# Disable detecting reverts if radius is 0.
if self.revert_radius > 0:
rev_detector = mwreverts.Detector(radius=self.revert_radius)
else:
rev_detector = None
if self.persist != PersistMethod.none:
window = deque(maxlen=PERSISTENCE_RADIUS)
@@ -574,13 +578,14 @@ class WikiqParser:
rev_data.text_chars = len(rev.text)
# generate revert data
revert = rev_detector.process(text_sha1, rev.id)
if rev_detector is not None:
revert = rev_detector.process(text_sha1, rev.id)
if revert:
rev_data.revert = True
rev_data.reverteds = revert.reverteds
else:
rev_data.revert = False
if revert:
rev_data.revert = True
rev_data.reverteds = revert.reverteds
else:
rev_data.revert = False
# if the fact that the edit was minor can be hidden, this might be an issue
rev_data.minor = rev.minor