+ rev_data.sha1 = text_sha1
+
+ return rev_data
+
+ # Outline for how we want to handle collapse_user=True
+ # iteration rev.user prev_rev.user add prev_rev?
+ # 0 A None Never
+ # 1 A A False
+ # 2 B A True
+ # 3 A B True
+ # 4 A A False
+ # Post-loop A Always
+ def __find_next_revision(self):
+
+ if self.prev_rev is None:
+ prev_rev = WikiqPage._correct_sha(next(self.revisions))
+ self.prev_rev = prev_rev
+ else:
+ prev_rev = self.prev_rev
+
+ if self.collapse_user:
+ collapsed_revs = 1
+ self.prev_rev.collapsed_revs = collapsed_revs
+ prev_rev = self.prev_rev
+
+ for rev in self.revisions:
+ rev = WikiqPage._correct_sha(rev)
+ if self.collapse_user:
+ # yield if this is the last edit in a seq by a user and reset
+ # also yield if we do know who the user is
+
+ if rev.deleted.user or prev_rev.deleted.user:
+ self.prev_rev = rev
+ if prev_rev is not None:
+ prev_rev.collapsed_revs = collapsed_revs
+ return prev_rev
+
+ elif not rev.user.text == prev_rev.user.text:
+ self.prev_rev = rev
+ if prev_rev is not None:
+ prev_rev.collapsed_revs = collapsed_revs
+ return prev_rev
+
+ # otherwise, add one to the counter
+ else:
+ collapsed_revs += 1
+ rev.collapsed_revs = collapsed_revs
+ # if collapse_user is false, we always yield
+ else:
+ self.prev_rev = rev
+ if prev_rev is not None:
+ return prev_rev