r46433 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46432‎ | r46433 | r46434 >
Date:07:02, 28 January 2009
Author:rarohde
Status:deferred
Tags:
Comment:
Adds file header. Also fixes logic error that was leading to poor compression for some types of changes.
Modified paths:
  • /trunk/tools/editsyntax/EditSyntax.py (modified) (history)

Diff [purge]

Index: trunk/tools/editsyntax/EditSyntax.py
@@ -1,4 +1,14 @@
22 #-*- 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+
313 import string, re, copy, hashlib
414
515 ## Global variables used by this script
@@ -107,7 +117,10 @@
108118 revert_id = c;
109119 break;
110120 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 = [];
112125 else:
113126 changes = differenceGenerator(revision_buffer[previous_revision],
114127 revision_buffer[current_revision]);
@@ -201,7 +214,8 @@
202215 k2 = string.find(new_line,old_line[k1:k1+min_char_block],min_k2);
203216 if k2 >= 0:
204217 if k1 > 0 and k2 > 0 and old_line[k1-1] == new_line[k2-1]:
205 - break;
 218+ k1 += 1;
 219+ continue;
206220 s = min_char_block;
207221 while k1 + s < len(old_line) \
208222 and k2 + s < len(new_line) \
@@ -210,7 +224,7 @@
211225 matches.append([k1,k2,s]);
212226 k1 += s;
213227 min_k2 = k2 + s;
214 - break;
 228+ continue;
215229 k1 += 1;
216230
217231 old = [];

Status & tagging log