a +b=@sddlmZddlZddlZddlmZddlmZddlm Z m Z m Z m Z m Z ddlmZddlmZdd lmZmZmZGd d d eZGd d d eZdS))absolute_importN)bin)_)ancestorerrormdiffpycompatrevlog) storageutil)flagutil) constantsfileserverclient shallowutilc@s$eZdZddZddZddZdS)remotefilelognodemapcCs||_||_dSN) _filename_store)selffilenamestorerG/usr/lib64/python3.9/site-packages/hgext/remotefilelog/remotefilelog.py__init__!szremotefilelognodemap.__init__cCs|j|j|fg}t| Sr)rZ getmissingrbool)rnodemissingrrr __contains__%sz!remotefilelognodemap.__contains__cCs||vrt||Sr)KeyErrorrrrrr__get__)szremotefilelognodemap.__get__N)__name__ __module__ __qualname__rrr rrrrr src@s:eZdZdZejZddZddZdFddZ d d Z dde j dfd d Z dGd dZddZddZeZddZddZeZddZddZddZddZdd Zd!d"Zd#d$Zd%d&ZdHd(d)Zd*d+Zd,d-Zd.d/Z d0d1Z!dId2d3Z"d4d5Z#d6d7Z$d8d9Z%d:d;Z&dd?Z(d@dAZ)dBdCZ*dDdEZ+dS)J remotefilelogTcCs8||_||_||_t|j|j|_d|_ttj |_ dS)Nr ) openerrrepor contentstorenodemapversiondictr ZflagprocessorsZ_flagprocessors)rr%pathr&rrrr4s zremotefilelog.__init__cCs4||}|ds|S|dd}||ddS)z&returns the file contents at this nodes N)revision startswithindex)rrtsrrrread>s    zremotefilelog.readNc Cs>t||d|d}t|||}|j||||||dS)Ncopycopyrev)r)rZcreaterevlogtextgetr hashrevisionsha1 addrevision) rtextmeta transactionlinknodep1p2ZhashtextrrrraddFs zremotefilelog.addcCstt||}d||f} |} d} |rDd|vrD|d} t|d} | d|| ||| f7} t} i} g}| |jjkr|}| rt|j| |j}| | | | | | | ||jjkr| | || || |d}|rz| d}| |\}}}}|p d}|d|||||f7}||jjkrP|| vrP| || |||jjkr|| vr| || |q| |7} | S)Ns%s%sr3r4s %s%s%s%s%sr)rZbuildfileblobheaderlenrsetr&nullidr$r%update ancestormapappendr>pop)rr8r9flagsr<r=rr;headerdataZrealp1copyfromZvisitedZ pancestorsqueueZp1flogZ ancestortextcZpa1Zpa2ZancestorlinknodeZ pacopyfromrrr_createfileblobPsT               zremotefilelog._createfileblobc  CsV|durt|||}t|\} } t|||\} } |j| |||||||| | fd S)N) _metatuple)r r6 parsemetar Zprocessflagswriteaddrawrevision)rr8r:r;r<r= cachedeltarrGsidedatar9 metaoffsetrawtextZ validatehashrrrr7s& zremotefilelog.addrevisionc  Csl| r| \} } nt|\} } |dkr(d} | r:|| d} n|} || | |||||} |jj|j|| |S)Nr)r rOrMr&r'Zaddremotefilelognoder)rrTr:r;r<r=rrGrQrNr9rSZblobtextrIrrrrPs  zremotefilelog.addrawrevisioncCs2|jj|j|}||\}}}}|r.||fSdSNFr& metadatastore getancestorsr)rr ancestorsr<r=r;rJrrrrenameds zremotefilelog.renamedcCst||S)z#return the size of a given revision)r@r2rrrrsizeszremotefilelog.sizecCs"||jjkrdS||}||kS)zpcompare text with a given file revision returns True if text is different than what is stored. T)r&rBr2)rrr8Znodetextrrrcmps  zremotefilelog.cmpcCsdS)NTrrrrr __nonzero__szremotefilelog.__nonzero__cCs|jdvrdStddS)N)s.hgtagss.hgsubs .hgsubstaterslen not supported)r RuntimeErrorr]rrr__len__s zremotefilelog.__len__cCsgSrrr]rrrheadsszremotefilelog.headscCsdSrUrr]rrremptyszremotefilelog.emptycCs4t|trtd|jj}||j|t j dS)Ns3remotefilelog does not accept integer rev for flagsr) isinstanceintrProgrammingErrorr&r'getmetarr5r METAKEYFLAG)rrrrrrrGs  zremotefilelog.flagscCsR||jjkr|jj|jjfS|jj|j|}||\}}}}|rJ|jj}||fSr)r&rBrWrXrrrrDr<r=r;rJrrrparentss zremotefilelog.parentscCs ||Sr)rirrevrrr parentrevsszremotefilelog.parentrevscCs&|jj|j|}||\}}}}|SrrVrhrrrr;szremotefilelog.linknodecCs|jj||Sr)r&Z unfilteredZ changelogrkr;rrrrlinkrev$szremotefilelog.linkrevFccs~~~~~d}|D]} || \} } |dur4| } }| | krD|jj} | |jjkrbd} || | }n|| } d}tj| | | || | || d| |ddd VqdS)Nr) rZp1nodeZp2noder;basenoderGZbaserevisionsizer-deltarRZprotocol_flags) rir&rBrevdiffrawdatar Zrevlogrevisiondeltar;rG)rZnodesZ nodesorderZ revisiondataZassumehaveparentrevisionsZ deltapreviousZ deltamodeZsidedata_helpersZprevnoderr<r=rnr-rorrr emitrevisions's6   zremotefilelog.emitrevisionscCst||||Sr)rZtextdiffrq)rZnode1Znode2rrrrpQszremotefilelog.revdiffcCs8t|dkrt|}t|dkr4t||jtd|S)N(sinvalid lookup input)r@rr LookupErrorrrrrrrlookupTs   zremotefilelog.lookupcCs|Srrrrrrrk^szremotefilelog.revcCst|trtd|S)Ns2remotefilelog does not convert integer rev to node)rcrdrrerjrrrrbs  zremotefilelog.nodecCs||jjkrdSt|dkr0t||jtd||jjjksL||jjj vrRtj |jj }| |j|}|rp|S| |j| tjd}|dkr|St|||dS)zreturns the revlog contents at this node. this includes the meta data traditionally included in file revlogs. this is generally only used for bundling and communicating with vanilla hg clients. r?rtsinvalid revision inputr)r&rBr@rrurrZ nodeconstantsZwdiridZwdirfilenodeidsZWdirUnsupportedr'r5rfr rgr Zprocessflagsread)rrrawrrTrGrrrr-js&     zremotefilelog.revisioncCs|j|ddS)NF)rw)r-rrrrrqszremotefilelog.rawdatacCs|jj}|j}t|jj|j|}z ||WSty@Yn0t |j|}t j |j |}z t|WSty~Yn0||j|fgz ||WStyYn0t||jtddS)z3reads the raw file blob from disk, cache, or serversno nodeN)r& fileservice localcacherZ getcachekeynamerr2rZ getlocalkeyosr+join localpathrZreadfileIOErrorZprefetchrrur)ridrxryZcachekeyZlocalkeyr}rrr_reads*       zremotefilelog._readcCs|jj|j|SrrVrrrrrDszremotefilelog.ancestormapcCsv||jjks||jjkr |jjS|||\}}ddt|D}t|||||}|rntt|j |S|jjS)NcSsi|]\}}||qSrr.0kvrrr r?z*remotefilelog.ancestor..) r&rB_buildrevgraphr iteritemsrrYminmap __getitem__rabrevmapZ parentfuncr(Zancsrrrrszremotefilelog.ancestorcCsf||jjks||jjkr |jjS|||\}}ddt|D}t|||||}t|j|S)z@calculate all the heads of the common ancestors of nodes a and bcSsi|]\}}||qSrrrrrrrr?z6remotefilelog.commonancestorsheads..) r&rBrrrrcommonancestorsheadsrrrrrrrs z"remotefilelog.commonancestorsheadscsR||}||}tt}t||fD]p}t|D]`\}}||} |\} } } } | |jjkrz| sz| |  | | |jjkr:| |  | q:q,tt}i}t fdd|D}|rH| \}}||vr|r|| ||qt |t |d}|||<|r&|| |||D]}|||fq0q||jfS)zBuilds a numeric revision graph for the given two nodes. Returns a node->rev map and a rev->[revs] parent function. c3s|]}|vrd|fVqdSrr)rnZ allparentsrr r?z/remotefilelog._buildrevgraph..r )rD collections defaultdictlistrArrr&rBrEr>dequerFr@r5 appendleftr)rrrZamapZbmapZ parentsmapmappingrZpdatarir<r=r;rJrlrrKZprevrevcurrentZ currentrevparentrrrrs@           zremotefilelog._buildrevgraphcCsdSrr)rZminlinkr:rrrstripszremotefilelog.stripcCsgSrrr]rrrfilesszremotefilelog.filescCsdS)N)rrrr]rrr checksizeszremotefilelog.checksize)NN)NN)NFFFNN)F),r!r"r#Z _generaldeltarZ RevlogErrorZ_flagserrorclassrr2r>rMr ZREVIDX_DEFAULT_FLAGSr7rPrZr[Zrawsizer\r^__bool__r`rarbrGrirlr;rmrrrprvrkrr-rqrrDrrrrrrrrrrr$/sb  @ + ,    *    1r$)Z __future__rrr{Zmercurial.noderZmercurial.i18nrZ mercurialrrrrr Zmercurial.utilsr Zmercurial.revlogutilsr r rrobjectrr$rrrrs