o ]Lb7W@sddlmZddlZddlmZddlmZddlmZddl m Z m Z m Z m Z dZdZddd Zd d Zed Zed ZedZedZGdddeZdS))absolute_importN)_)short) stringutil)errorpycompatrevlogutilcCs>|t||}|WdS1swYdSN)lockverifierverify)repolevelvr2/usr/lib/python3/dist-packages/mercurial/verify.pyrs  $rcCs d|vr|dd}d|vs|S)Ns///)replace)frrr _normpath!s rsChint: run "hg debugrebuildfncache" to recover from corrupt fncache s7parent-directory manifest refers to unknown revision %ss1warning: copy source of '%s' not in parents of %ss5warning: %s@%s: copy source revision is nullid %s:%s c@sneZdZdddZddZdddZddd Zd d Zd d ZddZ ddZ dddZ ddZ ddZ dS)r NcCs||_|j|_||_|durt}||_t|_d|_ d|_ t |j dk|_ t |jddk|_|j jtjk|_t|j|_d|_d|_|jdd|_d|_dS)NrFsverify skipflagsT) unfilteredrui narrowmatchmatchVERIFY_DEFAULT_levelsetbadrevserrorswarningslen changeloghavecl manifestlog getstoragehavemf_format_versionr REVLOGV0revlogv1r lrucachefunc __getitem__ lrugetctxrefersmf fncachewarned configint skipflagswarnorphanstorefiles)selfrrrrr__init__;s"   zverifier.__init__cCs"|j|d|jd7_dS)zrecord a "warning" level issue rN)rwarnr#)r5msgrrr_warnOszverifier._warncCsd|dur|j|d|}nd}d||f}|rd||f}|jd|d|jd7_dS) zrecord a "error" level issueNs%d?%s: %ss%s@%s r7r)r!addrr8r")r5linkrevr9filenamerrr_errTs    z verifier._errcCs2t|}|s t|}||d||f|dS)z1record exception raised during the verify processr<N)r forcebytestrrbytereprrA)r5r?r9instr@fmsgrrr_excas  z verifier._exccCst|s|js |jr||td|dS|}|dr+|dtd|d||dr<|dtd|d||jtjkrR|j sP| td|dSdS|j r`| td|dSdS) zverify high level property of a revlog - revlog is present, - revlog is non-empty, - sizes (index and data) are correct, - revlog's format version is correct. empty or missing %sNrsdata length off by %d bytesrsindex contains %d extra bytess"warning: `%s' uses revlog format 1s"warning: `%s' uses revlog format 0) r$r&r)rAr checksizer*r r+r,r:)r5objnamer?drrr _checkrevloghs zverifier._checkrevlogc Cs|||}|dks|jrv||vrv|dks|t|jjkr$td}ntd}|d|||f||rt|r`t|dkr`zg}|D]}||| |krT| |qBWn t y_Ynwtd}|d t tj|;}||d}zC||\} } | |vr| |jjkrtdt| t|f}||||| |vr| |jjkrtd t| t|f}||||Wn t y} z||td t|| |WYd} ~ nd} ~ ww||vr||td |||f||||<|S) a verify a single revlog entry arguments are: - obj: the source revlog - i: the revision number - node: the revision node id - seen: nodes previously seen for this revlog - linkrevs: [changelog-revisions] introducing "node" - f: string label ("changelog", "manifest", or filename) Performs the following checks: - linkrev points to an existing changelog revision, - linkrev points to a changelog revision that introduces this revision, - linkrev points to the lowest of these changesets, - both parents exist in the revlog, - the revision is not duplicated. Return the linkrev of the revision (or None for changelog's revisions). rs)rev %d points to nonexistent changeset %ds(rev %d points to unexpected changeset %dNrs (expected %s)r=sunknown parent 1 %s of %ssunknown parent 2 %s of %sschecking parents of %ssduplicate revision %d (%d))r?revr&r$rr%rrAr/filenodeappend Exceptionjoinmaprbytestrr:parentsnullidrrF) r5rIinodeseenlinkrevsrlrr9p1p2rDrrr _checkentrysN    (zverifier._checkentryc Cs4|j}|j}|dsttdtj | dr$| td|j s*|j s8|td|j r4dp5d|\}}||}~||||||\}}|tdt|j||f|jrn| td |j|jrv| t|jr| td |j|jrtd }|t|j;}| |dSdS) zverify the content of the Mercurial repository This method run all verifications, displaying issues as they are found. return 1 if any error have been encountered, 0 otherwise.sfile:s$cannot verify bundle or remote repossjournals-abandoned transaction found - run hg recover s!repository uses revlog format %d rrs2checked %d changesets with %d changes to %d files s%d warnings encountered! s!%d integrity errors encountered! s+(first damaged changeset appears to be %d) )rrurl startswithrAbortrospathexistssjoinr8verboser,status_verifychangelog_verifymanifest_crosscheckfiles _verifyfilesr$r%r#r1 HINT_FNCACHEr"r!min) r5rr mflinkrevs filelinkrevs filenodes totalfiles filerevisionsr9rrrrsD       zverifier.verifyc CsJ|j}|j}|j}|j}|tdi}i}i}||dd|jtdtdt|d}|D]l} | | | | } | || | || gdz3| | } | d|jj krc|| dg| d|_| dD]} || rx|t| g| qgWq0ty} zd|_|| td t| | WYd } ~ q0d } ~ ww|||fS) aIverify the changelog of a repository The following checks are performed: - all of `_checkrevlog` checks, - all of `_checkentry` checks (for each revisions), - each revision can be read. The function returns some of the data observed in the changesets as a (mflinkrevs, filelinkrevs) tuples: - mflinkrevs: is a { manifest-node -> [changelog-rev] } mapping - filelinkrevs: is a { file-path -> [changelog-rev] } mapping If a matcher was specified, filelinkrevs will only contains matched files. schecking changesets s changelogrcheckings changesetsunittotalTsunpacking changeset %sN)rrrr%rfrrL makeprogressr$updaterWr]readrU setdefaultrOr0rrPrFrcomplete)r5rrrclrmrnrXprogressrVnchangesrrDrrrrgsB    &zverifier._verifychangelogrc' sh|j}|j}|j}|jj}||} |s|jtdi} i} i} d} |r7|} | }|||r7| |j rB| | j | d|j tdtdt| d}| D]}|s[||| |}|| ||| |g| }|vrv|=n|rtdt|}|||| n ||tdt|| zW|||jd d }|D]F\}}}|s||td n|d krq|t|}|d kr||sq| |di}||g|q||sq| |i||qWn!ty }z||tdt||| WYd}~nd}~ww|jtkrBz |||}WqRtyA}ztdt|}||||| WYd}~qRd}~wwqR|sJ| |j!rfddD}t"|D]&\}}|ro||t#t|| q[td}|t|;}|||| q[|s| r|jtdt$}t$}|j%}g} |j&j'| dD]$\}!}}"|"dks|s|(dr|)t||)t*j+,|q| D] }|dtd|q|j tdtdt|d}t-.| D]!\}#}$|/|$|#||}%t-.|%D]\}}&| |i|&qq|s2| r2|dusJ| |j0r2t"|D] }|1td|q%| S)averify the manifestlog content Inputs: - mflinkrevs: a {manifest-node -> [changelog-revisions]} mapping - dir: a subdirectory to check (for tree manifest repo) - storefiles: set of currently "orphan" files. - subdirprogress: a progress object This function checks: * all of `_checkrevlog` checks (for all manifest related revlogs) * all of `_checkentry` checks (for all manifest related revisions) * nodes for subdirectory exists in the sub-directory manifest * each manifest entries have a file path * each manifest node refered in mflinkrevs exist in the manifest log If tree manifest is in use and a matchers is specified, only the sub-directories matching it will be verified. return a two level mapping: {"path" -> { filenode -> changelog-revision}} This mapping primarily contains entries for every files in the repository. In addition, when tree-manifest is used, it also contains sub-directory entries. If a matcher is provided, only matching paths will be included. schecking manifests smanifestrrrs manifestsrss#%s not in parent-directory manifests%s not in changesetsT)shallowsentry without name in manifests /dev/nulltrsreading delta %sNsreading full manifest %scs"g|] }|D]}||fqqSrr).0mcrmrr s"z,verifier._verifymanifest..s'changeset refers to unknown revision %sschecking directory manifests  undecodablesmeta/cannot decode filename '%s'warning: orphan data file '%s')2rrrr'r(rfrfilesdifference_update incrementr0rL_revlogrwr$rxrWr]getrrA readdelta iterentriesrvisitdirrzrOrPrFr VERIFY_FULLryr{r)sortedWARN_PARENT_DIR_UNKNOWN_REVr r,store datafilesr_r>rarbdirnamer iteritemsrhr4r:)'r5rmdir storefilessubdirprogressrrrmflmfro subdirnodesrXlabel revlogfilesr}rVr~rZr9mfdeltarfnflfullpathsdnrDchangesetpairsrrsubdirsr,rtsizesubdirrYsubdirfilenodes onefilenodesrrrrhs      (      zverifier._verifymanifestc s|j}|j}|tdt|t|}|jtdtd|d}|jrBt|D]}|||vrA||d}| |td|q(|j r}t|D]3}|||vr|z| |t fdd||D}Wn t yrd}Ynw| |td |qI|dS) Ns0crosschecking files in changesets and manifests s crosscheckingfilesrsrs in changeset but not in manifestcsg|] }|qSr)r?rM)rr~rrrrsz-verifier._crosscheckfiles..s in manifest but not in changeset)rrrfrr$rwr)rrrAr&filerlrPr{) r5rnrorrrur}rrZrrrris6      zverifier._crosscheckfilesc# s|j}|j}|j}|j}|j}|tdt}g} |jj | dD]\} } } | dks-|s9| dr9| t | q"| D] } | dtd| q<|jjj|j|dddkd } tt|t|B}d}|jtd td t|d }t|D]\}} |j|| d z|| }Wn tyg}Ynw|r|d}nd}z|| }Wntjy}z| |td|| WYd}~qwd}~ww|D]#}z||Wqty|jrtd}|||d|_Yqwt|s|j s|jr| |td| nNt| d<t| d<|!| D]>}|j"dur$|#|$|j"}nd}|j%r2||j%q|jrI|dur=|n|}| ||j| qt&d|j'i}|D]}|d7}|"|}|(|||||| }| |vr|r||| vr| |tdt)|| n|| |=|| dvr|| dvrqUzw|*|r|dur|j+r||}t,fdd|-Ds|t.| |f|d}t|std}| ||dt)df| n&d|jj/kr t0}|| |dt)df;}|1|n|$dWqUt2y5} z|3|tdt)|| | WYd} ~ qUd} ~ ww| |vr`ddt45|| D}!t|!D]\}}"td}| ||t)|"| qKqw|6|jrzt|D] } |td| qmt||fS)Nschecking files rrsdata/rscensorspolicysabort)sexpectedversionrserroroncensoredrrrrs)itemsbroken revlog! (%s)s% warning: revlog '%s' not in fncache!TrGsskipreads safe_renameds<problem instance does not set warning or error attribute: %srs%s not in manifestsc3s|] }d|vVqdS)rNr)rpctxrprr /sz(verifier._verifyfiles..s)empty or missing copy source revlog %s:%sschecking rename of %scSsg|]\}}||fqSrr)rkrrrrrBsz)verifier._verifyfiles..s&manifest refers to unknown revision %sr)7rrr/r,r)rfrr rrr_r>rrAr%r*r3configrrwr$ enumeraterxKeyErrorrr StorageErrorrremover4r:r1r&verifyintegrityrWr?rMwarningProgrammingErrorr9r]rrenamedreanyrTWARN_UNKNOWN_COPY_SOURCErUWARN_NULLID_COPY_SOURCEnoterPrFrrr{)#r5rornrrr/r,r)rrrrrstater revisionsr}rVrYrZreffr9problemr? linkrev_msgrXr~ctxfl2rrDfnsrWrrrrjs              $    zverifier._verifyfilesr )rNN)__name__ __module__ __qualname__r6r:rArFrLr]rrgrhrirjrrrrr :s   :.1  r r ) __future__rrai18nrrWrutilsrrrr r rrrrrkrrrobjectr rrrrs.