
    6hC                    <   S SK Jr  S SKrS SKrSSKJr  SSKJrJr  SSK	J
r
JrJrJrJrJr  SSKJr  S rS	 rS
 rSS jrSS jrSS jrSS jrSS jr\\\\\\S.rSS1r\" \5      rS rSS jr S r! " S S5      r" " S S5      r#\RH                  " 5       r%S r&g)    )annotationsN   )_)hexnullrev)errorobsoletephasespycompattagsutil)repoviewutilc                    [         R                  " U S5      nU R                  R                  U [        R
                  5      n[        U5      nX-  $ )aW  Revision 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.s   obsolete)r	   getrevs_phasecache	getrevsetr
   localhiddenphases	frozenset)repo	obsoletes	internalss      4/usr/lib/python3/dist-packages/mercurial/repoview.pyhideablerevsr      sG       {3I  **41I1IJI)$I      c                  ^	 U R                   n[        5       nUR                  U S   R                  5        Vs/ s H  o3R	                  5       PM     sn5        UR                  U R
                  R                  5        Vs/ s H  oAR	                  U5      PM     sn5        0 n[        R                  " U R                  X0 5        U(       aP  UR                  R                  m	UR                  U	4S jUR                  5        5       5        UR                  S5        SSKJn  UR                  R                  U 5      nUR!                  5       (       ae  UR#                  5       (       aP  UR$                  UR&                  4 H4  nUR                  R                  U5      m	T	c  M#  UR)                  T	5        M6     U$ s  snf s  snf )z8revisions blocking hidden changesets from being filteredNc              3  :   >#    U  H  nT" US    5      v   M     g7fr   N ).0trevs     r   	<genexpr>pinnedrevs.<locals>.<genexpr>9   s     7Ac!A$iis   r   )
mergestate)	changelogsetupdateparentsr!   
_bookmarksvaluestagsmodreadlocaltagsuiindexget_revdiscard r$   readactiveunresolvedcountlocalotheradd)
r   clpinnedparbmr   r$   msnoder!   s
            @r   
pinnedrevsr>   -   sB    
BUF
MMT
(:(:(<=(<779(<=>
MM(>(>(@A(@"66":(@ABD$''4r2hh777t
 				#	#D	)B	yy{{r))++XXrxx(D((""4(C

3 )
 M- >As   F8?F=c                    [        U5      nU(       a\  U " UR                  5       5       H8  nU[        :w  d  M  XA;   d  M  UR                  U5        UR	                  U5        M:     U(       a  M[  gg)a5  reveals 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)listpopr   removeappend)pfunchiddenrevsstackps        r   _revealancestorsrI   K   sN     JE
uyy{#AG|a Q $ %r   c                Z   U R                   R                  (       a   e[        U 5      nU(       ar  [        U[	        U 5      -
  5      nU(       a  X!-  nU R                   R
                  nU R                  R                  U [        R                  5      nXB-
  n[        X2U5        [        U5      $ )z^compute the set of hidden revision to filter

During most operation hidden should be filtered.)r%   filteredrevsr   r&   r>   
parentrevsr   r   r
   mutablephasesrI   r   )r   visibilityexceptionsrE   rD   mutablevisibles         r   computehiddenrQ   ^   s     ~~****$FVj../*F))"",,T63G3GH"0Vr   c                    U R                   R                  (       a   eU R                  R                  U [        R
                  5      n[        U5      $ )zcompute the set of revision that can never be exposed through hgweb

Changeset in the secret phase (or above) should stay unaccessible.)r%   rK   r   r   r
   remotehiddenphasesr   )r   rN   secretss      r   computesecretrU   q   s@     ~~****((v/H/HIGWr   c                    U R                   R                  (       a   e[        U S5      n[        U S5      nU(       a  [        X#-  5      $ U$ )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%   rK   
filterrevsr   )r   rN   hiddensrT   s       r   computeunservedr[   z   sF     ~~****z*G/0G*++r   c                    U R                   R                  (       a   eU R                  R                  U 5      (       a3  [	        U R                  R                  U [        R                  5      5      $ [	        5       $ N)r%   rK   r   hasnonpublicphasesr   r   r
   rM   )r   rN   s     r   computemutabler_      sX    ~~******400))33D&:N:NOPP;r   c                ,   U R                   R                  (       a   eU R                   n[        U5      nU R                  R	                  U 5      nU(       a  [        U[        U5      5      n[        SU5      n[        [        U[        U5      5      5      $ )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.r   )	r%   rK   lenr   nonpublicphaserootsminmaxr   range)r   rN   r8   firstmutablerootss        r   computeimpactablerh      st     ~~****	Br7L006E<U4q,'LU<R122r   )rW      visible-hiddenrX   s   serveds	   immutable   baserW   ri   c                |  ^^ U R                  SS5      mTc  g[        R                  " [        R                  S   " T5      R                  5       5      SS mU4S jn[        R                  nU" S5      [        ;  a?  [         H5  nUS.U4S	 jjnU[        U" U5      '   X2;   d  M#  U" X#   5      X!" U5      '   M7     T$ )
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   experimentals   extra-filter-revsNs   sha1   c                   > U S-   T-   $ )N   %r   )fnamefids    r   <lambda>extrafilter.<locals>.<lambda>   s    EDL3.r   rj   )namec               f   > [         U   " U /UQ70 UD6n[        U R                  T5      5      nXE-  $ r]   )filtertabler   rF   )r   rs   argskwargsbaserevs	extrarevsfrevss         r   extrafilteredrevs&extrafilter.<locals>.extrafilteredrevs   s8    &t,TCDCFC%dii&67	++r   )
configr   sysbytesr   DIGESTS	hexdigestr   subsettableru   _basefiltername)r-   combiner   	base_namer{   rp   rz   s        @@r   extrafilterr      s     IIo';<E}


DLL1%8BBD
Ecr
JC.G**Kw{*(I4= , ,
 /@K	*+'29*3GI./ ) Jr   c                B   XR                   ;  Ga  U R                  R                  SS5      (       a  SnX1-  nU R                  R                  (       a[  U R                  R                  (       a@  [
        R                  " UU R                  R                  U R                  R                  SS9  OU R                  R                  SU-  5        [        U   nU(       a  U" U R                  U5      $ U" U R                  5       5      U R                   U'   U R                   U   $ )zreturns set of filtered revision for this filter name

visibilityexceptions is a set of revs which must are exceptions for
hidden-state and must be visible. They are dynamic and hence we should not
cache it's results   devels   debug.repo-filterss"   computing revision filter for "%s"s   debug.filters: )fotherfprefixs   debug.filters: %s
)filteredrevcacher-   
configbooltracebackflag	debugflagr   debugstacktrace_fout_ferrdebugru   
unfiltered)r   
filternamerN   msgfuncs        r   rY   rY      s     ...77h(=>>7CCww$$):):$$ggmm77==-	 4s:;:&)=>>,01B,Cj)  ,,r   c                ~    [         R                   " U 5      nXl         " S S[        UR                  5      nX2l        U$ )Nc                      \ rS rSrSrg)(wrapchangelog.<locals>.filteredchangelog   r   N__name__
__module____qualname____firstlineno____static_attributes__r   r   r   filteredchangelogr          r   r   )copyrK   filteredchangelogmixin	__class__)unfichangelogrK   r8   r   s       r   wrapchangelogr      s4    	=	!B"O2BLL  %LIr   c                     ^  \ rS rSrS rS rS rSU 4S jjrS rS r	SU 4S jjr
U 4S	 jrU 4S
 jrU 4S jrU 4S jrU 4S jrU 4S jrSrU =r$ )r   i  c                j    [        [        U 5      S-
  SS5       H  nXR                  ;  d  M  Us  $    g)z!filtered version of revlog.tiprevr   Nre   ra   rK   )selfis     r   tiprevfilteredchangelogmixin.tiprev  s.    s4y1}b"-A))) .r   c                h    SUs=:*  =(       a    [        U 5      :  Os  =(       a    XR                  ;  $ )z'filtered version of revlog.__contains__r   )ra   rK   )r   r!   s     r   __contains__#filteredchangelogmixin.__contains__  s'    C###d)#D3D3D(DDr   c                   ^  U 4S jnU" 5       $ )z#filtered version of revlog.__iter__c               3  p   >#    [        [        T5      5       H  n U TR                  ;  d  M  U v   M     g 7fr]   r   )r   r   s    r   filterediter5filteredchangelogmixin.__iter__.<locals>.filterediter  s,     3t9%D---G &s   &6	6r   )r   r   s   ` r   __iter__filteredchangelogmixin.__iter__  s    	
 ~r   c              #  d   >#    [         TU ]  X5       H  nX0R                  ;  d  M  Uv   M     g7f)zfiltered version of revlog.revsN)superrF   rK   )r   startstopr   r   s       r   rF   filteredchangelogmixin.revs  s*     e*A))) +s    0	0c                    [        US5      (       a  [        U5      nU R                  n[        US5      (       a  X-  nOUR                  U5      nU H  n[        R
                  " U5      e   U$ )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)hasattrr&   rK   intersectionr   FilteredIndexError)r   rF   rK   	offendersr!   s        r   _checknofilteredinrevs-filteredchangelogmixin._checknofilteredinrevs!  sj     4$$t9D((4!!+I$11$7IC**3// r   c                j    U R                  5        Vs/ s H  oR                  U5      PM     sn$ s  snf r]   )headrevsr=   )r   rs     r   _head_node_ids%filteredchangelogmixin._head_node_ids5  s&    &*mmo6o		!o666s   0c                   > Uc&  U R                   R                  U R                  U5      $ Ub   eU R                  U5      n[        TU ]  U5      $ r]   )r.   r   rK   r   r   )r   rF   stop_revr   s      r   r   filteredchangelogmixin.headrevs9  sQ    <::&&t'8'8(CC**40w%%r   c                L   > U R                   (       a   e[        TU ]  " U0 UD6  g r]   )rK   r   strip)r   rv   rw   r   s      r   r   filteredchangelogmixin.stripB  s%     $$$$t&v&r   c                   > [         TU ]  U5      nX R                  ;   a4  [        R                  " [        U5      U R                  [        S5      5      eU$ )zfiltered version of revlog.revs   filtered node)r   r!   rK   r   FilteredLookupErrorr   
display_idr   )r   r=   r   r   s      r   r!   filteredchangelogmixin.revH  sL    GK!!!++D	4??A.>,?  r   c                l   > XR                   ;   a  [        R                  " U5      e[        TU ]  U5      $ )zfiltered version of revlog.node)rK   r   r   r   r=   r   r!   r   s     r   r=   filteredchangelogmixin.nodeQ  s/    ###**3//w|C  r   c                l   > XR                   ;   a  [        R                  " U5      e[        TU ]  U5      $ )z"filtered version of revlog.linkrev)rK   r   r   r   linkrevr   s     r   r   filteredchangelogmixin.linkrevW  s/    ###**3//ws##r   c                l   > XR                   ;   a  [        R                  " U5      e[        TU ]  U5      $ )z%filtered version of revlog.parentrevs)rK   r   r   r   rL   r   s     r   rL   !filteredchangelogmixin.parentrevs]  s0    ###**3//w!#&&r   c                l   > XR                   ;   a  [        R                  " U5      e[        TU ]  U5      $ )z filtered version of revlog.flags)rK   r   r   r   flagsr   s     r   r   filteredchangelogmixin.flagsc  s/    ###**3//w}S!!r   r   r   )NN)r   r   r   r   r   r   r   rF   r   r   r   r   r!   r=   r   rL   r   r   __classcell__)r   s   @r   r   r     sJ    E(7&'!$'" "r   r   c                  Z    \ rS rSrSrSS jr\S 5       rS rSS jr	S r
S	 rS
 rS rSrg)repoviewij  a~  Provide 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`.
Nc                    Uc  Sn[         R                  " U5      e[        R                  U SU5        [        R                  U SU5        [        R                  U SS 5        [        R                  U SS 5        [        R                  U SU5        g )Nz*repoview should have a non-None filtername_unfilteredrepor   _clcachekey_clcache_visibilityexceptions)r   ProgrammingErrorobject__setattr__)r   r   r   rN   r   s        r   __init__repoview.__init__  s{    >C((--4!2D94z:454T24!8:NOr   c                F   U R                   nUR                  nUR                  n[        U5      nX4S-
     S   n[        R
                  " SU R                  5         [        XR                  U R                  5      nSSS5        U R                  nXE[        W5      UR                  4nUb   UR                  ULd  XR                  :w  a  SnUcB  U(       a  [        X&5      OUn[        R                  U SU5        [        R                  U SU5        U$ ! , (       d  f       N= f)zWreturn a filtered version of the changeset

this changelog must not be used for writingr      zrepo filter for %sNr   r   )r   r%   r.   ra   r   timedcmr   rY   r   r   hashis_delayingr   r   r   r   )	r   unfir   	unfiindexunfilenunfinoderF   r8   newkeys	            r   r%   repoview.changelog  s     ##!''	i.q[)!,\\.@dOOT5O5OPD A]]T$Z1J1JK >HHI%3C3C)CB:7;}3BtZ4t]F;	! A@s   !D
D c                    U R                   $ )z&Return an unfiltered version of a repo)r   r   s    r   r   repoview.unfiltered  s    ###r   c                p    XR                   :X  a	  U(       d  U $ U R                  5       R                  X5      $ )z)Return a filtered version of a repository)r   r   filtered)r   rs   rN   s      r   r   repoview.filtered  s,    ??"+?K ))$EEr   c                    SU R                   R                  < S[        R                  " U R                  5      < SU R                  5       < S3$ )N<: >)r   r   r   sysstrr   r   r   s    r   __repr__repoview.__repr__  s3    NN##OODOO,OO
 	
r   c                .    [        U R                  U5      $ r]   )getattrr   r   attrs     r   __getattr__repoview.__getattr__      t++T22r   c                .    [        U R                  X5      $ r]   )setattrr   )r   r
  values      r   r   repoview.__setattr__  s    t++T99r   c                .    [        U R                  U5      $ r]   )delattrr   r	  s     r   __delattr__repoview.__delattr__  r  r   r   r]   )r   r   r   r   __doc__r   propertyr%   r   r   r  r  r   r  r   r   r   r   r   r   j  sA     D	P  :$F
3:3r   r   c                    [         R                  U 5      nUb  U" 5       nUb  U$  " S S[        U 5      n[        R                  " U5      [         U '   U$ )zBCreate a new type with the repoview mixin and the given base classc                      \ rS rSrSrg)newtype.<locals>.filteredrepoi  r   Nr   r   r   r   filteredrepor    r   r   r  )_filteredrepotypesgetr   weakrefref)baser  clsr  s       r   newtyper"    sR    

 
 
&C
e?Jx   '{{<8tr   r]   )'
__future__r   r   r  i18nr   r=   r   r   r1   r   r	   r
   r   r   r+   r   utilsr   r   r>   rI   rQ   rU   r[   r_   rh   ru   filter_has_wcr@   r   r   rY   r   r   r   WeakKeyDictionaryr  r"  r   r   r   <module>r(     s    #      !< &&3B $#  ./{#@-6	a" a"Hf3 f3Z ..0 r   