^c;CHddlZddlZddlmZddlmZmZddlmZm Z m Z ddl m Z m Z mZmZmZmZddlmZdZd Zd Zdd Zdd Zdd ZddZddZeeeeeedZddhZeeZdZ ddZ!dZ"GddZ#GddZ$ej%Z&dZ'dS)N)_)hexnullrev)delattrgetattrsetattr)errorobsoletephasespycompattagsutil) repoviewutilctj|d}|j|tj}t |}||zS)akRevision candidates to be hidden This is a standalone function to allow extensions to wrap it. Because we use the set of immutable changesets as a fallback subset in branchmap (see mercurial.utils.repoviewutils.subsettable), you cannot set "public" changesets as "hideable". Doing so would break multiple code assertions and lead to crashes.sobsolete)r getrevs _phasecache getrevsetr localhiddenphases frozenset)repo obsoletes internalss 4/usr/lib/python3/dist-packages/mercurial/repoview.py hideablerevsr"sI {33I **41IJJI)$$I y  c|jt}|d|dD|fd|jDi}t j|j||i|rTj j |fd|D| dddl m }|j |}|rV|rB|j|jfD]3}j ||4|S)z8revisions blocking hidden changesets from being filteredc6g|]}|Srev).0pars r zpinnedrevs..6s ===37799===rNc:g|]}|Srr )r"bmcls rr$zpinnedrevs..7s#AAA"266"::AAArc3:K|]}|dVdSrNr)r"tr!s r zpinnedrevs..=s/77Acc!A$ii777777rr) mergestate) changelogsetupdateparents _bookmarksvaluestagsmod readlocaltagsuiindexget_revdiscardr,readactiveunresolvedcountlocalotheradd)rpinnedrr,msnoder'r!s @@r pinnedrevsrC1s B UUF MM==T (:(:(<(<===>>> MMAAAA(>(>(@(@AAABBB D $'4r222 h 7777777777t    # #D ) )B yy{{ r))++ Xrx(  D(""4((C 3 Mrct|}|r]||D];}|tkr.||vr*||||<|[dSdS)aQreveals contiguous chains of hidden ancestors of 'revs' by removing them from 'hidden' - pfunc(r): a funtion returning parent of 'r', - hidden: the (preliminary) hidden revisions, to be updated - revs: iterable of revnum, (Ancestors are revealed exclusively, i.e. the elements in 'revs' are *not* revealed) N)listpoprremoveappend)pfunchiddenrevsstackps r_revealancestorsrNOs JJE  uyy{{##  AG||V  a    Q      rc8|jjrJt|}|rmt|t |z }|r||z}|jj}|j|tj }||z }t|||t|S)zbcompute the set of hidden revision to filter During most operation hidden should be filtered.) r- filteredrevsrr.rC parentrevsrrr mutablephasesrNr)rvisibilityexceptionsrJrImutablevisibles r computehiddenrVbs~**** $  F 1Vj...//  + * *F)",,T63GHHF"000 V  rc|jjrJ|j|tj}t |S)zcompute the set of revision that can never be exposed through hgweb Changeset in the secret phase (or above) should stay unaccessible.)r-rPrrr remotehiddenphasesr)rrSsecretss r computesecretrZus>~****((v/HIIG W  rc|jjrJt|d}t|d}|rt||zS|S)zcompute the set of revision that should be filtered when used a server Secret and hidden changeset should not pretend to be here.visible served.hidden)r-rP filterrevsr)rrShiddensrYs rcomputeunservedr`~sT~****z**G/00G7*+++rc|jjrJ|j|r2t |j|t jSt SN)r-rPrhasnonpublicphasesrrr rR)rrSs rcomputemutablerds[~**** **400Q)33D&:NOOPPP ;;rcJ|jjrJ|jt}|j|}|r)t |t fd|D}t d|}tt|tS)a/Everything impactable by mutable revision The immutable filter still have some chance to get invalidated. This will happen when: - you garbage collect hidden changeset, - public phase is moved backward, - something is changed in the filtering (this could be fixed) This filter out any mutable changeset and any public changeset that may be impacted by something happening to a mutable revision. This is achieved by filtered everything with a revision number equal or higher than the first mutable changeset is filtered.c3BK|]}|VdSrbr )r"rr's rr+z$computeimpactable..s-,F,F1RVVAYY,F,F,F,F,F,Frr) r-rPlenrnonpublicphaserootsminmaxrrange)rrS firstmutablerootsr's @rcomputeimpactableros~**** Br77L   0 0 6 6E H<,F,F,F,F,F,F,F)F)FGG q,''L U<R11 2 22r)r\visible-hiddenr]sserveds immutablebaser\rpc|dddStjtjdddfd}t j}|dtvrDtD]<fd}|t|<|vr||||<=S) zinitialize extra filter and return its id If extra filtering is configured, we make sure the associated filtered view are declared and return the associated id. s experimentalsextra-filter-revsNssha1 c|dzzS)N%r)fnamefids rzextrafilter..sEDL3.rrqc~t|g|Ri|}t|}||zSrb) filtertablerrK)rargskwargsbaserevs extrarevsfrevsnames rextrafilteredrevsz&extrafilter..extrafilteredrevssI&t,TCDCCCFCC%dii&6&677 )++r) configr sysbytesrDIGESTS hexdigestr subsettablerz_basefiltername)r5combinerrrwrrs @@@r extrafilterrs IIo'; < > <7C : Cw$ <): <$gm7=-  4s:;;;:&  ?4)=>> >,0D1B1B,C,Cj)   ,,rc|tj|}||_Gddt|j}||_|S)NceZdZdS)(wrapchangelog..filteredchangelogN__name__ __module__ __qualname__rrrfilteredchangelogr rr)copyrPfilteredchangelogmixin __class__) unfichangelogrPr'rs r wrapchangelogrsU = ! !B"BO     2BL   %BL IrceZdZdZdZdZdfd ZdZdfd Zfd Z fd Z fd Z fd Z fd Z fdZxZS)rchtt|dz ddD]}||jvr|cSdS)z!filtered version of revlog.tiprevrNrlrhrP)selfis rtiprevzfilteredchangelogmixin.tiprev sMs4yy1}b"--  A)))*  rcNd|cxkot|knco||jvS)z'filtered version of revlog.__contains__r)rhrP)rr!s r __contains__z#filteredchangelogmixin.__contains__s7C#####d))####D43D(DDrc"fd}|S)z#filtered version of revlog.__iter__c3dKttD]}|jvr|VdSrbr)rrs r filterediterz5filteredchangelogmixin.__iter__..filtereditersF3t99%%  D---GGG  rr)rrs` r__iter__zfilteredchangelogmixin.__iter__s*      |~~rrNc#~Ktt|||D]}||jvr|VdS)zfiltered version of revlog.revsN)superrrKrP)rstartstoprrs rrKzfilteredchangelogmixin.revssS-t4499%FF  A)))  rctj}||drt|}|j}||dr||z}n||}|D]}t j||S)zraise the appropriate error if 'revs' contains a filtered revision This returns a version of 'revs' to be used thereafter by the caller. In particular, if revs is an iterator, it is converted into a set. __next__first)r safehasattrr.rP intersectionr FilteredIndexError)rrKrrP offendersr!s r_checknofilteredinrevsz-filteredchangelogmixin._checknofilteredinrevs#s & ;tZ ( ( t99D( ;tW % % 8|+II$11$77I 0 0C*3// / rc |D |j|jS#t$r|cYSwxYw||}t t||Srb) r6headrevsfilteredrPAttributeError _headrevsrrrheadrevs)rrKrs rrzfilteredchangelogmixin.headrevs8s < (z2243DEEE" ( ( (~~''''' (**400+T22;;DAAAs$AAcZ|jrJtt|j|i|dSrb)rPrrstrip)rr{r|rs rrzfilteredchangelogmixin.stripDs=$$$$1$d++14B6BBBBBrctt||}||jvr5t jt ||jtd|S)zfiltered version of revlog.revs filtered node) rrr!rPr FilteredLookupErrorr display_idr)rrBrgrs rr!zfilteredchangelogmixin.revJsc ($ / / 3 3D 9 9 ! ! !+D 4?A.>,?,? rc||jvrtj|tt||S)zfiltered version of revlog.node)rPr rrrrBrr!rs rrBzfilteredchangelogmixin.nodeSsA $# # #*3// /+T2277<<>>>>>>>>rrcVeZdZdZd dZedZdZd dZdZ dZ d Z d Z dS) repoviewaProvide a read/write view of a repo through a filtered changelog This object is used to access a filtered version of a repository without altering the original repository object itself. We can not alter the original object for two main reasons: - It prevents the use of a repo with multiple filters at the same time. In particular when multiple threads are involved. - It makes scope of the filtering harder to control. This object behaves very closely to the original repository. All attribute operations are done on the original repository: - An access to `repoview.someattr` actually returns `repo.someattr`, - A write to `repoview.someattr` actually sets value of `repo.someattr`, - A deletion of `repoview.someattr` actually drops `someattr` from `repo.__dict__`. The only exception is the `changelog` property. It is overridden to return a (surface) copy of `repo.changelog` with some revisions filtered. The `filtername` attribute of the view control the revisions that need to be filtered. (the fact the changelog is copied is an implementation detail). Unlike attributes, this object intercepts all method calls. This means that all methods are run on the `repoview` object with the filtered `changelog` property. For this purpose the simple `repoview` class must be mixed with the actual class of the repository. This ensures that the resulting `repoview` object have the very same methods than the repo object. This leads to the property below. repoview.method() --> repo.__class__.method(repoview) The inheritance has to be done dynamically because `repo` can be of any subclasses of `localrepo`. Eg: `bundlerepo` or `statichttprepo`. Nct|d|t|d|t|ddt|ddt|d|dS)N_unfilteredrepor _clcachekey_clcache_visibilityexceptions)object __setattr__)rrrrSs r__init__zrepoview.__init__s4!2D9994z:::45554T2224!8:NOOOOOrc|j}|j}|j}t|}||dz d}t jd|j5t||j|j}dddn #1swxYwY|j }||t||j f}||j|us ||j krd}|L|rt||n|}t|d|t|d||S)z_return a filtered version of the changeset this changelog must not be used for writingrzrepo filter for %sNrr)rr-r6rhrtimedcmrr^rrhash_delayedrrrr) runfir unfiindexunfilenunfinoderKr'newkeys rr-zrepoview.changelogsa # !' i..Wq[)!, \. @ @ Q QdDOT5OPPD Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q ]8T$ZZ1GH > HI % %43C)C)CB :7;N}d333B   tZ 4 4 4   t]F ; ; ; sA88A<?A<c|jS)z&Return an unfiltered version of a repo)rrs rrzrepoview.unfiltereds ##rcp||jkr|s|S|||S)z)Return a filtered version of a repository)rrfiltered)rrrSs rrzrepoview.filtereds; 4? " "+? "K  ))$0DEEErcd|jjdtj|jd|dS)N<: >)rrr sysstrrrrs r__repr__zrepoview.__repr__sD N # # # ODO , , , , OO      rc,t|j|Srb)rrrattrs r __getattr__zrepoview.__getattr__t+T222rc.t|j||Srb)r r)rrvalues rrzrepoview.__setattr__st+T5999rc,t|j|Srb)rrrs r __delattr__zrepoview.__delattr__rrrb) rrr__doc__rpropertyr-rrrrrrrrrrrls  DPPPPX:$$$FFFF    333:::33333rrct|}||}||SGddt|}tj|t|<|S)zBCreate a new type with the repoview mixin and the given base classNceZdZdS)newtype..filteredrepoNrrrr filteredreporrrr)_filteredrepotypesgetrweakrefref)baserclsrs rnewtypersx   & &C cee ?J     x    '{<88t rrb)(rri18nrrBrrr rrr r9r r r rr3rutilsrrrCrNrVrZr`rdrorz filter_has_wcrErrr^rrrWeakKeyDictionaryrrrrrr sw    ! ! !<   &&    3333B$#   ./ ${##<----6   a>a>a>a>a>a>a>a>Hc3c3c3c3c3c3c3c3T/W.00     r