fec@sddlZddlZddlZddlZddlZddlZddlZddlZej dZ dZ e ddZdZedddd Zd Zed ded Zed dedZejdZeddedZeddedZeddedZeddedZdZedkrendS(iNtsrcdircCs"dj||dkrdndS(s7Return 'N file(s)' with the proper plurality on 'file'.s {} file{}itst(tformat(tcount((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt n_files_strscsfd}|S(s*Decorator to output status info to stdout.csfd}|S(Ncsotjjdtjj||} rF rFdGHn%rZ|GHn|rfdndGH|S(Ns ... tdonetyestNO(tsyststdouttwritetflush(targstkwargstresult(tfxntinfotmessagetmodal(s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytcall_fxns ((RR(RRR(Rs0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt decorated_fxns ((RRRR((RRRs0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytstatuss cCsxd}tj|jdtjdtj}z)|j\}}|jdkoT|SWd|jj|jjXdS(s*Check if there are any applied MQ patches.s hg qappliedR tstderriN( t subprocesstPopentsplittPIPEt communicatet returncodeR tcloseR(tcmdtsttbstdoutt_((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytmq_patches_applied's   s6Getting the list of files that have been added/changedRcCstt|S(N(Rtlen(tx((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt6scCstjjtjjtdrFd}d}trt|d7}qtn.tjjdrgd}d}n tjdtj |j d tj }zg|j |dkrg|j D]}|jj^qSd |j D}td |DSWd |j jXd S( s4Get the list of changed or added files from the VCS.s.hgthgs(hg status --added --modified --no-statuss --rev qparents.svntsvns7svn status --quiet --non-interactive --ignore-externalss%need a checkout to get modified filesR cssA|]7}|ddkr|jjjdddVqdS(itAMiiN(tdecodetrstriptrsplittNone(t.0R%((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pys Jscss'|]}tjj|r|VqdS(N(tostpathtisfile(R.R0((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pys LsN(R/R0tisdirtjointSRCDIRR#R texitRRRRtwaitR R*R+tsetR(tvcsRR R%toutput((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt changed_files5s$!     & cCsrt|}|dkr"t|Sdjt|g}x$|D]}|jdj|qAWdj|SdS(Nis{}:s {}s (R$RRtappendR3(t file_pathsRtlinesR0((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytreport_modified_filesQs    sFixing whitespacecCs\tt_g}xFd|DD]4}tjtjjt|r |j|q q W|S(sAMake sure that the whitespace for .py files have been normalized.css$|]}|jdr|VqdS(s.pyN(tendswith(R.R%((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pys as( tFalsetreindentt makebackuptcheckR/R0R3R4R;(R<tfixedR0((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytnormalize_whitespace\s  sFixing C file whitespacecCsg}xv|D]n}tjjt|}t|d}d|jkrRw nWdQXtj|ddt|j |q W|S(sReport if any C files trs Nitverbose( R/R0R3R4topentreadtuntabifytprocessR@R;(R<RDR0tabspathtf((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytnormalize_c_whitespacegs  s \s+(\r?\n)$sFixing docs whitespacec Csg}x|D]}tjjt|}yt|d}|j}WdQXg|D]}tjd|^qV}||krtj ||dt|d}|j |WdQX|j |nWq t k r}d||fGHq Xq W|S(Ntrbs\1s.baktwbsCannot fix %s: %s( R/R0R3R4RHt readlinestws_retsubtshutiltcopyfilet writelinesR;t Exception( R<RDR0RLRMR=tlinet new_linesterr((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytnormalize_docs_whitespacews % s Docs modifiedRcCs t|S(s9Report if any file in the Doc directory has been changed.(tbool(R<((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt docs_modifiedssMisc/ACKS updatedcCs d|kS(s$Check if Misc/ACKS has been changed.s Misc/ACKS((R<((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt credit_givenssMisc/NEWS updatedcCs d|kS(s$Check if Misc/NEWS has been changed.s Misc/NEWS((R<((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt reported_newsscCst}g|D]}|jdr|^q}g|D]}|jd r8|^q8}g|D]}|jdr`|^q`}ddht|@}t|t|t|t|t|t ||s|r|rdnd}Hd |GHndS( Ns.pys.cs.htDocs Misc/ACKSs Misc/NEWSs and check for refleaks?t?sDid you run the test suite(s.cs.h( R:R?t startswithR7RERNR[R]R^R_(R<tfnt python_filestc_filest doc_filest special_filestend((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytmains (((       t__main__(treR RTtos.pathR/Rt sysconfigRARJtget_config_varR4RR@R-RR#R:R>RERNtcompileRRR[tTrueR]R^R_Rit__name__(((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyts0