V Qc@sdZddlZddlZddlZddlZddlZeeds]de_ndddYZdddYZ d d Z d Z d Z iZ d ZdZdZdZedkrendS(s!Utilities for CVS administration.iNttimezoneitFilecBs\eZdZd dZdZdZdZd dZdZ dZ dZ RS( sRepresent a file's status. Instance variables: file -- the filename (no slashes), None if uninitialized lseen -- true if the data for the local file is up to date eseen -- true if the data from the CVS/Entries entry is up to date (this implies that the entry must be written back) rseen -- true if the data for the remote file is up to date proxy -- RCSProxy instance used to contact the server, or None Note that lseen and rseen don't necessary mean that a local or remote file *exists* -- they indicate that we've checked it. However, eseen means that this instance corresponds to an entry in the CVS/Entries file. If lseen is true: lsum -- checksum of the local file, None if no local file lctime -- ctime of the local file, None if no local file lmtime -- mtime of the local file, None if no local file If eseen is true: erev -- revision, None if this is a no revision (not '0') enew -- true if this is an uncommitted added file edeleted -- true if this is an uncommitted removed file ectime -- ctime of last local file corresponding to erev emtime -- mtime of last local file corresponding to erev extra -- 5th string from CVS/Entries file If rseen is true: rrev -- revision of head, None if non-existent rsum -- checksum of that revision, Non if non-existent If eseen and rseen are both true: esum -- checksum of revision erev, None if no revision Note cCsK|rd|krtdn||_d|_|_|_d|_dS(Nt/sno slash allowed in filei(t ValueErrortfiletlseenteseentrseentNonetproxy(tselfR((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyt__init__9s   cCst|j|jS(N(tcmpR(R tother((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyt__cmp__@scCsy&tj|jd\|_|_Wn+tjk rSd|_|_|_n(Xtj t |jj j |_d|_ dS(Nii(toststatRtlmtimetlctimeterrorRtlsumtmd5tnewtopentreadtdigestR(R ((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pytgetlocalCs &'cCs)tj|d}|jr:|d|jkr:tdn|d|_|d|_d|_d|_d|_|_ |jd dkrd|_|jd|_n|jdkrd|_d|_n0|d}t |d |_t |d |_ |d |_ |j r|j nd|_dS( NRisfile name mismatchiit-t0iiii(tstringt splitfieldsRRterevtedeletedtenewRtectimetemtimetunctimetextraRtgetesumR(R tlinetwordstdates((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pytgetentryLs*            cCs|r||_ny|jj|j|_Wn#tjtfk rSd|_nX|jrx|jj|j|_ n d|_ |j r|j nd|_ dS(Ni( R theadRtrrevRRtIOErrorRtsumtrsumRR&R(R R ((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyt getremoteds      cCsa|j|jkr!|j|_n<|jrT|j|jf}|jj||_n d|_dS(N(RR,R/tesumRR R.R(R tname((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyR&ss  cCs|js dS|jpd}|jr2d|}n|jrKd|j}n t|jdt|j}d|j|||jfS(sReturn a line suitable for inclusion in CVS/Entries. The returned line is terminated by a newline. If no entry should be written for this file, return "". tRRsInitial t s/%s/%s/%s/%s/ ( RRR R!RtgmctimeR"R#R%(R trevR)((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pytputentry|s    cCsddGHt|d}|d|jrU|dt|dt|dtn|jr|d|d |d |d t|d tn|jr|d |dt|jr|dtqndS(NRi2cSsDy|t||}Wntk r2d}nXd|G|GHdS(Nt?s%-15s:(tgetattrtAttributeError(tkeytreprR tvalue((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pytrs   RRRRRR!R R"R#R,R/R1(R<RthexifyR5RR(R R>((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pytreports$              N( t__name__t __module__t__doc__RR RRR*R0R&R7R@(((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyR s+     tCVScBseZdZeZddddddddgZd Zd Zd Zd Z d Z ddZ dZ dZdZdZdZddZdZdZRS(sRepresent the contents of a CVS admin file (and more). Class variables: FileClass -- the class to be instantiated for entries (this should be derived from class File above) IgnoreList -- shell patterns for local files to be ignored Instance variables: entries -- a dictionary containing File instances keyed by their file name proxy -- an RCSProxy instance, or None s.*s@*s,*s*~s*.os*.as*.sos*.pyccCsi|_d|_dS(N(tentriesRR (R ((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyR s cCsC||jkrdS||_x |jjD]}d|_q,WdS(Ni(R REtvaluesR(R R te((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pytsetproxys  cCski|_|jd}xB|j}|s1Pn|j}|j|||j|jcCs>tjjd|}d|kr1|j|nt||S(NRDR>(RRcRdtbackupR(R Rtmode((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyRJs cCs[tjj|rW|d}ytj|Wntjk rCnXtj||ndS(Nt~(RRctisfiletunlinkRtrename(R Rtbfile((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyRgs cCsDtjj|rtSx'|jD]}tj||r tSq WtS(N(RRctisdirtTruet IgnoreListtfnmatchtFalse(R Rtpat((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyRV#s N(RARBRCRRLRpR RHRORRR\RR_R@RSRFRbRfRJRgRV(((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyRDs"           s%02xicCs'|dkrdStttt|S(sDReturn a hex representation of a 16-byte string (e.g. an MD5 digest)RN(Rt hexify_formatttupleR`tord(R.((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyR?-s cCsd|dkrdSd}xGtdt|dD]-}|ttj|||d!d}q/W|S(s*Return the original from a hexified stringRR3iiiN(RtrangetlentchrRtatoi(thexsumR.ti((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pytunhexify3s  +c Cs|dkrdStsndddddddd d d d d g }d}x%|D]}|d}|t|s    + cCs&|dkrdStjtj|S(NR(RRtasctimetgmtime(tt((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyR5Os cCsttj}tj|}tj|}dG|G|GHdGtjGHdGtj|GHt|}dG|GHtj|}dG|GHtj|GHdS(NtGMTRtlocals unctime()s->(tintRRRRtctimeR$(tnowRtattutgu((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyt test_unctimeSs     cCsPt}|j|jddl}|j}|j||jdS(Ni(RDROR\t rcsclientt openrcsclientR_R@(txRR ((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyttest`s      t__main__(((RCRRRRRqthasattrRRRDRtR?R}RR$R5RRRA(((s)/usr/lib64/python2.7/Demo/pdist/cvslib.pyts&      ~