o ]Lbk6@sddlmZddlmZddlmZmZmZm Z ddl m Z e j Z dZ ejGdddeZdd d d d Zd dd d d d dd d d d d d ddd idZeded<dd d d d diZhdZd#ddZddZddZd$ddZGdddeZd d!Zd"S)%)_)attr)error requirementssslutilutil) stringutilsclonebundles.manifestc@s<eZdZeZeZeZeZeZ eZ dS) bundlespecN) __name__ __module__ __qualname__rib compressionwirecompressionversion wireversionparams contentoptsrr8/usr/lib/python3/dist-packages/mercurial/bundlecaches.pyr s r s0102s1)v1v2packed1bundle2TF) changegroup cg.versions obsolescencesphasestagsfnodescacherevbranchcacher)rrrrrstreamv2)rr rr>gzipnonebzip2cCsdd}|rd|vrttd|d|vrB|dd\}}|tjjvr.ttd|||\}}|tvrAttd|nE|rFJ||\}}|tjjvrn|}d}t j |j vr_d }nt j |j vrgd }|t vrmd }n|tvr~|d kryd }nd }|}n ttd ||dkr|t vrttd||d krd|vrt|dd}|t j}|rttddt|t|i} d|vr|dd krtd} | | tj|} | \}} t|} t|| || || S)aParse a bundle string specification into parts. Bundle specifications denote a well-defined bundle/exchange format. The content of a given specification should not change over time in order to ensure that bundles produced by a newer version of Mercurial are readable from an older version. The string currently has the form: -[;[;]] Where is one of the supported compression formats and is (currently) a version string. A ";" can follow the type and all text afterwards is interpreted as URI encoded, ";" delimited key=value pairs. If ``strict`` is True (the default) is required. Otherwise, it is optional. Returns a bundlespec object of (compression, version, parameters). Compression will be ``None`` if not in strict mode and a compression isn't defined. An ``InvalidBundleSpecification`` is raised when the specification is not syntactically well formed. An ``UnsupportedBundleSpecification`` is raised when the compression or bundle type/version is not recognized. Note: this function will likely eventually return a more complex data structure, including bundle2 part information. cSsd|vr|ifSi}|dd\}}|dD]%}d|vr&ttd||dd\}}t|}t|}|||<q||fS)N;r=s:invalid bundle specification: missing "=" in parameter: %s)splitrInvalidBundleSpecificationrurlrequnquote)srrparamstrpkeyvaluerrr parseparamsns$   z$parsebundlespec..parseparams-sCinvalid bundle specification; must be prefixed with compression: %srs%s compression is not supporteds%%s is not a recognized bundle versionrrrr"r#s+%s is not a recognized bundle specifications4compression engine %s is not supported on v1 bundless requirements,s+missing support for repository features: %ss, sstreamr )rr'rr&r compenginessupportedbundlenamesUnsupportedBundleSpecification_bundlespeccgversionsrequirementsmodGENERALDELTA_REQUIREMENTrREVLOGV2_REQUIREMENT_bundlespecv1compenginessetSTREAM_FIXED_REQUIREMENTSjoinsorted_bundlespeccontentoptsgetcopy_bundlespecvariantsupdate forbundlename bundletyper )repospecstrictr/rrrr missingreqsrvariantenginerrrrrparsebundlespecLs"                rKc Csg}|D]^}|}|sqd|di}|ddD]C}|dd\}}tj|}tj|}|||<|dkr^zt||} | j|d<| j|d<Wqtj yTYqtj y]Yqwq| |q|S) zParses the raw text of a clone bundles manifest. Returns a list of dicts. The dicts have a ``URL`` key corresponding to the URL and other keys are the attributes for the entry. URLrNr% BUNDLESPECs COMPRESSIONsVERSION) splitlinesr&rr(r)rKrrrr'r4append) rEr*mlinefieldsattrsrawattrr-r.r rrrparseclonebundlesmanifests0       rVcCs@|jdkr |jdkr dS|jdkr|jdkr|jdrdSdS)NsUNrTrr F)rrrr?)r rrrisstreamclonespecs   rWc Csg}|D]}|d}|rhzt||dd}|r't|s'|jd|dWqWnLtjyF}z|jt|dWYd}~qd}~wtj yg}z|jd|dt|fWYd}~qd}~ww|ru|jd |dqd |vrt j s|jd |dqd |vrz t |d }Wntjy|jd |dYqw|j} | dur| d|kr|jd|dq||q|S)auRemove incompatible clone bundle manifest entries. Accepts a list of entries parsed with ``parseclonebundlesmanifest`` and returns a new list consisting of only the entries that this client should be able to apply. There is no guarantee we'll be able to apply all returned entries because the metadata we use to filter on may be missing or wrong. rNT)rGs(filtering %s because not a stream clone rL Ns1filtering %s because unsupported bundle spec: %s s?filtering %s because cannot determine if a stream clone bundle s REQUIRESNIs'filtering %s because SNI not supported s REQUIREDRAMs0filtering %s due to a bad REQUIREDRAM attribute gQ?s8filtering %s as it needs more than 2/3 of system memory )r?rKrWuidebugrr'r forcebytestrr4rhassnir sizetoint ParseErrorestimatememoryrP) rEentriesstreamclonerequested newentriesentryrFr e requiredram actualramrrrfilterclonebundleentriessx        rgc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)clonebundleentryzRepresents an item in a clone bundles manifest. This rich class is needed to support sorting since sorted() in Python 3 doesn't support ``cmp`` and our comparison is complex enough that ``key=`` won't work. cCs||_||_dSN)r.prefers)selfr.rjrrr__init__bs zclonebundleentry.__init__cCs|jD]J\}}|j|}|j|}|dur"|dur"||kr"dS|dur1|dur1||kr1dS|dus9|dur:q||kr?q||krFdS||krMdSqdS)NrrM)rjr.r?)rkotherprefkey prefvalueavaluebvaluerrr_cmpfs"  zclonebundleentry._cmpcCs||dkSNrMrsrkrnrrr__lt__zclonebundleentry.__lt__cCs||dkSrtrurvrrr__gt__rxzclonebundleentry.__gt__cCs||dkSrtrurvrrr__eq__rxzclonebundleentry.__eq__cCs||dkSrtrurvrrr__le__rxzclonebundleentry.__le__cCs||dkSrtrurvrrr__ge__rxzclonebundleentry.__ge__cCs||dkSrtrurvrrr__ne__rxzclonebundleentry.__ne__N) r r r __doc__rlrsrwryrzr{r|r}rrrrrhZs" rhcsV|dds t|SddfddDtfdd|D}d d|DS) NsuisclonebundlepreferscSs2d|vrtd}tjtd||d|ddS)Nr%s3each comma separated item should be key=value pairss&invalid ui.clonebundleprefers item: %s)hintr)rrAbortr&)r,rrrr_splits   z&sortclonebundleentries.._splitcsg|]}|qSrr).0r,)rrr sz*sortclonebundleentries..c3s|]}t|VqdSri)rh)rv)rjrr sz)sortclonebundleentries..cSsg|]}|jqSr)r.)rirrrrs) configlistlistr=)rYr`itemsr)rrjrsortclonebundleentriess rN)T)F)i18nr thirdpartyrrrr6rrutilsrr(CB_MANIFEST_FILEr*objectr r5r>rAr9rKrVrWrgrhrrrrrsZ        $ H A