Afc@sdZddlmZmZddlZddlZddlZddlZddlm Z dZ defdYZ dZ d Z d efd YZd e fd YZdZdZedkrendS(s$Remote CVS -- command line interfacei(tCVStFileN(tCommandFrameWorkitMyFilecBskeZdZdZddZgdZdZddZdZdZ d Z d Z RS( cCsl|js|jn|js,|jn|js||jsR|jsKdSdSqh|js_dS|j|jkrudSdSn|js|jr|jrdSdSqh|jrdG|jGd GHd SdSn|js|j rd Sd Sn|j r |j|jkrd SdSn|j|j kr8|j |jkr1dSd Sn0|j |jkrNdS|j|jkrdd SdSdS(sReturn a code indicating the update status of this file. The possible return values are: '=' -- everything's fine '0' -- file doesn't exist anywhere '?' -- exists locally only 'A' -- new locally 'R' -- deleted locally 'U' -- changed remotely, no changes locally (includes new remotely or deleted remotely) 'M' -- changed locally, no changes remotely 'C' -- conflict: changed locally as well as remotely (includes cases where the file has been added or removed locally and remotely) 'D' -- deleted remotely 'N' -- new remotely 'r' -- get rid of entry 'c' -- create entry 'u' -- update entry (and probably others :-) t0tNt?tctCtRtrswarning:swas losttUtAtDtut=tMN( tlseentgetlocaltrseent getremoteteseentlsumtrsumtedeletedtfiletenewtesum(tself((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytaction0sT               cCs |j}|dkrdS|G|jGH|dkrA|jn|dkr\d|jGHn|dkrt|jd|_n|dkrd|_nm|dkrd |_|j|_d|_d|_|j |_ t j |jd \|_ |_d |_ndS(NRR RRs+%s: conflict resolution not yet implementedR iR RRiit(R R(RR(RRtgettremoveRtrrevterevRRRRtoststattemtimetectimetextra(Rtcode((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytupdateys,                  "RcCsc|j}|dkr)|j|dS|dkrDd|jGHn|dkr_d|jGHndS( NR RiR s*%s: committing removes not yet implementedRs+%s: conflict resolution not yet implemented(R R(RtputR(RtmessageR(((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytcommits      c CsE|jd}|j}x;|D]3\}}|dkrA|}q |d||}q W||jkr||j|jkr|dS|d}|j}|jj||f}tj|j }|j|krdSddl } | j } | j || j d|||fGHtjd|| j|f} | rAdd GHndS( NRs-rt iisdiff %s -r%s %ss diff %s %s %sRiF(RR!RRRtproxyRtmd5tnewtdigestttempfiletNamedTemporaryFiletwritetflushR#tsystemtname( RtoptstflagstrevtotatfntdatatsumR2ttftsts((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytdiffs.    !      cCs|jdkS(NR(R(R((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyt commitcheckscCsdG|jGdGHt|jj}|jsD|jj|jn|jj|j||}|rm|GHn|j|jj|j|j dS(Ns Checking ins...( RtopentreadRR.tlockR*tsetentrytheadR(RR+R>tmessages((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyR*s cCsX|jj|j}t|jd}|j||j|j|j|jdS(Ntw( R.RRRDR4tcloseRGR!R(RR>tf((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRs   cCs|jj|j|GHdS(N(R.tlogR(Rt otherflags((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRMscCsXd|_|j|_d\|_|_d|_d|_d|_d|_d|_dS(NiRi(ii( RRRR%R&R"RRR'(R((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytadds      cCsed|_||_tj|jd\|_|_||_d|_d|_ d|_d|_ dS(NiiiR( RRR#R$RR%R&R"RRR'(RR"R((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRGs  "    ( t__name__t __module__RR)R,RBRCR*RRMRORG(((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyR.s I      s/usr/lib/sendmail -tsoTo: %s Subject: CVS changes: %s ...Message from rcvs... Committed files: %s Log message: %s tRCVScBsqeZeZdZdZddZddZdZdZ dZ dZ d Z d d Z RS( cCstj|dS(N(Rt__init__(R((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRSscCs+x$|j|dD]}|jqWdS(Ni(t whichentriesR)(Rtfileste((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyR)sRcCs|j|}|sdSd}x#|D]}|js&d}q&q&W|sTdGHdS|sitd}ng}x0|D](}|j|rv|j|jqvqvW|j||dS(Niiscorrect above errors firsts One-liner: (RTRCt raw_inputR,tappendRtmailinfo(RRUR+tlisttokRVt committed((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyR,s"    cCsd}t|tj|tj||f}ddGH|GHddGHtd|}tjtj|d krtjtd}|j ||j }|rd t |GHqd GHnd GHdS( Nssjoerd@cwi.nl, jack@cwi.nlt-iFsOK to mail to %s? tytyetyesRJsSendmail exit status %ss Mail sent.s No mail sent.(R^R_R`( tMAILFORMtstringtjoinRWtlowertstripR#tpopentSENDMAILR4RKtstr(RRUR+ttowhomtmailtextR[tpRA((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRYs    cCs(x!|j|D]}|jqWdS(N(RTtreport(RRURV((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRl!scCs+x$|j|D]}|j|qWdS(N(RTRB(RRUR8RV((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRB%scCsC|stdng}x$|j|dD]}|jq+WdS(Ns!'cvs add' needs at least one filei(t RuntimeErrorRTRO(RRURZRV((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRO)s  cCs|stdntddS(Ns 'cvs rm' needs at least one files'cvs rm' not yet imlemented(Rm(RRU((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytrm0s cCsZd}x&|D]\}}|d||}q Wx$|j|D]}|j|q?WdS(NRR-(RTRM(RRUR8R9R;R<RV((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRM5s icCs|rkg}xE|D]Q}|jj|r;|j|}n|j|}||j|<|j|qWn|jj}xX|jjD]G}|jj|rqn|j|}||j|<|j|qW|rJxltjtj D]U}|jj| r|j | r|j|}||j|<|j|qqWn|j |jrx/|D]$}|jdkrd|j|_qdqdWn|S(N( tentriesthas_keyt FileClassRXtvaluesR.t listfilesR#tlistdirtcurdirtignoredtsorttNone(RRUt localfilestooRZRRV((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRT<s8       (RPRQRRqRSR)R,RYRlRBRORnRMRT(((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRRs         trcvscBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z e Ze Zd Zd ZeZeZdZdZeZeZdZdZeZdZdZRS(s d:h:p:qvLsMusage: rcvs [-d directory] [-h host] [-p port] [-q] [-v] [subcommand arg ...]s<If no subcommand is given, the status of all files is listedcCs&tj|d|_t|_dS(s Constructor.N(RRSRxR.RRtcvs(R((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRSes  cCs&|jr|jjnd|_dS(N(R.t_closeRx(R((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRKks cCs|jtjtj}x|D]}|tjks#|tjkrMq#n|dkr_q#ntjj|swq#ntjj|rq#ndG|GdGHtj|z3tjjdr|j j n |j WdtjtjdG|GdGHXq#WdS(NRs--- entering subdirectorys---s--- left subdirectory( RKR#RtRutpardirtpathtisdirtislinktchdirt __class__truntrecurse(RtnamesR7((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRps&     cCs ||_dS(N(R8(RR8((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytoptionsscCsEddl}|j|j|_|jj|j|jjdS(Ni(t rcsclientt openrcsclientR8R.R{tsetproxyt getentries(RR((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytreadys cCs|jjgdS(N(R{Rl(R((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytdefaultscCs|jj|dS(N(R{Rl(RR8RU((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyt do_reportscCst}x>|D]6\}}|dkr.d}n|dkr d}q q W|jj||jj| r| r|jndS(supdate [-l] [-R] [file] ...s-lis-RiN(t DEF_LOCALR{R)t putentriesR(RR8RUtlocalR;R<((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyt do_updates   s-lRcCsVd}x)|D]!\}}|dkr |}q q W|jj|||jjdS(scommit [-m message] [file] ...Rs-mN(R{R,R(RR8RUR+R;R<((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyt do_commits  sm:cCs|jj||dS(sdiff [difflags] [file] ...N(R{RB(RR8RU((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytdo_diffsscbitwcefhnlr:sD:S:cCs0|sdGHdS|jj||jjdS(s add file ...s%'rcvs add' requires at least one fileN(R{ROR(RR8RU((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytdo_adds cCs0|sdGHdS|jj||jjdS(sremove file ...s('rcvs remove' requires at least one fileN(R{R R(RR8RU((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyt do_removes cCs|jj||dS(slog [rlog-options] [file] ...N(R{RM(RR8RU((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytdo_logssbhLNRtd:s:V:r:(RPRQt GlobalFlagst UsageMessagetPostUsageMessageRSRKRRRRRRt flags_updatetdo_uptflags_upRt flags_committdo_comt flags_comRt flags_difftdo_dift flags_difRRtdo_rmRt flags_log(((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyRz]s6             cCs,ytj|Wntjk r'nXdS(N(R#tunlinkterror(R=((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyR scCs)t}z|jWd|jXdS(N(RzRRK(R ((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pytmains t__main__(t__doc__tcvslibRRR/R#RbtsystcmdfwRRRRgRaRRRzR RRP(((s'/usr/lib64/python2.7/Demo/pdist/rcvs.pyts       lp