;ò )äHEc@sdZdklZdklZlZlZdkZdkl Z l Z dk l Z dk lZdklZdklZlZd klZd klZlZdkZd klZlZlZeid ƒid „Z d„Z!dd„Z"dfd„ƒYZ#ee#ƒdS(sÓ Simple revisions support for zwiki pages. Provides methods to look up and revert to old versions from the ZODB history, and a diff-browsing form. todo: - clean up - separate out html vs. email diff methods (s nested_scopes(sjoinssplitsatoiN(spacksunpack(s html_quote(shistoricalRevision(sndiff(sgetSecurityManagersClassSecurityInfo(sInitializeClass(sMAX_OLD_LINES_DISPLAYsMAX_NEW_LINES_DISPLAY(sget_transactionsBLATHERsformattedTracebacks\s*$cCs||ƒtj SdS(N(spatslinesNone(slinespat((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pysISJUNKscst‡d†|ƒSdS(Ncsˆ|S(N(sprefixsx(sx(sprefix(s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pys"s(smapslines(slinessprefix((sprefixs4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pysprefix"sicCs½g}|ot|ƒ|jost|ƒ|}x-t|dƒD]}|i|||ƒqAW|i|d||djodpdfƒn#x|D]}|i||ƒqšW|SdS(Nis[%d more line%s...]sss( soutputsmaxlinesslenslinessextrasxrangesisappendsprefixsline(slinessprefixsmaxlinessextrasisoutputsline((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pys abbreviate$s3sPageDiffSupportcBsUtZdZeƒZddeed„Zd„Zd„Zd„Z d„Z ei e i dƒd „Zei e i d ƒd „Zei e i d ƒdd „Zei e idƒed„Zei e idƒed„Zei e idƒedd„Zddd„Zddeed„Zddeedd„Zd„Zd„ZRS(s} I provide methods for browsing a zwiki page's 'edit history', or at least the differences between recent edits. iicCsWt|ƒt|ƒf\}}|p|id|d|ƒ}|i||d|ƒSdS(s Display a diff between two revisions of this page, as a web page. Uses the diffform template. See rawDiff for more. XXX should skip uninteresting transactions if re.search(r'(/edit|/comment|/append|PUT)',lastrevision['description']): srevAsrevBsREQUESTN( sstrsrevAsrevBstestsselfshtmlDiffstsdiffformsREQUEST(sselfsrevAsrevBsREQUESTstestst((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pysdiff9s cCs$|it|ƒdt|ƒƒSdS(s* helpers for form buttons iN(sselfsdiffsintscurrentRevision(sselfscurrentRevision((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pysprevDiffHscCs(|it|ƒdt|ƒdƒSdS(s* helpers for form buttons iiN(sselfsdiffsintscurrentRevision(sselfscurrentRevision((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pysnextDiffNscCs!dfd„ƒY}|iƒSdS(så Return the list of ZODB transaction history entries. This is an alias for manage_change_history and is fairly limited. History entries may relate to things other than text changes, eg a property change. They contain some basic information and may be used to fetch the old object (revision) from the ZODB. When the ZODB is packed, history and revisions disappear. The maximum number of history entries we can get is 20. s EditRecordcBstZdZRS(sŸ A brain-like object representing an edit (or other transaction). Combines the contents of manage_change_history entries, (s__name__s __module__s__doc__(((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pys EditRecord_s N(s EditRecordsselfsmanage_change_history(sselfs EditRecord((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pyshistoryTs cCst|iƒƒSdS(sD How many old revisions are available in the ZODB ? N(slensselfshistory(sself((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pys revisionCountiss pageRevisionc Cswt|ƒ}yY|iƒ|}|d}ttdftt t t |dƒƒƒƒ}t ||ƒSWn tSnXdS(s Get one of the previous revisions of this page object. The argument increases to select older revisions, eg revision 1 is the most recent version prior to the current one, revision 2 is the version before that, etc. skeys>HHHHs.N(sintsrevsselfshistorys historyentryskeysapplyspackstuplesmapsatoissplitsserialshistoricalRevisionsNone(sselfsrevs historyentryskeysserial((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pys pageRevisionps  .srevisionInfoForcCsM|i|ƒ}|o/hd|i<d|i<d|iƒchanged:s5s-ssssdeletesremoved:sinserts added:N(sasselfslasttextsrevAsbsrevBssplitsrsappendsextendsaddsaddmsaddnobrsrawDiffstagsalosahisblosbhisprefixsmaps html_quotesjoin(sselfsrevAsrevBsasbsalosahisaddnobrsblosbhisaddsrsaddmstag((srs4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pyshtmlDiffösB     #      #     cCs³|p|id|ƒ}|p|id|ƒ}t|dƒ}t|dƒ}g} | i| i f\} } x-|i ||ƒD]\}}}} } |djo]|o| dƒn| t|||!dtƒƒ| t|| | !dtƒƒ| dƒq|djo@|o| dƒn| t|||!dtƒƒ| dƒq|d jo@|o| d ƒn| t|| | !dtƒƒ| dƒqqWdt| dƒSd S( sò Generate readable a plain text diff of this page's revisions. This should optimize for human readability, as people may be getting a lot of these in mail-outs. Revisions are numbered backwards from the latest (0). Alternately, a and/or b texts can be specified. verbose adds more decoration. Each text segment is abbreviated according to built in constants, to avoid eg generating monster mail-outs. This can be annoying. srevs sreplaces ??changed:s-ssdeletes --removed:sinserts++added:N(sasselfslasttextsrevAsbsrevBssplitsrsappendsextendsaddsaddmsrawDiffstagsalosahisblosbhisverboses abbreviatesMAX_OLD_LINES_DISPLAYsMAX_NEW_LINES_DISPLAYsjoin(sselfsrevAsrevBsasbsverbosesalosahistagsblosbhisaddsrsaddm((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pystextDiff%s6    c Cst|dƒ}t|dƒ}g}xT|i||ƒD]@\}}}}}|ddfjo|i |||!ƒq7q7Wdt |dƒSdS(sU Return any lines which are in b but not in a, according to difflib. s sinsertsreplaceN( ssplitsasbsrsselfsrawDiffstagsalosahisblosbhisextendsjoin( sselfsasbsalosbhisahistagsblosr((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pys addedTextKscCs&tidtd|d|ƒiƒSdS(sF Return a diff between two texts, as difflib opcodes. sisjunksasbN(sndiffsSequenceMatchersISJUNKsasbs get_opcodes(sselfsasb((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pysrawDiffWs (s__name__s __module__s__doc__sClassSecurityInfossecuritysNonesdiffsprevDiffsnextDiffshistorys revisionCountsdeclareProtecteds PermissionssViews pageRevisionsrevisionInfoForslasttextsEditsreverts revertEditsBysmanage_propertiessrevertEditsEverywhereByslastlogshtmlDiffstextDiffs addedTextsrawDiff(((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pysPageDiffSupport2s0          $ /& ($s__doc__s __future__s nested_scopessstringsjoinssplitsatoisresstructspacksunpacksDocumentTemplate.DT_Utils html_quotes OFS.HistoryshistoricalRevisionsOFSsndiffs AccessControlsgetSecurityManagersClassSecurityInfosGlobalssInitializeClasssDefaultssMAX_OLD_LINES_DISPLAYsMAX_NEW_LINES_DISPLAYs PermissionssUtilssget_transactionsBLATHERsformattedTracebackscompilesmatchsISJUNKsprefixs abbreviatesPageDiffSupport(s abbreviatesPageDiffSupportsformattedTracebacksndiffsprefixsreshistoricalRevisionssplits Permissionss nested_scopessClassSecurityInfosInitializeClasssget_transactionsatoisunpacksBLATHERsjoinsgetSecurityManagersMAX_OLD_LINES_DISPLAYsISJUNKspacks html_quotesMAX_NEW_LINES_DISPLAY((s4/mnt/gmirror/ports/www/zope-zwiki/work/ZWiki/Diff.pys? s$         ÿÍ