o ]Lb&@sdZddlmZddlmZddlmZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZmZddlmZGdd d ejZGd d d eejZGd d d eejZGddde j ZGddde jZGdddeZ dddZ!ddZ"dS)z~Repository class for "in-memory pull" of one local repository to another, allowing operations like diff and log with revsets. )absolute_import)_)getattr) changelogcmdutilencodingerrorfilelog localrepomanifestmdiffpathutilrevlogutilvfs) constantscsfeZdZddZddZfddZdfd d Zdd d Z    dd dZddZ ddZ Z S) unionrevlogcCsVt|}t|dd}|dur|jj}tjj||||d||_t|}|d|_ t |_ |jD]x}|jj |}|\ } } } } } }}}}}}}}| d@}|durX| |ksUJ|}n|| }|durd|| } |j |}|duru|j |q0|j|}|j|}|d| | ||||||ddtjtj|f }|j ||j ||d7}q0dS)Ntarget)rradixrir)vfsmod readonlyvfsr_revlogrr__init__revlog2len repotiprevset bundlerevsindexget_revaddnoderevrevlog_constantsCOMP_MODE_INLINEappend)selfopenerrr linkmapperrnrev2r$_start_csizersizebaselinkrevp1revp2revr#_sdo_sds_dcm_sdcmrankflagslinkthis_revp1nodep2nodeer?5/usr/lib/python3/dist-packages/mercurial/unionrepo.pyr(sr             zunionrevlog.__init__cCs*||jkr tj||S|j||SN)rr_chunkrr#)r(r$r?r?r@rBus zunionrevlog._chunkcs|||jkr||jkr|j|j|||j||S||jkr2||jkr2tt|||St| || |S)z1return or calculate a delta between two revisions) rrrevdiffr$r#superrr textdiffrawdata)r(rev1r, __class__r?r@rCzszunionrevlog.revdiffNFcsdt|tr |}||}n|}||}||jkr%t|jd|j}|j}ntt |j}||||dS)Nr)_dfraw) isinstanceintr#r$rrr _revisiondatarDr)r( nodeorrevrJrKr$r#rfuncrHr?r@rNs     zunionrevlog._revisiondatacCtrANotImplementedError)r(text transactionr:p1p2dr?r?r@ addrevisionzunionrevlog.addrevisioncCrQrArR)r(deltasr*rU alwayscache addrevisioncbduplicaterevisioncbmaybemissingparentsr?r?r@addgroups zunionrevlog.addgroupcCrQrArR)r(minlinkrUr?r?r@striprZzunionrevlog.stripcCrQrArRr(r?r?r@ checksizerZzunionrevlog.checksizeNF)NNN)FNNF) __name__ __module__ __qualname__rrBrCrNrYr`rbrd __classcell__r?r?rHr@r'sM    rc@eZdZddZdS)unionchangelogcCs4tj||d}t|}t|||j||dSrA)rrrr)r(r)opener2r* changelog2r?r?r@rs zunionchangelog.__init__Nrfrgrhrr?r?r?r@rk rkc@rj) unionmanifestcCs6tj|||t||}t|||jj||dSrA)r manifestrevlogrrrr)r( nodeconstantsr)rlr* manifest2r?r?r@rs  zunionmanifest.__init__Nrnr?r?r?r@rprorpc@seZdZddZddZdS) unionfilelogcCsPtj|||t||}t||jj|j||_||_|jj|_|jj|_dSrA)r rrrr_reporr)r(r)pathrlr*repofilelog2r?r?r@rs  zunionfilelog.__init__cCs6||jkr tj||S||}|j|j|S)z Check if a revision is censored.)rr iscensoredr#rr$)r(r$r#r?r?r@rys  zunionfilelog.iscensoredN)rfrgrhrryr?r?r?r@rts rtc@rj) unionpeercCdSrer?rcr?r?r@canpushrZzunionpeer.canpushN)rfrgrhr|r?r?r?r@rzrorzc@sleZdZdZddZejddZejddZdd Z d d Z d d Z ddZ ddZ ddZddZdS)unionrepositoryzRepresents the union of data in 2 repositories. Instances are not usable if constructed directly. Use ``instance()`` or ``makeunionrepository()`` to create a usable instance. cCs"||_||_|jdddddS)NsphasesspublishFs unionrepo)repo2_urlui setconfig)r(r~urlr?r?r@rszunionrepository.__init__cCst|j|jjSrA)rksvfsr~rcr?r?r@rszunionrepository.changelogcCs2t|j|j|jj|j}t|j|||SrA) rprrrr~ unfiltered_clrevr manifestlog narrowmatch)r( rootstorer?r?r@rszunionrepository.manifestlogcCs|jj|}|j|S)z?map from repo2 changelog rev to temporary rev in self.changelog)r~rr#r$)r(r,r#r?r?r@rs zunionrepository._clrevcCs|jSrA)rrcr?r?r@rszunionrepository.urlcCst|j||jj|j|SrA)rtrr~rr)r(fr?r?r@fileszunionrepository.filecCs|jdSrA)r~closercr?r?r@rszunionrepository.closecCr{rer?rcr?r?r@cancopyrZzunionrepository.cancopycCst|SrA)rzrcr?r?r@peerzunionrepository.peercCstSrA)rgetcwdrcr?r?r@rrzunionrepository.getcwdN)rfrgrh__doc__rr unfilteredpropertycacherrrrrrrrrr?r?r?r@r}s    r}Nc Cs|r ttd|dd}|stt}|durd}|r=t}||kr+d}nt |}| |r=|t |d}| dra| ddd dd}t |dkr\||d }} n |\}} n||}} t ||| S) Ns"cannot create new union repositorysbundles mainreporootsunion::r+r)r Abortrconfigrfindreporrr normasprefix startswithrsplitmakeunionrepository) rrvcreateintents createopts parentpathcwdsrepopath repopath2r?r?r@instance s*        rcCshtj||dd}tj||dd}dt|t|f}Gdddt|j}|}||_t||||S)z7Make a union repository object from 2 local repo paths.F)rs union:%s+%sc@s eZdZdS)z3makeunionrepository..derivedunionrepositoryN)rfrgrhr?r?r?r@derivedunionrepository5sr)r rr expandpathr}rIr)r repopath1rrepo1r~rrrwr?r?r@r+sr)NN)#r __future__ri18nrpycompatrrrrr r r r r rrrrr revlogutilsrr%rrkrqrprt localpeerrzobjectr}rrr?r?r?r@s   8   7