o ]LbK@sddlmZddlZddlZddlmZmZmZddlm Z m Z m Z m Z m Z ddlmZe jZdZGdd d e jZGd d d e jeZdS) )absolute_importN)binhexnullrev)ancestorcontexterrorphasesutil) shallowutilg?cseZdZ     d)fdd ZddZeddZd*dd Zd d Zed d Z ddZ ddZ ddZ ddZ ddZddZd+ddZddZdd Zd+d!d"Zd#d$Zfd%d&Zd'd(ZZS), remotefilectxNcsJ|tkr|j}|rt|dkrt|}tt|||||||||_dS)N()rnullidlenrsuperr __init__ _ancestormap)selfrepopathchangeidfileidfilelog changectx ancestormap __class__C/usr/lib/python3/dist-packages/hgext/remotefilelog/remotefilectx.pyrs    zremotefilectx.__init__cCs|j|jSN)_filelogsize _filenoderrrrr".szremotefilectx.sizecCs`d|jvr|jSd|jvr|jSd|jvr,||j|j|j|j}|j j |S| S)N _changeid _changectx_descendantrev) __dict__r%r&rev_adjustlinknode_pathr!r#r'_repo unfiltered changeloglinkrev)rlinknoderrrr%1s    zremotefilectx._changeidcCst|j|j||j|dS)zMopens an arbitrary revision of the file without opening a new filelog)rrr)r r,r+r!)rrrrrrfilectxAszremotefilectx.filectxcCs|jSr )_linkrevr$rrrr/Lszremotefilectx.linkrevc Cs|j|jjkr tS|}||j\}}}}|jjj|}|dur$|S|j}|j}|j j} |jj } t t | dddD]#}| |} | | } || dvra|| | d|kra|Sq>dS)Nr r)r#r,rrrr.indexget_revr+r- manifestlograngernodereadreadfastget) rrp1p2r0copyfromr)rrclmflr9datarrrr2Os*   zremotefilectx._linkrevcCsb|}t|}d|vpd|v }|s||kr|S|j|j|j|j|dd}|jj|S)areturn the rev of the changeset which introduced this file revision This method is different from linkrev because it take into account the changeset the filectx was created from. It ensures the returned revision is one of its ancestors. This prevents bugs from 'linkrev-shadowing' when a file revision is used by multiple changesets. r%r&T inclusive) r/varsr)r*r+r!r#r,r.)rlkrattrsnoctxr0rrrintrorevos zremotefilectx.introrevc Cs|}||j\}}}}|sdS||f}||kr|S|}|j}|jD]} z || |kr9WdSWq+tj yDYq+w|S)a#check if file was actually renamed in this changeset revision If rename logged in file revision, we report copy for changeset only if file revisions linkrev points back to the changeset in question or both changeset parents contain different file revisions. N) rr#r)r/rr&parentsfilenoder LookupError) rrr=r>r0r?renamednamefnodeprrrrMs$zremotefilectx.renamedcCs|}|o |dS)Nr)rM)rcopyrrr copysources zremotefilectx.copysourcecCs|js ||j|_|jSr )rrrr#r$rrrrszremotefilectx.ancestormapc Cs|j}|}||j\}}}}g}||jkr4|p|j}||} t|||| |d} || _| | ||jkrT|j}||} t|||| |d} || _| | |S)N)rrr) r,rr#rr+filer r)r'append) rrrr=r>r0r?resultsrflogp1ctxp2ctxrrrrJs*           zremotefilectx.parentsc CsH||}|d|d}}||vr"||||kr"||SdS)zBreturns the node for in if content matches rr4N)r:r;r<r9) rancrevr@rArrOancctx manifestnodefilesrrr_nodefromancrevs  zremotefilectx._nodefromancrevFcs0|j}|j|j}|}||d} |dur(dd|jdD} d}n|g} || | r3| Sdfdd| Dt||t |j t |j d} |j j d i| |j} d } j| |d }|D]/}|||||}|dury|S| s| ||tjkr||||| | }|r|Sd} qf| S)areturn the first ancestor of introducing If the linkrev of the file revision does not point to an ancestor of srcrev, we'll walk down the ancestors until we find one introducing this file revision. :repo: a localrepository object (used to access changelog and manifest) :path: the file path :fnode: the nodeid of the file revision :filelog: the filelog of this path :srcrev: the changeset revision we search ancestors from :inclusive: if true, the src revision will also be checked Note: This is based on adjustlinkrev in core, but it's quite different. adjustlinkrev depends on the fact that the linkrev is the bottom most node, and uses that as a stopping point for the ancestor traversal. We can't do that here because the linknode is not guaranteed to be the bottom most one. In our code here, we actually know what a bunch of potential ancestor linknodes are, so instead of stopping the cheap-ancestor-traversal when we get to a linkrev, we stop when we see any of the known linknodes. NcSsg|]}|qSr)r)).0rPrrr sz1remotefilectx._adjustlinknode..T csg|] }t|qSr)rr9)r_r)r@rrr`s)revsrOfilepathuserreponame linkrevfixupadjusting linknode FrC)rgrh)r,r-r.r7rrJ_verifylinknodejoinrr getusernameui getreponamelog _phasecache ancestorsr]phaser public_forceprefetch)rrrrOsrcrevrDrrArr0rccommonlogkwargspc seenpubliciterancrYlnoderrbrr*sD      zremotefilectx._adjustlinknodec CsNd}t}zzX|jj|t|fgddd|_||d}|||rCd}|WWt|} |jjd|dfd| d i|Sd }WWt|} |jjd|dfd| d i|dSt y} z#d | }WYd} ~ Wt|} |jjd|dfd| d i|dSd} ~ wwt|} |jjd|dfd| d i|w) NT)forcer^s#remotefilelog prefetching succeededrg elapsedis#remotefilelog prefetching not founds%remotefilelog prefetching failed (%s)) time fileserviceprefetchrrrrirlrn Exception) rrrrOrcrulogmsgstartr0r}errrrssh*        zremotefilectx._forceprefetchcsF|sdSz|jjtfdd|DWStjy"YdSw)a Check if a linknode is correct one for the current history. That is, return True if the linkrev is the ancestor of any of the passed in revs, otherwise return False. `revs` is a list that usually has one element -- usually the wdir parent or the user-passed rev we're looking back from. It may contain two revs when there is a merge going on, or zero revs when a root node with no parents is being created. Fc3s"|] }|VqdSr ) isancestorr9)r_rr@r0rr qs z0remotefilectx._verifylinknode..)r,r-r.anyrrL)rrcr0rrrri`s  zremotefilectx._verifylinknodec csg}t|f}t}|r=|}||vrq |||||}d}|D] }|s3|s8||d}q-|s|dt|dddd}|D]} | VqMdS)NTFrcSs|Sr )r/)xrrrsz)remotefilectx.ancestors..)reversekey) collectionsdequesetpoprKaddrTrJsorted) r followfirstrpqueueseencurrentrJfirstrPrrrrrpys,     zremotefilectx.ancestorsc s||kr||vr||S||vr&||vr&||S||vr8||vr8||S||fdd}||f}||f}t|||}|ro|\}}t|j||d} | SdS)NcsD|\}}|p |}|sgS|dp||df||dfgS)Nr4rr )r<)rfnrPamapbmaprrrJs  z'remotefilectx.ancestor..parents)rr)rrrKrgenericancestorr r,) rfc2actxrJabresultrrrrrrrs"   zremotefilectx.ancestorc s"|}|dd}|r#|}||kr#t|j|j||j|j|jd}g}t }t |f}| | |rr|} | |krP|| t| f|rW| |vrWq5| D]} | |vro| | || q[|s7|jjdt||r|jj|tt|j|i|S)N prefetchskip)rrrrs1remotefilelog: prefetching %d files for annotate )rrIr)r r,r+r#r!rrrrrr9rKrTrrrJrldebugrrrrannotate) rargskwargsintroctxrrIfetchrrrparentrrrrsJ         zremotefilectx.annotatecCsgSr rr$rrrchildrenszremotefilectx.children)NNNNNr )F)__name__ __module__ __qualname__rr" propertycacher%r1r/r2rIrMrRrrJr]r*rsrirprrr __classcell__rrrrr s6     LE  ",r cs.eZdZdfdd ZddZddZZS) remoteworkingfilectxNcs d|_tt|||||dSr )rrrr)rrrr workingctxrrrrs zremoteworkingfilectx.__init__cCs t|Sr )r rJr$rrrrJs zremoteworkingfilectx.parentsc Cs.|js|j}|jj}|}|r|}n ||dj||jjf}||jjf}t |dkr9||dj||jjf}i}|d|jjkr[|jj |d|dd}| | |d|d|jjkr{|jj |d|dd}| | |dd} |r|d} |d|d|jj| f|d<||_|jS)Nrr )rrz)rr+r&_parentsrM _manifestr<r,rrr1updaterr) rrpclrMr=r>mrWrXr?rrrrs.  z remoteworkingfilectx.ancestormap)NN)rrrrrJrrrrrrrsr) __future__rrr~mercurial.noderrr mercurialrrrr r r rFASTLOG_TIMEOUT_IN_SECSr1r workingfilectxrrrrrs  Q