o ö]LbœKã@sŒddlmZddlZddlZddlmZmZmZddlm Z m Z m Z m Z m Z ddlmZe jZdZGdd „d e jƒZGd d „d e jeƒZdS) é)Úabsolute_importN)ÚbinÚhexÚnullrev)ÚancestorÚcontextÚerrorÚphasesÚutilé)Ú shallowutilgà?csÊeZdZ     d)‡fdd„ Zdd„Zedd„ƒZd*dd „Zd d „Zed d „ƒZ dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zd+dd„Zdd„Zdd „Zd+d!d"„Zd#d$„Z‡fd%d&„Zd'd(„Z‡ZS),Ú remotefilectxNcsJ|tkr|j}|rt|ƒdkrt|ƒ}tt|ƒ ||||||¡||_dS)Né()rÚnullidÚlenrÚsuperr Ú__init__Ú _ancestormap)ÚselfÚrepoÚpathÚchangeidÚfileidÚfilelogÚ changectxÚ ancestormap©Ú __class__©úC/usr/lib/python3/dist-packages/hgext/remotefilelog/remotefilectx.pyrs   ÿ zremotefilectx.__init__cCs|j |j¡S©N)Ú_filelogÚsizeÚ _filenode©rrrrr".szremotefilectx.sizecCs`d|jvr|jSd|jvr|j ¡Sd|jvr,| |j|j|j|j¡}|j   ¡j  |¡S|  ¡S)NÚ _changeidÚ _changectxÚ_descendantrev) Ú__dict__r%r&ÚrevÚ_adjustlinknodeÚ_pathr!r#r'Ú_repoÚ unfilteredÚ changelogÚlinkrev)rÚlinknoderrrr%1s    ÿzremotefilectx._changeidcCst|j|j||j|dS)zMopens an arbitrary revision of the file without opening a new filelog)rrr)r r,r+r!)rrrrrrÚfilectxAsûzremotefilectx.filectxcCs|jSr )Ú_linkrevr$rrrr/Lszremotefilectx.linkrevc CsÈ|j|jjkr tS| ¡}||j\}}}}|jjj |¡}|dur$|S|j}|j}|j  ¡j} |jj } t t | ƒdddƒD]#}|   |¡} |  | ¡} || dvra|| | d ¡ |¡kra|Sq>dS)Nr réÿÿÿÿé)r#r,rrrr.ÚindexÚget_revr+r-Ú manifestlogÚrangerÚnodeÚreadÚreadfastÚget) rrÚp1Úp2r0Úcopyfromr)rrÚclÚmflr9Údatarrrr2Os*  ÿ €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.)rÚlkrÚattrsÚnoctxr0rrrÚintrorevos ûzremotefilectx.introrevc CsŽ| ¡}||j\}}}}|sdS||f}| ¡| ¡kr|S| ¡}|j}|j ¡D]} 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&ÚparentsÚfilenoderÚ LookupError) rrr=r>r0r?ÚrenamedÚnameÚfnodeÚprrrrM†s$ÿÿzremotefilectx.renamedcCs| ¡}|o |dS)Nr)rM)rÚcopyrrrÚ copysource¡s zremotefilectx.copysourcecCs|js | ¡ |j¡|_|jSr )rrrr#r$rrrr¥szremotefilectx.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?ÚresultsrÚflogÚp1ctxÚp2ctxrrrrJ«s*    ÿ     ÿ  zremotefilectx.parentsc CsH| |¡}|d|d}}||vr"||| ¡ |¡kr"| |¡SdS)zBreturns the node for in if content matches rr4N)r:r;r<r9) rÚancrevr@rArrOÚancctxÚ manifestnodeÚfilesrrrÚ_nodefromancrevÅs  zremotefilectx._nodefromancrevFcs0|j}| ¡j‰|j}| ¡}||d} |dur(dd„|jd ¡Dƒ} d}n|g} | | | ¡r3| Sd ‡fdd„| Dƒ¡t|ƒ|t   |j ¡t   |j ¡dœ} |j j d i| ¤Ž|j} d } ˆj| |d }|D]/}| |ˆ|||¡}|dury|S| s•|  ||¡tjkr•| |||| | ¡}|r“|Sd} qf| S)a…return 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)ÚrevsrOÚfilepathÚuserÚreponameó linkrevfixupóadjusting linknode FrC)rgrh)r,r-r.r7rrJÚ_verifylinknodeÚjoinrr Ú getusernameÚuiÚ getreponameÚlogÚ _phasecacheÚ ancestorsr]Úphaser ÚpublicÚ_forceprefetch)rrrrOÚsrcrevrDrrArr0rcÚcommonlogkwargsÚpcÚ seenpublicÚiterancrYÚlnoderrbrr*ÏsD     û ÿ€zremotefilectx._adjustlinknodec CsNd}t ¡}zˆzX|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) NóT)Úforcer^s#remotefilelog prefetching succeededrgó Úelapsediès#remotefilelog prefetching not founds%remotefilelog prefetching failed (%s)) ÚtimeÚ fileserviceÚprefetchrrrrirlrnÚ Exception) rrrrOrcruÚlogmsgÚstartr0r}Úerrrrssh*  þýüù þý üû  þý ü€û þýüzremotefilectx._forceprefetchcsF|sdSz|j ¡j‰t‡‡fdd„|DƒƒWStjy"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_Úr©r@r0rrÚ qs€ z0remotefilectx._verifylinknode..)r,r-r.ÚanyrrL)rrcr0rr‡rri`s  ûzremotefilectx._verifylinknodec csªg}t |f¡}tƒ}|r=| ¡}| ¡|vrq | | ¡¡| |¡| ¡}d}|D] }|s3|s8| |¡d}q-|s| d¡t|ddd„d}|D]} | VqMdS)NTFrcSs| ¡Sr )r/)ÚxrrrÚ‘sz)remotefilectx.ancestors..)ÚreverseÚkey) Ú collectionsÚdequeÚsetÚpoprKÚaddrTrJÚsorted) rÚ followfirstrpÚqueueÚseenÚcurrentrJÚfirstrPrrrrrpys,€    ó ÿ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<)rŠÚfÚnrP©ÚamapÚbmaprrrJ¦s  z'remotefilectx.ancestor..parents)rr)rrrKrÚgenericancestorr r,) rÚfc2ÚactxrJÚaÚbÚresultr™ršr†rr›rr–s"   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|jj dt|ƒ¡|r†|jj |¡tt|ƒj|i|¤ŽS)NÚ prefetchskip)rrrrs1remotefilelog: prefetching %d files for annotate )r‘rIr)r r,r+r#r!rrrŽrr’r9rKrTrrrJrlÚdebugrrr€rÚannotate) rÚargsÚkwargsÚintroctxr¤rIÚfetchr–r•r—Úparentrrrr¦¸sJ  ú      €õ ÿÿzremotefilectx.annotatecCsgSr rr$rrrÚchildrenäszremotefilectx.children)NNNNNr )F)Ú__name__Ú __module__Ú __qualname__rr"Ú propertycacher%r1r/r2rIrMrRrrJr]r*rsrirprr¦r¬Ú __classcell__rrrrr s6ø     LE  ",r cs.eZdZd‡fdd„ Zdd„Zdd„Z‡ZS) ÚremoteworkingfilectxNcs d|_tt|ƒ ||||¡dSr )rrr²r)rrrrÚ workingctxrrrrés ÿzremoteworkingfilectx.__init__cCs t |¡Sr )r rJr$rrrrJïs zremoteworkingfilectx.parentsc Cs.|js”|j}|jj}| ¡}|r|}n ||dj ||jj¡f}||jjf}t |ƒdkr9||dj ||jj¡f}i}|d|jjkr[|jj |d|dd}|  |  ¡  |d¡¡|d|jjkr{|jj |d|dd}|  |  ¡  |d¡¡d} |rƒ|d} |d|d|jj| f|d<||_|jS)Nrr )rrz)rr+r&Ú_parentsrMÚ _manifestr<r,rrr1Úupdaterr) rrÚpclrMr=r>ÚmrWrXr?rrrròs.  z remoteworkingfilectx.ancestormap)NN)r­r®r¯rrJrr±rrrrr²èsr²)Ú __future__rrŽr~Úmercurial.noderrrÚ mercurialrrrr r Úr r°ÚFASTLOG_TIMEOUT_IN_SECSr1r Úworkingfilectxr²rrrrÚs  Q