o ]LbW@sdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z m Z mZmZmZmZddlmZddlmZddlmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+dd l,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3dd l4m5Z5dd l6m7Z7m8Z8m9Z9m:Z:m;Z;mZmZ>dd l?m@Z@m>ZAdd l_eRdZ`eAae@jbe5jcddGdd d edZeeAae@jfe5jcdd!Gd"d#d#edZgd$d%Zhd&d'Zid(d)Zje>_eRd*rad+d,ZkndZkd-d.Zld/Zmed0ZnGd1ddedZodS)2zStorage back-end for Mercurial. This provides efficient delta storage with O(1) retrieve and append and O(changes) merge between branches. )absolute_importN)binhexnullrevsha1nodeconstantsshortwdirrev)_)getattr) ALL_KINDS CHANGELOGV2COMP_MODE_DEFAULTCOMP_MODE_INLINECOMP_MODE_PLAIN ENTRY_RANKFEATURES_BY_VERSIONFLAG_GENERALDELTAFLAG_INLINE_DATA INDEX_HEADERKIND_CHANGELOG RANK_UNKNOWNREVLOGV0REVLOGV1REVLOGV1_FLAGSREVLOGV2REVLOGV2_FLAGSREVLOG_DEFAULT_FLAGSREVLOG_DEFAULT_FORMATREVLOG_DEFAULT_VERSIONSUPPORTED_FLAGS)REVIDX_DEFAULT_FLAGSREVIDX_ELLIPSISREVIDX_EXTSTOREDREVIDX_FLAGS_ORDERREVIDX_HASCOPIESINFOREVIDX_ISCENSOREDREVIDX_RAWTEXT_CHANGING_FLAGS)attr) ancestordagoperrormdiffpolicypycompat revlogutilstemplatefiltersutil) repositoryr1)deltasdocketflagutilnodemaprandomaccessfilerevlogv0rewritesidedata) storageutil stringutilparsersr)r*revlogicC|dfSNFrltextrArA2/usr/lib/python3/dist-packages/mercurial/revlog.pyellipsisreadprocessorrFcCr?r@rArBrArArEellipsiswriteprocessorrGrHcCdSr@rArBrArArEellipsisrawprocessorsrJcCs$|r |d|dS||dS)z}Verify the integrity of the given revlog ``node`` while providing a hook point for extensions to influence the operation.skipreadN)addrevision)rC skipflagsstatenoderArArE_verify_revisionsrQBaseIndexObjectT)slotsc@sheZdZeZeZeZeZeZ eZ eZ eZ eZ eZejddZdS)revlogrevisiondeltaNdefault)__name__ __module__ __qualname__r(ibrPp1nodep2nodebasenodeflagsbaserevisionsizerMdeltar:protocol_flagslinknoderArArArErTsrT)frozenc@s0eZdZejddZejddZejddZdS) revlogproblemNrU)rWrXrYr(rZwarningr+rPrArArArErds  rdcCt||\}}||fSN)r= parse_index2datainlineindexcacherArArEparse_index_v1srncCtj||td\}}||fSN)format)r=rhrrirArArEparse_index_v2rrcCrorp)r=rhr rirArArEparse_index_cl_v2rsrtparse_index_devel_nodemapcCrfrg)r=rurirArArEparse_index_v1_nodemapsrvcCst||\}}t||fSrg)rn rustrevlog MixedIndexrirArArEparse_index_v1_mixedsryisNcannot read from revlog %s; expected %d bytes from offset %d, data size is %dc@s8eZdZdZejZ        dddZddZddd Z dd d Z e j d d Z e j ddZddZe j ddZe j ddZddZddZddZdddZejdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zdd,d-Zd.d/Zd0d1Z d2d3Z!d4d5Z"d6d7Z#d8d9Z$d:d;Z%dd?Z'd@dAZ(dBdCZ)dDdEZ*dFdGZ+dHdIZ,dJdKZ-dLdMZ.e.Z/dNdOZ0dPdQZ1dRdSZ2dTdUZ3dVdWZ4ddXdYZ5ddZd[Z6d\d]Z7dd^d_Z8dd`daZ9ddbdcZ:ddddeZ;ddfdgZdldmZ?ddndoZ@dpdqZAdrdsZBdtduZCdvdwZDdxdyZEddzd{ZFd|d}ZGd~dZHddZIddZJdddZKddZLdddZMdddZNdddZOddZPddZQddZRddZSdddZTdddZUdddZVdddZWddZXdddZYddZZdddZ[ddZ\ddZ]ejddZ^ejddZ_ddZ`ddeaddfddZb   dddZcddZdddZe   dddZfddZgddZh   dddZidd„ZjddĄZkddƄZlddȄZmddʄZndd̄Zodddepjqdfdd΄ZrdZsdZtdZudZvhdӣZwdetddfddՄZxddׄZydddڄZzdd܄Z{     dddބZ|ddZ}dS)r>ak the underlying revision storage object A revlog consists of two parts, an index and the revision data. The index is a file with a fixed record size containing information on each revision, including its nodeid (hash), the nodeids of its parents, the position and offset of its data within the data file, and the revision it's based on. Finally, each entry contains a linkrev entry that can serve as a pointer to external data. The revision data itself is a linear collection of data chunks. Each chunk represents a revision and is usually represented as a delta against the previous chunk. To bound lookup time, runs of deltas are limited to about 2 times the length of the original version data. This makes retrieval of a version proportional to its size, or O(1) relative to the number of revisions. Both pieces of the revlog are written to in an append-only fashion, which means we never need to rewrite a file to insert or remove data, and can use some simple techniques to avoid the need for locking while reading. If checkambig, indexfile is opened with checkambig=True at writing, to avoid file stat ambiguity. If mmaplargeindex is True, and an mmapindexthreshold is set, the index will be mmapped rather than read if it is larger than the configured threshold. If censorable is True, the revlog can have censored revisions. If `upperboundcomp` is not None, this is the expected maximal gain from compression for the data content. `concurrencychecker` is an optional function that receives 3 arguments: a file handle, a filename, and an expected position. It should check whether the current position in the file handle is valid, and log/warn/fail (by raising). See mercurial/revlogutils/contants.py for details about the content of an index entry. NFc Cs ||_||_d|_d|_d|_d|_d|_||_| |_||_ | r&t ||_|dt vs.Jt |dks6J||_||_||_||_d|_td|_d|_d|_d|_d|_d|_d|_d|_i|_d|_i|_d |_ d |_!d |_"d |_#d |_$d |_%t&t'j(|_)d|_*d|_+|,| |_-dS) aJ create a revlog object opener is a function that abstracts the file opening operation and can be used to implement COW semantics or the like. `target`: a (KIND, ID) tuple that identify the content stored in this revlog. It help the rest of the code to understand what the revlog is about without having to resort to heuristic and index filename analysis. Note: that this must be reliably be set by normal code, but that test, debug, or performance measurement code might not set this to accurate value. Nrd)riTszlibFg?i).upperboundcompradix _docket_file _indexfile _datafile _sidedatafile _nodemap_filepostfix _trypendingopener nodemaputilget_nodemap_filer lentarget _checkambig_mmaplargeindex _censorable_revisioncacher1 lrucachedict_chainbasecache _chunkcache_chunkcachesize _maxchainlen_deltabothparentsrl_docket_nodemap_docket_pcache _compengine_compengineopts_maxdeltachainspan_withsparseread _sparserevlog hassidedata_srdensitythreshold _srmingapsizedictr5flagprocessors_flagprocessors_writinghandles _adding_group _loadindex_concurrencychecker) selfrrrr checkambigmmaplargeindex censorabler~persistentnodemapconcurrencychecker trypendingrArArE__init__!sR    zrevlog.__init__cCs"d}|jj}d|vr|jtkrt}n#d|vrt}nd|vr*ttB}d|vr)|tO}n d|jjvr3t }nt }d|vr>|d|_ d|vrG|d|_ d |vrP|d |_ t|d d |_d |_|jrht|d d |_d|vrq|d|_d|vr||d|jd<d|vr|d|jd<d|vr|d|_|jrd|vr|d}t|dd |_t|dd }|jp||_d|vr|d|_d|vr|d|_|drt|jt<t|diD] \}}t |||jq|j dkrt!"t#d|j |j |j d@rt!"t#d|j |dd }|||fS)aprocess options (from above/config) to setup associated default revlog mode These values might be affected when actually reading on disk information. The relevant values are returned for use in _loadindex(). * newversionflags: version header to use if we need to create a new revlog * mmapindexthreshold: minimal index size for start to use mmap * force_nodemap: force the usage of a "development" version of the nodemap code Ns changelogv2srevlogv2srevlogv1 generaldeltasrevlogv0schunkcachesizes maxchainlensdeltabothparentss lazydeltaTFs lazydeltabases compengines zlib.levels zstd.levelsmaxdeltachainspansmmapindexthresholds sparse-revlogswith-sparse-readssparse-read-density-thresholdssparse-read-min-gap-sizesenableellipsissflagprocessorsrs0revlog chunk cache size %r is not greater than 0rs.revlog chunk cache size %r is not a power of 2sdevel-force-nodemap)$roptions revlog_kindrr rrrrrrrrrboolget _lazydelta_lazydeltabaserrrrrrrrellipsisprocessorrr"r. iteritemsr5insertflagprocessorr+ RevlogErrorr )rmmapindexthresholdopts new_headerwithsparsereadflag processor force_nodemaprArArE _init_optsysz                zrevlog._init_optsc Cs zk||[}|durD|j|j}||krD|durt||}|dur3tt|WdWStt||WdWS|durT|WdWS||WdWS1sdwYWdSty}z|j t j krzWYd}~dSd}~ww)zbreturn a file content with or without mmap If the file is missing return the empty stringNr|) rfstatst_sizeminr1buffermmapreadreadIOErrorerrnoENOENT)rfilepathmmap_thresholdsizefp file_sizeinstrArArE _get_datas.    ( zrevlog._get_datac Csj|\}}}|jdurd|j|jf}n|jr'|jd|jr'd|j}nd|j}|dur7||_||_nd}d|_| ||}t |dkrWt |ddd}d|_n|}|d @|_ |d @|_t|j}|dur~td } | |j|jf;} t| |j |@rtd } |j d ?} | | |j|jf;} t| t|j} | d|j |_| d|j |_| d|_| ds||_|} n||_|jrt|||_n tj|||jd|_|jdur|j|_d} |jj} | dkr|j |j|| d} t | | krtd} | |jt | | f;} t| d|_d|_d|_|jdur-|j |_!|j"|_#n|jdur:d|j|_!n d|j|jf|_!t$|_%|j%j&|_&|jsRd|_'d|_(|jo_|o_t)du}d}t*durw|jdurpd}n|jj+d}t,|_-|jt.krt/j0|_-n!|jt1krt2|_-n|jt3krt4|_-n |rt)|_-n|rt5|_-zN|-| |j}|\}}|j o|jduot67|d}|rt89|}|dur|d}t |d|j:kr|d|j:d|j;kr||_<|j=|Wnt>t?fyttd|jw||_@tAA|j|jr|jn|j!|jB||_CtAA|j|j#|jB|_Dt6Ed|_Fi|_GdS)Ns%s.i.%ss%s.i.as%s.ir|TrFis!unknown version (%d) in revlog %ss-unknown flags (%#04x) in version %d revlog %ssinlinerssidedatasdocket) use_pending)rs.too few index data for %s: got %d, expected %ds%s.ds%s.d.%ss rust.indexupdate_nodemap_datasindex %s is corrupted)Hrrrrrexistsrr _initemptyrrrunpack _format_flags_format_versionr rr display_idr+rr_inline _generaldeltarr docketutildefault_docket parse_docketindex_filepath index_endr data_filepathrsidedata_filepathrr nodeconstantsnullidr_storedeltachainsrvrwrrn _parse_indexrr8parse_index_v0rrrr rtryr1 safehasattrrpersisted_datatip_revtip_noderr ValueError IndexErrorrlr7r _segmentfile_segmentfile_sidedatar_chaininfocache_decompressors)rr4rrr entry_point entry_dataheadersupported_flagsmsg display_flagfeatures index_data index_size devel_nodemapuse_rust_indexdrl chunkcache use_nodemap nodemap_datarArArErs                                    zrevlog._loadindexcCs |jdSNr)rrrArArErs zrevlog.revlog_kindcCs|jS)z;The public facing "ID" of the revlog that we use in message)rrrArArErszrevlog.display_idc Csrz|j|}W|Sty8ztj|}||j}||j|<WY|Sty7tt dt |ww)Nsunknown compression type %s) rKeyErrorr1 compenginesforrevlogheaderrevlogcompressorrr+rr binasciihexlify)rt compressorenginerArArE_get_decompressors     zrevlog._get_decompressorcCstj|j}||jSrg)r1r rr r)rrrArArE _compressors  zrevlog._compressorcCs&|jdurdS|jj}||}|jS)zthe default decompressorN)rdefault_compression_headerr decompress)rrcrArArE _decompressors  zrevlog._decompressorcCs|j|jddS)z'file object for the revlog's index filermode)rrrrArArE_indexfpzrevlog._indexfpc Csz%|j|jd|jd}|jdur|dtj|WS||jjtj|WSt yH}z|j t j kr4|j|jd|jdWYd}~Sd}~ww)Nr+)rrrw+) rrrrseekosSEEK_ENDrSEEK_SETrrr)rfrrArArE__index_write_fps"    zrevlog.__index_write_fpcCs|j|jd|jddS)NwT)rr atomictemp)rrrrrArArE__index_new_fps zrevlog.__index_new_fprcCs|j|j|dS)z&file object for the revlog's data filer)rr)rrrArArE_datafprzrevlog._datafpccsP|jr |jdVdS||j }|VWddS1s!wYdS)z%file object suitable to read sidedatarzN)rrr)rrrArArE_sidedatareadfps "zrevlog._sidedatareadfpcCst|jdSNrrrlrrArArEtiprevz revlog.tiprevcCs||Srg)rPr,rrArArEtipr-z revlog.tipcCsd|ko t|kSSr)rrrevrArArE __contains__szrevlog.__contains__cCs t|jSrgr+rrArArE__len__s zrevlog.__len__cCsttt|Srg)iterr.xrangerrrArArE__iter__zrevlog.__iter__rcCstjt|||dS)z8iterate over all rev in this revlog (from start to stop)startstop)r;iterrevsr)rr8r9rArArErevssz revlog.revscCs&z||WdStyYdSw)NTF)r0r rrPrArArEhasnodes   zrevlog.hasnodecCs$||t@s||t@rdSdS)z;whether two revisions (baserev, rev) can be delta-ed or notFT)r^r')rbaserevr0rArArEcandeltas  zrevlog.candeltacCs4|jdur|durt|dSt||dSdSrg)rrupdate_persistent_nodemapsetup_persistent_nodemapr transactionrArArE update_cachess zrevlog.update_cachescCsd|_|j|j|ji|_d|_|j |j o,|j duo,t |jd}|rEt|}|durG|d|_|jj|dSdSdS)Nrr)rrclearr clear_cacherrrrl clearcachesrrr1rrrr)rrrrArArErGs&       zrevlog.clearcachesc Cs`z|j|WStytjy/||jjks"||jjvr%tjt ||j t dw)Nno node) rlr0 TypeErrorr+rrwdiridwdirfilenodeidsWdirUnsupported LookupErrorrr r<rArArEr0s   z revlog.revcCst|j|dd?S)Nrr)intrlr/rArArEr8*sz revlog.startcCs\|j|d}|dkr |Sd|kr,|j|}|ddkr$|d|dS|d8}d|ksdS)Nr rrl)rr0 sd_cut_offerArArEsidedata_cut_off-s  zrevlog.sidedata_cut_offcCs|j|dd@S)NrrrQr/rArArEr^>r6z revlog.flagscC|j|dSr*rQr/rArArElengthAr-z revlog.lengthcCs|jsdS|j|dS)NrrP)rrlr/rArArEsidedata_lengthDszrevlog.sidedata_lengthcCs,|j|d}|dkr |S||}t|S)z?return the length of the uncompressed text for a given revisionrzr)rlrawdatar)rr0lrrArArErawsizeIs  zrevlog.rawsizecCs4||}|tjtA@dkr||St||S)z=length of non-raw text (processed by a "read" flag processor)r)r^r5REVIDX_KNOWN_FLAGSr"rZrrM)rr0r^rArArErRs  z revlog.sizecCs|j|t}|tkr dS|S)aReturn the rank of a revision if already known, or None otherwise. The rank of a revision is the size of the sub-graph it defines as a head. Equivalently, the rank of a revision `r` is the size of the set `ancestors(r)`, `r` included. This method returns the rank retrieved from the revlog in constant time. It makes no attempt at computing unknown values for versions of the revlog which do not persist the rank. N)rlrr)rr0rankrArArE fast_rank\s zrevlog.fast_rankcCs\|j|}|dur |S|j}|}||d}||kr'|}||d}||ks||j|<|S)N)rrrl)rr0baserliterrevrArArE chainbasels    zrevlog.chainbasecCrU)NrrQr/rArArElinkrev{r-zrevlog.linkrevcCs>z|j|}Wnty|tkrtjw|d|dfS)Nrlrr r+rL)rr0entryrArArE parentrevs~s zrevlog.parentrevscCs0z|j|dWSty|tkrtjw)Nrrer/rArArErPs z revlog.nodecCs||||Srg)r8rVr/rArArEendz revlog.endcCs4|j}|||}||dd||ddfS)Nrcrrd)rlr0)rrPirrArArEparentss zrevlog.parentscCs||dSr) _chaininfor/rArArEchainlenr-zrevlog.chainlenc Cs|j}||vr ||S|j}|j}|}||}d}d}||dkrU|d7}||d7}|r2|d}n|d8}||vrK||} || d7}|| d7}n||}||dks!||d7}||f} | ||<| S)Nrr^r)rrlr) rr0chaininfocacherl generaldeltar`rSclencompresseddeltalenrrrArArErls4      zrevlog._chaininfoc Csz |j|||jWStyYnwg}|j}|j}|}||}||dkrJ||krJ|||r8|d}n|d8}||}||dkrJ||ks,||krQd}n||d}|||fS)aWObtain the delta chain for a revision. ``stoprev`` specifies a revision to stop at. If not specified, we stop at the base of the chain. Returns a 2-tuple of (chain, stopped) where ``chain`` is a list of revs in ascending order and ``stopped`` is a bool indicating whether ``stoprev`` was hit. r^rTF)rl deltachainrAttributeErrorappendreverse) rr0stoprevchainrlror`rSstoppedrArArE _deltachains.     zrevlog._deltachaincCsZt|}|j}|D]}||q tdur|jjrtj}|j}ntj}|j}|||||dS)zGenerate the ancestors of 'revs' in reverse revision order. Does not generate revs lower than stoprev. See the documentation for ancestor.lazyancestors for more details.N)rw inclusive) listrP rustancestorrlrust_ext_compat LazyAncestorsr) lazyancestors_uncheckedparentrevs)rr;rwr{checkrevrrrargrArArE ancestorss zrevlog.ancestorscCst||j|jSrg)r*descendantrevsr;rgrr;rArArE descendantsr6zrevlog.descendantscs|durjg}|dur}fdd|D}fdd|D}Gdddt}||t|t}t fdd|D}|rm| }||vrUqJ|| |D] }|vrj| |q_|sLt |}|fd d|DfS) aReturn a tuple of the ancestors of common and the ancestors of heads that are not ancestors of common. In revset terminology, we return the tuple: ::common, (::heads) - (::common) The list is sorted by revision number, meaning it is topologically sorted. 'heads' and 'common' are both lists of node IDs. If heads is not supplied, uses all of the revlog's heads. If common is not supplied, uses nullid.Ncg|]}|qSrAr0.0nrrArE z,revlog.findcommonmissing..crrArrrrArErrc@s4eZdZddZddZddZddZd d Zd S) z)revlog.findcommonmissing..lazysetcSst|_||_dSrg)set addedvalues lazyvalues)rrrArArErs z2revlog.findcommonmissing..lazyset.__init__cSs||jvp ||jvSrgrrrvaluerArArEr1riz6revlog.findcommonmissing..lazyset.__contains__css6|j}|D]}|Vq|jD] }||vr|VqdSrgr)raddedrrrArArEr5s z2revlog.findcommonmissing..lazyset.__iter__cS|j|dSrg)rrLrrArArErL&z-revlog.findcommonmissing..lazyset.addcSrrg)rupdate)rvaluesrArArEr)rz0revlog.findcommonmissing..lazyset.updateN)rWrXrYrr1r5rLrrArArArElazysets  rc3s|] }|vr|VqdSrgrArrr)hasrArE 2sz+revlog.findcommonmissing..crrArP)rmissrrArEr>r)rheadsobjectrrLrrr collectionsdequepopleftrgrur|sort)rcommonrrmissingvisitrrprA)rrrEfindcommonmissings2      zrevlog.findcommonmissingcCs:|durtg}tdur|jjrt|j|St|j|S)aOReturn an object that can be used to incrementally compute the revision numbers of the ancestors of arbitrary sets that are not ancestors of common. This is an ancestor.incrementalmissingancestors object. 'common' is a list of revision numbers. If common is not supplied, uses nullrev. N)rr}rlr~MissingAncestorsr)incrementalmissingancestorsrg)rrrArArEincrementalmissingrevs@s  zrevlog.incrementalmissingrevscCs4|durtg}|dur|}|j|d}||S)axReturn the revision numbers of the ancestors of heads that are not ancestors of common. More specifically, return a list of revision numbers corresponding to nodes N such that every N satisfies the following constraints: 1. N is an ancestor of some node in 'heads' 2. N is not an ancestor of any node in 'common' The list is sorted by revision number, meaning it is topologically sorted. 'heads' and 'common' are both lists of revision numbers. If heads is not supplied, uses all of the revlog's heads. If common is not supplied, uses nullid.Nr)rheadrevsrmissingancestorsrrrincrArArEfindmissingrevsPs   zrevlog.findmissingrevscsh|durjg}|dur}fdd|D}fdd|D}j|d}fdd||DS)a.Return the ancestors of heads that are not ancestors of common. More specifically, return a list of nodes N such that every N satisfies the following constraints: 1. N is an ancestor of some node in 'heads' 2. N is not an ancestor of any node in 'common' The list is sorted by revision number, meaning it is topologically sorted. 'heads' and 'common' are both lists of node IDs. If heads is not supplied, uses all of the revlog's heads. If common is not supplied, uses nullid.NcrrArrrrArEr|rz&revlog.findmissing..crrArrrrArEr}rrcrrArrrrArErr)rrrrrrArrE findmissinghs zrevlog.findmissingc s"gggf}|durt|}|s|Stfdd|D}njg}t}|tkr=|dur=fddDjgtfS|durLtd}di}nt|}|sT|Stt|d}t|}t fdd|D}|r| }|jkrxql |}||kr|vr || fdd|Dn ||vr| ||sns|S|tkrƇfd d|D}|rtfd d|D}n|St}jg}t|} | }g} jt |d |dd D]}|}d} |tkrd } nC|| vrd } ||vrt|} | d | vs| d| vr||nt|} | d | vs.| d| vr5| |d } | rndusB|vrn| |durV||vrVd ||<qdurnd ||<|D] } | | dqdqddt|D}t|}| sJ|sJ|sJ| ||fS)aReturn a topological path from 'roots' to 'heads'. Return a tuple (nodes, outroots, outheads) where 'nodes' is a topologically sorted list of all nodes N that satisfy both of these constraints: 1. N is a descendant of some node in 'roots' 2. N is an ancestor of some node in 'heads' Every node is considered to be both a descendant and an ancestor of itself, so every reachable node in 'roots' and 'heads' will be included in 'nodes'. 'outroots' is the list of reachable nodes in 'roots', i.e., the subset of 'roots' that is returned in 'nodes'. Likewise, 'outheads' is the subset of 'heads' that is also in 'nodes'. 'roots' and 'heads' are both lists of node IDs. If 'roots' is unspecified, uses nullid as the only root. If 'heads' is unspecified, uses list of all of the revlog's heads.NcrrArrrrArErrz'revlog.nodesbetween..crrArrrrArErrrFcrrArrrrArErrcsg|] }|jkr|qSrA)r)rrrrArErcsg|]}|vr|qSrArArroot)rrArErcrrArrrrArErrrr7TcSg|]\}}|r|qSrArA)rheadrrArArErr)r|rrrrrrrfromkeysmaxpopr0rLrrkcopyr;rPtupleremoverur.r) rrootsrnonodes lowestrev highestrev nodestotagrrrr orderedout isdescendantrrA)rrrE nodesbetweens                    zrevlog.nodesbetweencCs\|durz|jWSty|YSwtdur'|jjr't|j|St||jSrg)rlrrt _headrevs rustdagopr~r*rrrArArEr"s   zrevlog.headrevscCs |j|Srg)rlcomputephasesmapsets)rrrArArE computephases,s zrevlog.computephasescCsjt|}|s tgSdg|d}|j}|D]}d||<||}d||d<||d<qddt|DS)NrrrcrdcSrrArA)rrrvalrArArEr:rz$revlog._headrevs..)rrrl enumerate)rcountisheadrlrrrSrArArEr/szrevlog._headrevscs|dur|durtsjgSfddDS|dur"t}n|}fdd|p/gD}tjjj||d}fdd|DS)areturn the list of all nodes that have no children if start is specified, only heads that are descendants of start will be returned if stop is specified, it will consider all the revs from stop as if they had no children NcrrArrrrArErGrz revlog.heads..csh|]}|qSrArrrrArE Nrzrevlog.heads..)startrevstoprevscrrArrr0rrArErTr) rrrrr0r*headrevssubsetr;rg)rr8r9rr;rArrEr<s  z revlog.headscCs|g}||}|j|ddD],}dd||D}|r/|D]}||kr-|||qq|tkr;|||q|S)z!find the children of a given noder)r8cSsg|]}|tkr|qSrA)r)rprrArArEr[rz#revlog.children..)r0r;rgrurPr)rrPrrrrprevsrrArArEchildrenVs zrevlog.childrencCs0||||}}|||}t|j|S)z@calculate all the heads of the common ancestors of nodes a and b)r0_commonancestorsheadsr.maplistrPrabancsrArArEcommonancestorsheadsds zrevlog.commonancestorsheadsc Gs@z |jj|}W|Sttfytj|jg|R}Y|Sw)z7calculate all the heads of the common ancestors of revs)rlrrt OverflowErrorr)rg)rr;rrArArErjszrevlog._commonancestorsheadscCs"||||}}|||S)zgreturn True if node a is an ancestor of node b A revision is considered an ancestor of itself.)r0 isancestorrevrrrrArArE isancestorrs zrevlog.isancestorcCs>|tkrdS||kr dS||krdSt|j||g|gddS)zreturn True if revision a is an ancestor of revision b A revision is considered an ancestor of itself. The implementation of this is trivial but the use of reachableroots is not.TF) includepath)rrreachablerootsrrArArEryszrevlog.isancestorrevc Cs<z |j||||WStyt|j||||YSw)zlreturn (heads(::( and ::))) If includepath is True, return (::).)rlreachableroots2rtr*_reachablerootspurerg)rminrootrrrrArArErs  zrevlog.reachablerootsc Csj||||}}z |j||}Wnttfy't|j||}Ynw|r2tt|j |S|j S)z5calculate the "best" common ancestor of nodes a and b) r0rlrrtrr)rgrmaprPrrrArArEr)szrevlog.ancestorc Cst|tr ||St||jjkr'z |}|||WStjy&Ynwz(t|}d||kr4t |dkr>t||}|dksH|t|krJt ||WSt t fyZYnwt|d|jjkrz t |}|||WSt tjfy~YdSwdS)Ns%drrz) isinstancerNrPrrnodelenr0r+rMrrrrI)ridrPr0rArArE_matchs>       z revlog._matchc sjj}d}zj}|r|r|rd}n |WS|r$tjWdSWntjy:t dds8d}Yn t t fyDYnw|rQt j tdjvr[jStdkrz]td}td|dfddjD}fd d|D}jjr|jt|d krt|d kr|s|d j<|d WSt j td|rtjWdStyYdSwdS) NFT filteredrevssambiguous identifier(rzcs"g|] }|dr|dqS)r) startswith)rrSprefixrArErs"z(revlog._partialmatch..cs(g|]}t|r|r|qSrA)rrr=r)rrrArErsrr)rwdirhexrrl partialmatchr=r+rLrr rtrAmbiguousPrefixLookupErrorrr rrrnullhexrurrI)rr maybewdir ambiguouspartialrYnlrA)rrrrE _partialmatchsb             zrevlog._partialmatchcCs<||}|dur |S||}|r|St||jtd)z{locate a node based on: - revision number or str(revision number) - nodeid or subset of hex nodeid Nsno match found)rrr+rMrr )rrrrArArElookups  z revlog.lookuprc sfdd}ddt}fdd}tddsMztj|}|||WStjyDjjkrBt j t d Yn t yLYnwjjkrmt |t|d D]}|d|}||rl|Sq\t |t|d D]}|d|}||r|||SqvdS) z7Find the shortest unambiguous prefix that matches node.csZz|}WntjyYdStjyYdSw|dur+tjtddS)NFTrH)rr+rrLrMrr )r matchednode)rPrrArEisvalidsz revlog.shortest..isvalidcSstddt|DS)Ncss|]}|dkVqdS)fNrA)rrrArArErsz5revlog.shortest..maybewdir..)allr. iterbytestrrrArArErsz"revlog.shortest..maybewdircs8t|t|dD]}|d|}|s|Sq dS)zDisambiguate against wdirid.rN)ranger)hexnode minlengthrVr)rrArE disambiguate s  z%revlog.shortest..disambiguaterNrHr)rr rrlshortestr+rrrJrMrr rtrr)rrPrrrrrVrrA)rrPrrEr s:          zrevlog.shortestcCs ||\}}t||||kS)zpcompare text with a given file revision returns True if text is different than what is stored. )rkr;hashrevisionsha1)rrPrDp1p2rArArEcmp?sz revlog.cmpc Cs|j}||}t|dd?}||kr||d}n||}t|dd?|d}|jrA||d|jj7}||d|jj7}||} ||j|| |fS)aObtain a segment of raw data corresponding to a range of revisions. Accepts the start and end revisions and an optional already-open file handle to be used for reading. If the file handle is read, its seek position will not be preserved. Requests for data may be satisfied by a cache. Returns a 2-tuple of (offset, data) for the requested range of revisions. Offset is the integer offset from the beginning of the revlog and data is a str or buffer of the raw byte data. Callers will need to call ``self.start(rev)`` and ``self.length(rev)`` to determine where each revision's data begins and ends. rrr)rlrNr entry_sizer read_chunk) rrendrevdfrlistartr8rhiendrVrArArE_getsegmentforrevsGszrevlog._getsegmentforrevscCsh|j|d}|j|||dd}|tkr|S|tkr ||S|tkr)||Sd}||;}t|)a<Obtain a single decompressed chunk for a revision. Accepts an integer revision and an optional already-open file handle to be used for reading. If used, the seek position of the file will not be preserved. Returns a str holding uncompressed data for the requested revision. rrunknown compression mode %d) rlrrrrrrr+r)rr0rcompression_moderjrrArArE_chunkis    z revlog._chunkc sx|sgSj}j}j}jj}tj}g} | j} js |f} nt j ||d} | D]} | d} | dddD] }||dkrAnq7z j | |d\}}Wnt ycfdd| DYSwj }j}| D]L}||}|r|||d|7}||}j|d }|||||}|tkr| |ql|tkr| ||ql|tkr| ||qld }||;}t|q*| S) aObtain decompressed chunks for the specified revisions. Accepts an iterable of numeric revisions that are assumed to be in ascending order. Also accepts an optional already-open file handle to be used for reading. If used, the seek position of the file will not be preserved. This function is similar to calling ``self._chunk()`` multiple times, but is faster. Returns a list with decompressed data for each requested revision. ) targetsizerNr}rcsg|] }j|dqS)r)rrrrrArErrz"revlog._chunks..rrr)r8rVrrlr r1rrur deltautil slicechunkrrrrrrrr+r)rr;rrr8rVrkiosizerrYladd slicedchunks revschunkfirstrevlastrevoffsetrjdecomp def_decompr0 chunkstart chunklength comp_moderrrArrE_chunkssZ     zrevlog._chunkscCs,|j|d}||kr tS|jr|S|dS)z(return deltaparent of the given revisionr^r)rlrr)rr0r_rArArE deltaparents zrevlog.deltaparentcCs|js ||tkSt|jdr|jj|_||S|tkr!dS|j|}|d}||kr0dS|tkr6dS|d}|d}||ksF||krHdS||S)ztells whether rev is a snapshots issnapshotTr^rcrdF)rr(rr1rrl issnapshot)rr0rfr_rr rArArEr)s$    zrevlog.issnapshotcCs*||s tdt||ddS)z/number of snapshot in the chain before this onesrevision %d not a snapshotrr)r)r+ProgrammingErrorrrzr/rArArE snapshotdepths  zrevlog.snapshotdepthcCs<|tkr|||krt||St||||S)zreturn or calculate a delta between two revisions The delta calculated is in binary form and is intended to be written to revlog data directly. So this function needs raw revision data. )rr(bytesrr,textdiffrX)rrev1rev2rArArErevdiffszrevlog.revdiffcCs |||S)zreturn an uncompressed revision of a given node or revision number. _df - an existing file handle to read from. (internal-only)  _revisiondatar nodeorrev_dfrArArErMs zrevlog.revisioncCs$t|tr|}n||}||S)za map of extra data related to the changeset but not part of the hash This function currently return a dictionary. However, more advanced mapping object will likely be used in the future for a more efficient/lazy code. )rrNr0 _sidedata)rr4r5r0rArArEr:s   zrevlog.sidedatac Cst|tr |}||}n|}d}||jkrdS|j|||d\}}}|r)|r)|S|dur2||}||}|r?|tkr?|S|rKt |||} |} n t |||} | \} } | r`|j | ||d|sh|||f|_ | S)Nr|)r5r) rrNrPr_rawtextr0r^r!r5processflagsrawprocessflagsread checkhashr) rr4r5rawr0rPrawtext validatedr^ validatehashrDrrrArArEr2 s2       zrevlog._revisiondatac Csd}d}|jr|jd|kr||jddfS|jd}|dur$||}|j||d\}}|r4|jd}d|_d}|j|d} d| krHd| }|j|||d} |dur`t| d}| dd} t|| } ~|| d fS) zjreturn the possibly unvalidated rawtext for a revision returns (rev, rawtext, validated) NrrzTr)rwr)rrF)rr0rzrlr'r,r,patches) rrPr0r5 cachedrevbasetextrxryrrZbinsr<rArArEr76s.       zrevlog._rawtextcCs|j|}|d}|d}|jr||jjd|7}|dkr iS|jj||kr@|j}|jj}|}|}t||||f} t| |j ||} |j|d} | t krU| } n| t kr_| | } n| tkri|| } n d} | | ;} t| t| }|S)z0Return the sidedata for a given revision number.rOrPrr r)rlrr r sidedata_endrFILE_TOO_SHORT_MSGr+rrr rrrrr sidedatautildeserialize_sidedata)rr0 index_entrysidedata_offset sidedata_sizefilenamerhr!rVm comp_segmentcompsegmentrr:rArArEr6as:      zrevlog._sidedatacCs|j||ddS)zreturn an uncompressed raw data of a given node or revision number. _df - an existing file handle to read from. (internal-only) T)r;r1r3rArArErXszrevlog.rawdatacCst|||S)zyCompute a node hash. Available as a function so that subclasses can replace the hash as needed. )r;r)rrDrr rArArEhashsz revlog.hashcCszD|dur|dur||\}}|||||krB|jr&|jd|kr&d|_|}|dur3tt|}ttd|j t |fWdStjy]|j r\t |r\t|j ||w)zCheck node hash integrity. Available as a function so that subclasses can extend hash mismatch behaviors as needed. Nrsintegrity check failed on %s:%s)rkrPrr0rrr+rr rr.bytestrrr;iscensoredtextCensoredNodeError)rrDrPrr r0 revornoderArArEr:s(zrevlog.checkhashc Cst|d}||||}|jr|tkrdS||j}|dur-tt d|jd}| |j dd}|j durSd}|j d}| |d|_ d|j_|d}|dz|1} |D]"} ||j| | | dd|dur||| | |jjkr| }qe| Wdn1swY|durd}|Q}|jtM_d|_|D]&} |j| } | dkr|jdur|j|jB} |j| } | | } || q|jdur||j_ |!|j ||Wdn1swY|!|j||jjt"#||t$$|j%|j |j&|_|r-|'}||df|_ ||j_d}W|dur9|dSdS|durE|ww) aCheck if the revlog is too big for inline and convert if so. This should be called after revisions are added to the revlog. If the revlog has grown too large to be an inline revlog, it will convert it to use multiple index and data files. rNs%s not found in the transactionrFTrr)(rr8rVr _maxinline findoffsetrr+rr rLrrflushcloserwriting_handler(truncaterwriterrlr _revlog__index_new_fprr entry_binaryrr pack_headertellrreplacerrAr7rr_revlog__index_write_fp)rtrr, total_sizetroffsettrindexexisting_handlesrnew_dfhread_ifhrrrjrSrifhrArArE_enforceinlinesizes                      zrevlog._enforceinlinesizecCrI)z0called when trying to add a node already stored.NrA)rrCrPrArArE_nodeduplicatecallbackszrevlog._nodeduplicatecallbackc csr|j)|j dVWdn1swYWddSWddS1s2wYdS)zCContext manager that keeps data and sidedata files open for readingN)rreadingrrrArArErls  "zrevlog.readingc cs|jrd}||j;}t||jdurdVdSd}}}z t|}d}|r1||d}d}|jsyz|d}|j durI| dt j n | |j j t jWntyq}z|jtjkrb|d}WYd}~nd}~ww||j||jdur|dusJz|j|jdd}| |j jt jWn!ty}z|jtjkr|j|jdd}WYd}~nd}~ww||j|j j||jj} |}|jr||j|| n||j| |||f|_|jr|n||j_||j_dV|j dur||Wd|_d|j_d|j_|dur||dur||dur*|dSdSd|_d|j_d|j_|dur@||durI||durS|ww)Ns)try to write in a `trypending` revlog: %srrrrr) rrr+r*rrrhrr(rrr r!data_endr"rrrrLrrrrDrlr rarrrYr _write_docketrX) rrCrridfhsdfhrrdsizerisizerArArE_writings                        zrevlog._writingcCs|j|dS)zwrite the current docket on disk Exist as a method to help changelog to implement transaction logic We could also imagine using the same transaction logic for all revlog since docket are cheap.N)rr[rBrArArErncszrevlog._write_docketc  Cs|tkrttd|j| duri} n | r!|js!ttd|r,|p+||||}t |||\} } | |kr;d}t | t krOttd|jt | f|pW|| ||}|j |} | durd| S| ro|j| |||d|j| |||||||| | d S)aadd a revision to the log text - the revision data to add transaction - the transaction object used for rollback link - the linkrev data to add p1, p2 - the parent nodeids of the revision cachedelta - an optional precomputed delta node - nodeid of revision; typically node is not specified, and it is computed by default as hash(text, p1, p2), however subclasses might use different hashing method (and override checkhash() in such case) flags - the known flags to set on the revision deltacomputer - an optional deltacomputer instance shared between multiple calls s!attempted to add linkrev -1 to %sNs9trying to add sidedata to a revlog who don't support thems;%s: size of %d bytes exceeds maximum revlog storage of 2GiB)rr ) cachedelta deltacomputerr:)rr+rr rrr*rPr5processflagswriter _maxentrysizerlget_revr:addrawrevision)rrDrClinkrr rtrPr^rur:r<r>r0rArArE addrevisionlsR     zrevlog.addrevisionc CsL|||j||||||||| | d WdS1swYdS)zadd a raw revision with known flags, node and parents useful when reusing a revision not stored in this revlog (ex: received over wire, or read from an external bundle). rur:N)rs _addrevision) rr<rCrzrr rPr^rtrur:rArArErys $zrevlog.addrawrevisioncCsD|sd|fS|j|}|rd|fS|dddkrd|fSd|fS)z6Generate a possibly-compressed representation of data.r|rru)rcompress)rrj compressedrArArErs zrevlog.compressc Cs|s|S|dd}|dkr-zt|WStjy,}z ttdt|d}~ww|dkr3|S|dkr=t|dS| |}| |S)zDecompress a revlog chunk. The chunk is expected to begin with a header identifying the format type so it can be routed to an appropriate decompressor. rrxsrevlog decompress error: %sNr~r) _zlibdecompresszlibr+rr r< forcebytestrr1rrr)rrjrrSrrArArErs(     zrevlog.decompressc (Cs||jkrttd|j||jjks||jjvr%ttd|j|jdur1d} t | |j r:|jd} n|jd} |g}t |}|d}| |}|j r~|j\}}}|j rj| ||j|||jjn| ||j||jj| ||j|||||}}|durtt||d|d}nt |}| durt|} t|||||||}| || }t}|jdur|jj}t||}|\}}t}| r|j rt!}t"#| }|jj$}|%|\} }!| dkr|!dddkrt |!t |kr| rJ|!dd|jjkrt&}|!}n t}|!}nd }d}t'}"|j(t)krw||ft*t*fkr3d}"nD|t*krE|t*krEd|+|}"n2|t*krW|t*krWd|+|}"n t,||f\}#}$d|+|$}"|"t-d d |.|$g|#gD7}"tj/|||j0|||j1|||||t |||"d }%|j2|%|j3|}&|dkr|jdur|j4|j(B}'|j5|'}'|'|&}&|6||&|j7|||||d}| r|dur| 8|| }t9|t:kr|||f|_;|j<|j=|<|S) ainternal function to add revisions to the log see addrevision for argument descriptions. note: "addrevision" takes non-raw text, "_addrevision" takes raw text. if "deltacomputer" is not provided or None, a defaultdeltacomputer will be used. invariants: - rawtext is optional (can be None); if not set, cachedelta must be set. if both are set, they must correspond to each other. s %s: attempt to add null revisions %s: attempt to add wdir revisionN1adding revision outside `revlog._writing` contextrrrr~r|css|]}dVqdS)rNrA)rr rArArEr sz&revlog._addrevision..)r^ data_offsetdata_compressed_lengthdata_uncompressed_lengthdata_compression_modedata_delta_baselink_rev parent_rev_1 parent_rev_2node_idrIsidedata_compressed_lengthsidedata_compression_moder\)>rr+rr rrrJrKrr*rr_get_data_offsetrrrlr rr0r, patchedsizer>rrrur/ revisioninfo finddeltainforrrdelta_compressionrrrFserialize_sidedatarDrrrrr rr]sortedsumrrfdeltalenr_rur]rr^ _writeentryrj buildtexttyper,rrar)(rrPr<rCrzrr r^rt alwayscacherur:rfhbtextcurrprevr!rirorpp1rp2rtextlenrevinfo deltainfor default_comprrrserialized_sidedatarIh comp_sidedatar\pminpmaxrSrfrrArArEr} s                    "        zrevlog._addrevisioncCs|jdur ||S|jjS)aReturns the current offset in the (in-transaction) data file. Versions < 2 of the revlog can get this 0(1), revlog v2 needs a docket file to store that information: since sidedata can be rewritten to the end of the data file within a transaction, you can have cases where, for example, rev `n` does not have sidedata while rev `n - 1` does, leading to `n - 1`'s sidedata being written after `n`'s data. TODO cache this in a docket file before getting out of experimental.N)rrhrm)rrrArArEr s zrevlog._get_data_offsetcCs|jdur d}t||j\} } } |jdur| dtjn | |jjtj| r@|jdur7| dtjn | |jj tj| rK| |jj tjt |d} |j s| |j||jre| |j|| |j| t ||dr{| |d| |d|r| || |n+|| |jj7}| |j|| || |d| |d|rJ|||jdur|jd} |jd}|jd}| dusJ|dusJ|dusJ| |j_||j_ ||j_ t||dS)Nrrrrz)rr+r*rrr r!rr"rmrDrrrLrrrr[rlr rjr_rrA)rrCrfrjrzr!r:rIrrirorprwh1wh2wh3rArArEr sV                    zrevlog._writeentrycCs|jrtdd|_d}z||t|}|D]} | \} } } } }}}}|| }|p.t}|j| }|durI| |||rF|||d}q| | fD]}|j |s_t ||j t dqM|j |spt ||jt d||}|tkr||rtd}||}t||}|d|t||krt|j|||s|||r|tO}|j| d||| | |||f|||d }|r|||d}qWdn1swYWd|_| SWd|_| Sd|_w) a\ add a delta group given a set of deltas, add them to the revision log. the first delta is against its parent, which should be in our log, the rest are against the previous delta. If ``addrevisioncb`` is defined, it will be called with arguments of this revlog and the node that was added. scannot nest addgroup() callsTNFsunknown parentsunknown delta bases>lll)rrur:)rr+r*rsrrur!rlrxrkhas_noderMrr rr0r iscensoredstructcalcsizerZrr,replacediffheaderCensoredBaseErrorrP_peek_iscensoredr&r})rr3 linkmapperrCr addrevisioncbduplicaterevisioncbemptyrurjrPrr rb deltabaser`r^r:rzr0rr>hlenoldlennewlenrArArEaddgroup& s                   PPzrevlog.addgroupcCs|jsdS||t@S)z%Check if a file revision is censored.F)rr^r&r/rArArEr szrevlog.iscensoredcCs|jsdSt|||jS)z6Quickly check if a delta produces a censored revision.F)rr;deltaiscensoredrZ)rr>r`rArArEr szrevlog._peek_iscensoredcCs"t|t|d||j|jS)zfind the minimum rev that must be stripped to strip the linkrev Returns a tuple containing the minimum rev and a set of all revs that have linkrevs that will be broken by this strip. r)r;resolvestripinforrrbrg)rminlinkrArArE getstrippoint s zrevlog.getstrippointcCst|dkrdS||\}}|t|krdS||}|js-||j|||jj}n|||jj}|jrD| |}||j|||j ||j durd||j _ ||j _ ||j _|j j|ddd|_td|_|j|j|j|d=dS)a7truncate the revlog on the first revision with a linkrev >= minlink This function is called when we're stripping revision minlink and its descendants from the repository. We have to remove all revisions with linkrev >= minlink, because the equivalent changelog revisions will be renumbered after the strip. So we truncate the revlog on the first of these revisions, and trust that the caller has saved the revisions that shouldn't be removed and that it'll re-add them after this truncation. rNT) strippingrr})rrr8rrLrrlr rrTrrrrmrDr[rr1rrrrFr)rrrCr0r rmrhrDrArArEstrip s0        z revlog.stripc Csd}t|rtd|t|d}z%|}|dtj|}Wdn1s-wY||}WntyR}z|j t j krFd}WYd}~nd}~wwzP| |j }|dtj|}| |jj}td||}|||}|jrd} |D] } | td|| 7} qd}|t||| }W||fSW||fSty}z|j t j krd}WYd}~||fSd}~ww)zCheck size of index and data files return a (dd, di) tuple. - dd: extra bytes for the "data" file - di: extra bytes for the "index" file A healthy revlog will return (0, 0). rrN)rrrhr(rior!r_rrrrrrXrlr rrV) rexpectedr#actualddrsrjdi databytesrrrArArE checksize sN         zrevlog.checksizecCs|jg}|jdur|js||j|S||j||jjdd|jjr.||j||jj dd|jj rB||j ||jj dd|S)NF) include_empty) rrrrurextendrold_index_filepathsrmold_data_filepathsrDrold_sidedata_filepaths)rresrArArEfiles s     z revlog.filescCsl|dvr td||dur|jsd}|js|tjkrtj}tj|||t |j |j |j |j |j||||d S)N)snodesstorageslinearNs"unhandled value for nodesorder: %sr) deltaparentfn candeltafn rawsizefn revdifffnflagsfn deltamode revisiondataassumehaveparentrevisionssidedata_helpers)r+r*rrr2CG_DELTAMODE_PREVCG_DELTAMODE_FULLr; emitrevisionsrTr(r?rZr0r^)rnodes nodesorderrrrrrArArEr s2  zrevlog.emitrevisionsalwayssamerevsneverfulladd>rrrrc Cs||jvr ttd|t|rttdt|ddr#ttdt|ddr/ttd|j}|j}|j} z>||jkrEd|_d|_n||j krQd|_d|_n ||j kr\d|_d|_|p_| |_| ||||||W||_||_| |_dS||_||_| |_w) a]Copy this revlog to another, possibly with format changes. The destination revlog will contain the same revisions and nodes. However, it may not be bit-for-bit identical due to e.g. delta encoding differences. The ``deltareuse`` argument control how deltas from the existing revlog are preserved in the destination revlog. The argument can have the following values: DELTAREUSEALWAYS Deltas will always be reused (if possible), even if the destination revlog would not select the same revisions for the delta. This is the fastest mode of operation. DELTAREUSESAMEREVS Deltas will be reused if the destination revlog would pick the same revisions for the delta. This mode strikes a balance between speed and optimization. DELTAREUSENEVER Deltas will never be reused. This is the slowest mode of execution. This mode can be used to recompute deltas (e.g. if the diff/delta algorithm changes). DELTAREUSEFULLADD Revision will be re-added as if their were new content. This is slower than DELTAREUSEALWAYS but allow more mechanism to kicks in. eg: large file detection and handling. Delta computation can be slow, so the choice of delta reuse policy can significantly affect run time. The default policy (``DELTAREUSESAMEREVS``) strikes a balance between two extremes. Deltas will be reused if they are appropriate. But if the delta could choose a better revision, it will do so. This means if you are converting a non-generaldelta revlog to a generaldelta revlog, deltas will be recomputed if the delta's parent isn't a parent of the revision. In addition to the delta policy, the ``forcedeltabothparents`` argument controls whether to force compute deltas against both parents for merges. By default, the current default is used. See `revlogutil.sidedata.get_sidedata_helpers` for the doc on `sidedata_helpers`. s value for deltareuse invalid: %ssdestination revlog is not emptyrNs$source revlog has filtered revisionss)destination revlog has filtered revisionsTF) DELTAREUSEALLrr rr rrrDELTAREUSEALWAYSDELTAREUSESAMEREVSDELTAREUSENEVER_clone) rrb destrevlogr deltareuseforcedeltabothparentsr oldlazydeltaoldlazydeltabaseoldamdrArArEcloneL sL 5            z revlog.clonecCst|}|j}|D]} || } | dd@} | d} || dd} || dd}| d}d}d}||jkrj|| }|| }|durZt|||| \}}| |d|d@B} |j||| | |||| ||d ni|j r| | }|t kr|t | | f}d}|s|| }|| }|dur|| }|durt|||| \}}| |d|d@B} |||j|||| | || |||d Wdn1swY|r||| |q dS) zBperform the core duty of `revlog.clone` after parameter processingrrrrcrrdNr)rtrPr^rur:r|)rrurlDELTAREUSEFULLADDr2r:rFrun_sidedata_helpersr{rr(rr,rrsr})rrbrrrrrrurlr0rfr^rbrr rPrtr<rDr: new_flagsdprArArEr s           z revlog._cloner|cCsP|jtkrttd|j|jtkrt||||dSt||||dS)Ns%cannot censor with version %d revlogs) rrr+rr rr9 v1_censor v2_censor)rrb censornode tombstonerArArEcensorrevision s  zrevlog.censorrevisionc cs|\}}|rttd|dV|rttd|dV|j}||dkr8ttd|j||dfdVt|d<t|d<|D]}||}z5|d d }|r[|||M}t ||||| |}t | |} || krttd | |f|d VWqDt jy|d rttd|d V|d|YqDty} zttdt|t| f|d V|d|WYd} ~ qDd} ~ wwdS)zVerifies the integrity of the revlog. Yields ``revlogproblem`` instances describing problems that are found. sdata length off by %d bytes)r+sindex contains %d extra bytessexpectedversions0warning: '%s' uses revlog format %d; expected %d)rerKs safe_renameds skipflagsrs unpacked size is %d, %d expected)r+rPserroroncensoredscensored file datasunpacking %s: %sN)rrdr rrrrPrr^rQrZrrXr+rSrL Exceptionrr<r) rrOrrversionr0rPrNl1l2rSrArArEverifyintegrity s`     2  zrevlog.verifyintegritycsi}|rjjfg|d<js|djjf|r!g|d<|r)t|d<|r7ttjt |d<|rHtfdd D|d<|S)Nsexclusivefiless sharedfilessrevisionscounts trackedsizec3s|] }j|jVqdSrg)rstatr)rpathrrArEr s z%revlog.storageinfo..s storedsize) rrrrurrrrrZr3r)rexclusivefiles sharedfilesrevisionscount trackedsize storedsizerrArrE storageinfox s    zrevlog.storageinfocCsF|jsdS|jr J|ds|dsdSg}|||j\}}}||jjtj| } t ||dD]} |j | } t j ||i| d\} } t | }t}|r|jrt}||\}}|dkr|ddkrt|t|kr|rsJ|d|jjkrt}|}nt}|}| ddks| ddkrd }t|| d| d| d@B}| t|||f}|| tj||||| t|7} | |j_q6|||j jt|D]8\}}||} |j j| g|R|j | }| dkr |jdur |j|jB}|j |}||}||qWddS1swYdS) Nrrz)storerr:r0rrr~rOrPs0rewriting existing sidedata is not supported yet) rrrsrrrrDr r"r_rrlrFrrrrrrrrr+Abortr[rur rreplace_sidedata_infor]rrr^)rrChelpersrr  new_entriesrirorpcurrent_offsetr0rf new_sidedatar^rrrrrnew_offset_flags entry_updaterjrSpackedrrArArErewrite_sidedata s|               $zrevlog.rewrite_sidedata)NFFFNFNFrg)r)rN)rF)NN)F)rr@)NNN)FNN)r|)FFFFF)~rWrXrY__doc__r+r_flagserrorclassrrrrr1 propertycacherrrrrrrar\r( contextlibcontextmanagerr)r,r.r1r2r5r;r=r?rDrGr0r8rTr^rVrWrZrr]rarbrgrrPrhrkrmrlrzrrrrrrrrrrrrrrrrrr)rrrrr rrr'r(r)r+r0rMr:r2r7r6rXrPr:rjrkrlrsrnr!r{ryrrr}rrrrrrrrrr2CG_DELTAMODE_STDrrrrrrrrrrr rrArArArEr>sB- X R               )  @    !     ": 3  " D    ,+ & ^  E W < >F m2, ' c U k )pr __future__rr rrrrr rrrPrrrrrr i18nr r.r revlogutils.constantsr r rrrrrrrrrrrrrrrrrrr revlogutils.flagutilr!r"r#r$r%r&r' thirdpartyr(r)r*r+r,r-r/r0r1 interfacesr2 interfaceutilr3rr4rr5r6rr7r8r9r:rFutilsr;r< importmodr= importrustr}rrwrrrUrFrHrJrrQrHAS_FAST_PERSISTENT_NODEMAP implementerirevisiondeltarrrTiverifyproblemrdrnrrrtrvryrwrEr>rArArArEs    \$ , (