7ec@sddlZddlZddlZddlZddlZddlZddlZddlZej j dddej j dddej j dddej j ddej j ddgZ ej d Z d Zedd Zd Zd ZeddddZedddddZdZeddedZeddedZejdZeddedZeddedZed ded!Zed"ded#Zd$Z e!d%kre ndS(&iNtModulest_ctypestlibffit libffi_osxt libffi_msvctexpattzlibtsrcdircCs"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 cCsBdj}ytj|dtjSWntjk r=dSXdS(s0Get the symbolic name for the current git branchsgit rev-parse --abbrev-ref HEADtstderrN(tsplitt subprocesst check_outputtPIPEtCalledProcessErrortNone(tcmd((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytget_git_branch.s  cCsBdj}ytj|dtjWntjk r=dSXdS(skGet the remote name to use for upstream branches Uses "upstream" if it exists, "origin" otherwise sgit remote get-url upstreamRtorigintupstream(RR R!R"R#(R%((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytget_git_upstream_remote7s  sGetting base branch for PRRcCs|dk r|SdS(Nsnot a PR branch(R$(tx((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytER cCstjjtjjtds%dStj}|jdkrFd}ndj |}t }|dksv||krzdSt }|d|S(Ns.gittalphatmasters{0.major}.{0.minor}t/( tostpathtexiststjointSRCDIRR$Rt version_infot releaselevelR R&R)(tversiont base_brancht this_branchtupstream_remote((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytget_base_branchDs!    s6Getting the list of files that have been added/changedcCstt|S(N(R tlen(R*((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyR+XR csvtjjtjjtdr |r4d|}nd}g}tj|jdtj}zx|j D]}|j j }|jd d\}t |}|jdsqkndkrjdddjn|jqkWWd |j jXn tjd g}xO|D]Gtjjtfd tDraq'n|jq'W|S( s0Get the list of changed or added files from git.s.gitsgit diff --name-status sgit status --porcelainRitMAUs -> iNs)need a git checkout to get modified filesc3s|]}j|VqdS(N(t startswith(t.0R0(tfilename(s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pys zs(R/R0R1R2R3R tPopenRR"RtdecodetrstripR$tsett intersectiontstriptappendtcloseRtexittnormpathtanyt EXCLUDE_DIRS(R7R%t filenameststtlinet status_textRt filenames2((R?s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt changed_filesWs2!     cCsrt|}|dkr"t|Sdjt|g}x$|D]}|jdj|qAWdj|SdS(Nis{}:s {}s (R;R R RFR2(t file_pathsR tlinesR0((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytreport_modified_filess    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 s( tFalsetreindentt makebackuptcheckR/R0R2R3RF(RRtfixedR0((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytnormalize_whitespaces  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/R0R2R3topentreadtuntabifytprocessRVRF(RRRZR0tabspathtf((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytnormalize_c_whitespaces  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/R0R2R3R^t readlinestws_retsubtshutiltcopyfilet writelinesRFt Exception( RRRZR0RbRcRSRNt new_linesterr((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytnormalize_docs_whitespaces % s Docs modifiedRcCs t|S(s9Report if any file in the Doc directory has been changed.(tbool(RR((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt docs_modifiedssMisc/ACKS updatedcCstjjdd|kS(s$Check if Misc/ACKS has been changed.tMisctACKS(R/R0R2(RR((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt credit_givenss Misc/NEWS.d updated with `blurb`cCstd|DS(s&Check if Misc/NEWS.d has been changed.css0|]&}|jtjjdddVqdS(RssNEWS.dtnextN(R=R/R0R2(R>tp((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pys s(RJ(RR((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pyt reported_newss cCst}t|}g|D]}|jdr|^q}g|D]}|jd rD|^qD}g|D]*}|jdrl|jd rl|^ql}d|D}t|t|t|t|t|t ||s|r|rdnd }Hd |GHndS( Ns.pys.cs.htDocs.rsts.inccSs%h|]}|jdr|qS(Rs(R=(R>Rw((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pys s s and check for refleaks?t?sDid you run the test suite(s.cs.h(s.rsts.inc( R:RQRUR=R[RdRpRrRuRx(R7RRtfnt python_filestc_filest doc_filest misc_filestend((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytmains"  ((       t__main__("treRRjtos.pathR/R t sysconfigRWR`R0R2RKtget_config_varR3R RVR$RR&R)R:RQRTR[RdtcompileRhRptTrueRrRuRxRt__name__(((s0/usr/lib64/python2.7/Tools/scripts/patchcheck.pytsB            )