ó fc@sddlZddlZddlZddlZddlZddlZddlZddlZej j dddƒej j dddƒej j dddƒej j ddƒej j ddƒgZ ej d ƒZ d „Zedd „Zd „Zd „Zeddd„ƒd„ƒZeddd„ƒdd„ƒZd„Zeddeƒd„ƒZeddeƒd„ƒZejdƒZeddeƒd„ƒZeddeƒd„ƒZed deƒd!„ƒZed"deƒd#„ƒZd$„Z e!d%kre ƒndS(&iÿÿÿÿNtModulest_ctypestlibffit libffi_osxt libffi_msvctexpattzlibtsrcdircCs"dj||dkrdndƒS(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_strscs‡‡‡fd†}|S(s*Decorator to output status info to stdout.cs‡‡‡‡fd†}|S(Ncsotjjˆdƒtjjƒˆ||Ž}ˆ 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|dtjƒSWntjk 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|dtjƒWntjk 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 cCstjjtjjtdƒƒs%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 csvtjjtjjtdƒƒr |r4d|}nd}g}tj|jƒdtjƒ}z›x”|j D]‰}|j ƒj ƒ}|jd dƒ\}‰t |ƒ}|jdƒs¼qkndˆkrçˆjddƒdjƒ‰n|jˆƒqkWWd |j jƒXn tjd ƒg}xO|D]G‰tjjˆƒ‰t‡fd †tDƒƒraq'n|jˆƒq'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_files‚s    sFixing whitespacecCs\tt_g}xFd„|DƒD]4}tjtjjt|ƒƒr |j|ƒq q W|S(sAMake sure that the whitespace for .py files have been normalized.css$|]}|jdƒr|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 whitespacecCsƒg}xv|D]n}tjjt|ƒ}t|dƒ}d|jƒkrRw 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_whitespace˜s  s \s+(\r?\n)$sFixing docs whitespacec Cs÷g}xê|D]â}tjjt|ƒ}y¢t|dƒ}|jƒ}WdQXg|D]}tjd|ƒ^qV}||krÉtj ||dƒt|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_whitespace¨s % 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_modified»ssMisc/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_givenÁss Misc/NEWS.d updated with `blurb`cCstd„|DƒƒS(s&Check if Misc/NEWS.d has been changed.css0|]&}|jtjjdddƒƒVqdS(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_newsÇs cCstƒ}t|ƒ}g|D]}|jdƒr|^q}g|D]}|jd ƒrD|^qD}g|D]*}|jdƒrl|jd ƒrl|^ql}d„|Dƒ}t|ƒt|ƒt|ƒt|ƒt|ƒt |ƒ|sô|r|rdnd }Hd |GHndS( Ns.pys.cs.htDocs.rsts.inccSs%h|]}|jdƒr|’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.pytmainÎs"  ((       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            )