;ς ˆΈ“Fc@sRdZdZdklZlZdklZlZlZdefd„ƒYZ dS(s Tailor needs a generic way to remember which was the last migrated revision between the two repositories. For some backends it could derive such information directly from the working dir/repository, others have no such capability. Moreover, since fetching and digesting the history to produce a sequence of ChangeSets it's time and bandwidth consuming, the state file helps keeping a cache of pending changes. sreStructuredText(sloadsdump(ssignalsSIGINTsSIG_IGNs StateFilecBsttZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z e d„Z d „Z d „Z d „ZRS( sΌ State file that stores current revision and pending changesets. It behaves as an iterator, and source backends loop over not yet applied changesets, calling .applied() after each one: that writes the applied changeset in a *journal* file, much more atomic than rewriting the whole archive each time. When the source backend finishes it's job, either because there are no more pending changeset or stopped by an error, it calls .finalize(), that in presence of a journal file adjust the archive filtering out already applied changesets. Should an hard error prevent .finalize() call, it will happen automatically next time the state file is loaded. cCsDdkl}||_t|_t|_t|_|dƒ|_ dS(sK Initialize a new instance, logging to `tailor.statefile`. (s getLoggerstailor.statefileN( sloggings getLoggersfnamesselfsfilenamesNonesarchives last_appliedscurrentslog(sselfsfnamesconfigs getLogger((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pys__init__*s     cCst|iƒt|_y5t|iƒ|_t|iƒ|_t|iƒWn%t j ot|_t|_nXdS(s” Open the pickle file and load the last applied changeset. The second pickled object is ignored for backward compatibility. N( sselfsfinalizesNonescurrentsopensfilenamesarchivesloads last_appliedsIOError(sself((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pys_load7s   cCs’d}tttƒ}zet|idƒ}t |i |ƒt t |ƒx%|D]}t ||ƒ|d7}qNW|iƒWdtt|ƒX|iid|ƒdS(s€ Write the state file, that is dump last applied changeset, a dummy None, then one changeset at a time. iswiNs.Cached information about %d pending changesets(scountssignalsSIGINTsSIG_IGNsprevioussopensselfsfilenamessfsdumps last_appliedsNones changesetsscsscloseslogsinfo(sselfs changesetsscountssfscssprevious((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pys_writeJs  cCs |iSdS(N(sselfsfilename(sself((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pys__str__^scCs|SdS(N(sself(sself((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pys__iter__ascCsh|i o t‚nyt|iƒ|_Wn/tj o#|iiƒt|_t‚nX|iSdS(N(sselfsarchives StopIterationsloadscurrentsEOFErrorsclosesNone(sself((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pysnextds     cCs’|itjo|iƒn|itjotSn|iiƒ}yt|iƒ}Wnt j o t}nX|ii |ƒ|tj SdS(sI Verify if there's at least one changeset still pending. N( sselfsarchivesNones_loadsFalsestellspossloadsnextsEOFErrorsseek(sselfspossnext((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pyspendingos cCsktttƒ}zG|p|i|_t|iddƒ}t |i|ƒ|i ƒWdtt|ƒXdS(sB Write the applied changeset to the journal file. s.journalswN( ssignalsSIGINTsSIG_IGNspreviousscurrentsselfs last_appliedsopensfilenamesjournalsdumpsclose(sselfscurrentsjournalsprevious((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pysappliedsc Csdkl}dkl} l}tttƒ} zL|i t j o|i i ƒt |_ n||i dƒo |iidƒt|i dƒ}t|ƒ} |i ƒ||i ƒozt|i ƒ}t|ƒt|ƒy1t|ƒ}x|| jot|ƒ}qξWWntj o t }nXt|i ddƒ}t| |ƒtt |ƒ|t j ojd}xJtoByt|ƒ}Wntj oPnXt||ƒ|d7}qoW|iid |ƒn|i ƒ|i ƒ|i d }||ƒo| |ƒn||i |ƒ||i|i ƒn7t|i dƒ}t| |ƒtt |ƒ|i ƒ| |iƒnWd tt| ƒXd S( sz If there is a journal file, adjust the archive accordingly, dropping already applied changesets. (sexists(sunlinksrenames.journals*Adjusting the state accordingly to journals.newswiis#%d pending changesets in state files.oldN(sos.pathsexistssossunlinksrenamessignalsSIGINTsSIG_IGNsprevioussselfsarchivesNonesclosesfilenameslogsdebugsopensjournalsloads last_appliedsoldscssEOFErrorssfsdumpscountsTruesinfosoldnamesname( sselfsrenamesoldsexistssjournalscountssfsoldnamescss last_appliedsunlinksprevious((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pysfinalizesj                       cCs)|itjo|iƒn|iSdS(sL Return the last applied changeset, if any, None otherwise. N(sselfsarchivesNones_loads last_applied(sself((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pyslastAppliedChangesetΤscCsE|itj o|iiƒt|_n|i|ƒ|iƒdS(s= Write pending changesets to the state file. N(sselfsarchivesNonescloses_writes changesetss_load(sselfs changesets((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pyssetPendingChangesetsέs    (s__name__s __module__s__doc__s__init__s_loads_writes__str__s__iter__snextspendingsNonesappliedsfinalizeslastAppliedChangesetssetPendingChangesets(((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pys StateFiles        E N( s__doc__s __docformat__scPicklesloadsdumpssignalsSIGINTsSIG_IGNsobjects StateFile(sloadsdumps StateFilessignalsSIGINTs __docformat__sSIG_IGN((sD/mnt/gmirror/ports/devel/tailor/work/tailor-0.9.29/vcpx/statefile.pys?s