Index: trunk/tools/editsyntax/EditSyntax.py |
— | — | @@ -1,4 +1,14 @@ |
2 | 2 | #-*- coding: utf-8 -*- |
| 3 | + |
| 4 | +## Originally written by Robert A. Rohde (rohde@robertrohde.com) |
| 5 | +## |
| 6 | +## The file provides a library of functions used to re-express |
| 7 | +## Mediawiki full history dump files into a much more compact "edit syntax" |
| 8 | +## or to make them grow large again. |
| 9 | +## |
| 10 | +## For practical implementations of use, see the companion files: |
| 11 | +## ConvertToEditSyntax.py and ConvertFromEditSyntax.py |
| 12 | + |
3 | 13 | import string, re, copy, hashlib |
4 | 14 | |
5 | 15 | ## Global variables used by this script |
— | — | @@ -107,7 +117,10 @@ |
108 | 118 | revert_id = c; |
109 | 119 | break; |
110 | 120 | if revert_id > -1: |
111 | | - changes = [dict({'node':'revert','revision':revert_id})]; |
| 121 | + if revert_id != previous_revision: |
| 122 | + changes = [dict({'node':'revert','revision':revert_id})]; |
| 123 | + else: |
| 124 | + changes = []; |
112 | 125 | else: |
113 | 126 | changes = differenceGenerator(revision_buffer[previous_revision], |
114 | 127 | revision_buffer[current_revision]); |
— | — | @@ -201,7 +214,8 @@ |
202 | 215 | k2 = string.find(new_line,old_line[k1:k1+min_char_block],min_k2); |
203 | 216 | if k2 >= 0: |
204 | 217 | if k1 > 0 and k2 > 0 and old_line[k1-1] == new_line[k2-1]: |
205 | | - break; |
| 218 | + k1 += 1; |
| 219 | + continue; |
206 | 220 | s = min_char_block; |
207 | 221 | while k1 + s < len(old_line) \ |
208 | 222 | and k2 + s < len(new_line) \ |
— | — | @@ -210,7 +224,7 @@ |
211 | 225 | matches.append([k1,k2,s]); |
212 | 226 | k1 += s; |
213 | 227 | min_k2 = k2 + s; |
214 | | - break; |
| 228 | + continue; |
215 | 229 | k1 += 1; |
216 | 230 | |
217 | 231 | old = []; |