
    6hƬ                       % S r SSKJr  SSKrSSKrSSKrSSKrSSKJrJrJ	r	J
r
JrJrJrJrJrJr  SSKJr  SSKJrJrJrJrJr  SSKJrJrJrJrJr  \
\\\   4   r \
\\\   4   r!\RD                  (       a.  SS	K#J$r$  SS
KJ%r%J&r'  \'/(       d   e\\\%RP                  \ /\ 4      r)\RT                  " S5      r+Sr,S\-S'   Sr.S\-S'   Sr/S\-S'   Sr0Sr1\,\.\/\0\14r2\.\/\0\14r3\3r4/ SQr5\6" \7" \55      5      r8S\8\0'   S\8\1'   \8Rs                  5        V Vs0 s H  u  pX_M	     snn r:S\-S'   \:Rw                  5       r<S\-S'   \<R{                  \8 V s0 s H  o U _M     sn 5        \<R{                  \8 V s0 s H	  n SU -  U _M     sn 5        \.\/\0\14r>\.\/4r?\/\0\14r@\1\04rA\B" S \2 5       5      rC\CrDS5S jrES5S jrF S6     S7S jjrGS8S jrHS9S  jrIS! rJS" rKS# rLS$rM " S% S&5      rNS:S' jrOS( rPS) rQS;S* jrR          S<S+ jrSS, rTS- rU      S=S. jrV " S/ S05      rW      S>S1 jrXS?S2 jrYS5S3 jrZ        S@S4 jr[gs  snn f s  sn f s  sn f )Aa  Mercurial phases support code

    ---

    Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
                   Logilab SA        <contact@logilab.fr>
                   Augie Fackler     <durin42@gmail.com>

    This software may be used and distributed according to the terms
    of the GNU General Public License version 2 or any later version.

    ---

This module implements most phase logic in mercurial.


Basic Concept
=============

A 'changeset phase' is an indicator that tells us how a changeset is
manipulated and communicated. The details of each phase is described
below, here we describe the properties they have in common.

Like bookmarks, phases are not stored in history and thus are not
permanent and leave no audit trail.

First, no changeset can be in two phases at once. Phases are ordered,
so they can be considered from lowest to highest. The default, lowest
phase is 'public' - this is the normal phase of existing changesets. A
child changeset can not be in a lower phase than its parents.

These phases share a hierarchy of traits:

            immutable shared
    public:     X        X
    draft:               X
    secret:

Local commits are draft by default.

Phase Movement and Exchange
===========================

Phase data is exchanged by pushkey on pull and push. Some servers have
a publish option set, we call such a server a "publishing server".
Pushing a draft changeset to a publishing server changes the phase to
public.

A small list of fact/rules define the exchange of phase:

* old client never changes server states
* pull never changes server states
* publish and old server changesets are seen as public by client
* any secret changeset seen in another repository is lowered to at
  least draft

Here is the final table summing up the 49 possible use cases of phase
exchange:

                           server
                  old     publish      non-publish
                 N   X    N   D   P    N   D   P
    old client
    pull
     N           -   X/X  -   X/D X/P  -   X/D X/P
     X           -   X/X  -   X/D X/P  -   X/D X/P
    push
     X           X/X X/X  X/P X/P X/P  X/D X/D X/P
    new client
    pull
     N           -   P/X  -   P/D P/P  -   D/D P/P
     D           -   P/X  -   P/D P/P  -   D/D P/P
     P           -   P/X  -   P/D P/P  -   P/D P/P
    push
     D           P/X P/X  P/P P/P P/P  D/D D/D P/P
     P           P/X P/X  P/P P/P P/P  P/P P/P P/P

Legend:

    A/B = final state on client / state on server

    * N = new/not present,
    * P = public,
    * D = draft,
    * X = not tracked (i.e., the old client or server has no internal
          way of recording the phase.)

    passive = only pushes


    A cell here can be read like this:

    "When a new client pushes a draft changeset (D) to a publishing
    server where it's not present (N), it's marked public on both
    sides (P/P)."

Note: old client behave as a publishing server with draft only content
- other people see it as public
- content is pushed as draft

    )annotationsN)
AnyCallable
CollectionDictIterableListOptionalSetTupleoverload   )_)binhexnullrevshortwdirrev)errorrequirementssmartsettxnutilutil)Literal)	localrepouis   >i20sintpublicdraft   secret    `   )s   publics   drafts   secrets   archiveds   internalzdict[bytes, int]phasenumberzdict[bytes | int, int]phasenumber2   %ic              #  D   #    U  H  o[         -  (       d  M  Uv   M     g 7fN)internal).0ps     2/usr/lib/python3/dist-packages/mercurial/phases.py	<genexpr>r-      s     Ay!LAAys    	 c                <    [         R                  U R                   ;   $ )z6True if the internal phase can be used on a repository)r   INTERNAL_PHASE_REQUIREMENTrepos    r,   supportinternalr2          22d6G6GGG    c                <    [         R                  U R                   ;   $ )z6True if the archived phase can be used on a repository)r   ARCHIVED_PHASE_REQUIREMENTr0   s    r,   supportarchivedr7      r3   r4   c                   U R                  5       n Sn[         Vs0 s H  o3[        5       _M     nnU R                  R                  R
                  nSn [        R                  " U R                  U R                  S5      u  px U Hv  n	U	R                  5       u  p[        U
5      n[        U5      nU" U5      nUc-  U R                  R                  U[        U5      U4-  5        SnMc  XL   R!                  U5        Mx     UR#                  5         XB4$ s  snf ! UR#                  5         f = f! [$         a    U(       a  U H  nU" X5      nM     Sn XB4$ f = f)ar  Read phase roots from disk

phasedefaults is a list of fn(repo, roots) callable, which are
executed if the phase roots file does not exist. When phases are
being initialized on an existing repository, this could be used to
set selected changesets phase to something else than public.

Return (roots, dirty) where dirty is true if roots differ from
what is being stored.
Fs0   removing unknown node %s from %i-phase boundary

   phaserootsT)
unfiltered	allphasesset	changelogindexget_revr   
trypendingrootsvfssplitr   r   r   debugr   addcloseFileNotFoundError)r1   phasedefaultsdirtyirootsto_revunknown_msgfpendingline	str_phasehex_nodephasenoderevs                  r,   
_readrootsrV      s2    ??DE+459aCE9E5^^!!))FFK''		499mL
	&*jjl#	I8}Tl;GGMM+x%0H"HI EL$$S)  GGI </ 6" GGI "$ #<s0   D.D, A<D ?D, D))D, ,$EEc                    / nU R                  5        H2  u  p#U H'  nUR                  [        R                  X$5      5        M)     M4     SR	                  U5      $ )zoencode a 'phase -> nodes' mapping into a binary stream

The revision lists are encoded as (phase, root) pairs.
r4   )itemsappend_fphasesentrypackjoin)phasemapping
binarydatarS   nodesheads        r,   binaryencodera      sR    
 J$**,Dm00=>  - 88Jr4   c                D   [          Vs0 s H  o/ _M     nn[        R                  n U R                  U5      n[	        U5      U:  a)  U(       a  [
        R                  " [        S5      5      e U$ [        R                  U5      u  pVX%   R                  U5        Mu  s  snf )zdecode a binary stream into a 'phase -> nodes' mapping

The (phase, root) pairs are turned back into a dictionary with
the phase as index and the aggregated roots of that phase as value.s   bad phase-heads stream)
r;   rZ   sizereadlenr   Abortr   unpackrY   )streamrJ   headsbyphase	entrysizeentryrS   rT   s          r,   binarydecoderl     s    
 $--9arE9L-""I
I&u:	!kk!$=">??  $**51""4(  .s   Bc                   SnU(       a  XS-
     u  pVUS   S-   U:H  =(       a    Xc:H  nSnU[        U 5      :  a  X   u  pUS   US-   :H  =(       a    X:H  nU(       a5  U(       a.  [        WS   WS   S-   5      U4XS-
  '   U R                  U5        g U(       a  [        WS   US-   5      U4XS-
  '   g U(       a  [        UWS   S-   5      U4X'   g U R                  U[        X"S-   5      U45        g )NFr   r   )re   rangepopinsert)
dataidxrU   tmerge_beforer1t1merge_afterr2t2s
             r,   _sortedrange_insertr{     s    L
Ag"vzS(4RWK
SYesQw&227r!ubfqj1151W	r!ucAg.21W	32
+Q/	C%1W-q12r4   c                   X   u  pEX5:X  a  g US   US   4n[        U5      S:X  a  U R                  U5        [        XX#5        g US   U:X  a&  [        US-   US   S-   5      U4X'   [        XX#5        g US   U:X  a#  [        US   U5      U4X'   [        XS-   X#5        g [        US   U5      U4[        X"S-   5      U4[        US-   US   S-   5      U4/XUS-   & g )Nr   r   rn   )re   rp   r{   ro   )rr   rs   rU   rt   rv   rw   s         r,   _sortedrange_splitr}   *  s    YFBw	A!A
2w!|Ds.	A#37BrFQJ/4	Ds.	B32a5#&+	D'32 2a5##3a !$37BrFQJ',
37r4   c                "   U c  gU (       d"  U R                  S[        XS-   5      X#445        gSn[        U 5      nX#4nXE:  a  XE-   S-  nX   S   nUS   n	US   n
X:  a  X::  a  [        XX5        gXS-   :X  a5  U(       a!  XS-
     S   S   U:X  a  [        XS-
  X5        g[	        XX5        gXS-
  :X  aC  US-   [        U 5      :  a!  XS-      S   S   U:X  a  [        XS-   X5        g[	        XS-   X5        gX:  a  UnOUS-   nXE:  a  M  U[        U 5      :X  a   U R                  [        XS-   5      U45        gX   u  pUS   U:  a!  U R                  U[        XS-   5      U45        gU R                  US-   [        XS-   5      U45        g)zQadd a phase move to the <data> list of ranges

If data is None, nothing happens.
Nr   r   r    rn   )rq   ro   re   r}   r{   rY   )rr   rU   oldnewlowhighrt   midrevsrevs_low	revs_highrv   rw   s                r,   _trackphasechanger   @  s   
 | Ac7+cZ89
Ct9D	
A
*zay|7H	?s/t#1Qwt!G}Q'+s2"4q#9  $Ds6aQwT"t!G}Q'7':c'A"4q#9  $D'3:>D'C7 *: c$iU3a(!,-YFB	!us{C%1W-q12C!GeCq1156r4   d   c                  N   \ rS rSr\R
                  (       a&  \        SS j5       r\ S       SS jj5       r SS jrSS jrSS jr	      SS jr
 S        S!S	 jjrS
 rS rS rS rS"S jrS rS#S jrS rS rSS jrS r S$S jrS rS%S jr  S&S jrSrg)'
phasecachei  c                    g r(    selfr1   rH   _loads       r,   __init__phasecache.__init__       r4   c                    g r(   r   r   s       r,   r   r     r   r4   c                n    U(       a.  [        X5      nUS   U l        US   U l        SU l        S U l        g g )Nr   r   )rV   _phaserootsrI   _loadedrevslen
_phasesets)r   r1   rH   r   loadeds        r,   r   r     s<     4F+1!9D%ayDJ"#D37DO r4   c                V    [        S U R                  R                  5        5       5      $ )z3detect if there are revisions with non-public phasec              3  B   #    U  H  u  pU[         :w  d  M  Uv   M     g 7fr(   )r   )r*   rS   r   s      r,   r-   0phasecache.hasnonpublicphases.<locals>.<genexpr>  s      
$<[UDD$<s   	)anyr   rX   r   r1   s     r,   hasnonpublicphasesphasecache.hasnonpublicphases  s-      
$($4$4$:$:$<
 
 	
r4   c                    UR                  5       nU R                  U5        [        5       R                  " U R                  R                  5        VVs/ s H  u  p#U[        :w  d  M  UPM     snn6 $ s  snnf )zreturns the roots of all non-public phases

The roots are not minimized, so if the secret revisions are
descendants of draft revisions, their roots will still be present.
)r:   _ensure_phase_setsr<   unionr   rX   r   r   r1   rS   r   s       r,   nonpublicphaserootsphasecache.nonpublicphaseroots  sk      %u{{ $(#3#3#9#9#;#;KEF? #;
 	
s   A2
'A2
c                    U[         :X  a  [        R                  " S5      eU R                  UR	                  5       5        U R
                  R                  U5      nUc
  [        5       $ U$ )zreturn the set of revision in that phase

The returned set is not filtered and might contains revision filtered
for the passed repoview.

The returned set might be the internal one and MUST NOT be mutated to
avoid side effect.
zcannot get_set for public phase)r   r   ProgrammingErrorr   r:   r   getr<   r   s       r,   get_raw_setphasecache.get_raw_set  sW     F?(()JKK 12""5)<5Lr4   Nc                (  ^^^^ U R                  TR                  5       5        [        T5      m[        T;   nU(       a;  [        [        5      R                  T5      mT(       d  [        R                  " T5      $ Sm[        T5      S:X  a  Tu  nU R                  U   mSmO0[        R                  " T Vs/ s H  oPR                  U   PM     sn6 mUUU4S jnU(       do  TR                  R                  (       a  TTR                  R                  -
  mUc  [        R                  " T5      $ U" UT5      mU[        R                  " T5      -  $ Uc  [        R                  " T5      nU" UT5      mT(       d  U$ UR                  U4S j5      $ s  snf )z&return a smartset for the given phasesFr   Tc                   > [         U ;   aC  TS    R                  5       T;   a,  T(       a  UR                  5       nUR                  [         5        U$ r(   )r   rS   copyrE   )
wdirsubsetwdirrevsphasesr1   revsneedscopys     r,   _addwdir&phasecache.getrevset.<locals>._addwdir  s@    *$d)9)9);v)E '}}H
 W%Or4   c                   > U T;  $ r(   r   )rr   s    r,   <lambda>&phasecache.getrevset.<locals>.<lambda>  s	    1D=r4   )r   r:   r<   r   r;   
differencer   fullreposetre   r   r   r=   filteredrevsbasesetfilter)	r   r1   r   subsetpublicphaser+   r   r   r   s	    ``    @@r,   	getrevsetphasecache.getrevset  sM    	 12V&^..v6F++D11 v;!CQ??1%D M 996B6aq16BCD		 ~~**dnn999~''--- 0 0 666~!--d3FD)D==!899= Cs   5Fc                   U R                  S S SS9nU R                  R                  5       Ul        U R                  Ul        U R                  Ul        U R
                  c	  S Ul        U$ U R
                  R                  5       Ul        U$ )NF)r   )	__class__r   r   rI   r   r   )r   phs     r,   r   phasecache.copy
  sz     ^^D$e^4))..0:: //??" BM 	 !OO002BM	r4   c           	     @    S H  n[        X[        X5      5        M     g)z4replace all values in 'self' with content of phcache)r   rI   r   r   N)setattrgetattr)r   phcacheas      r,   replacephasecache.replace  s    
A DWW01
r4   c                l    UR                  5       nUR                  R                  U R                  5      $ r(   )r:   r=   computephasesr   r   s     r,   _getphaserevsnativephasecache._getphaserevsnative!  s)     ~~++D,<,<==r4   c                   UR                  5       nUR                  n[         Vs0 s H  o3[        5       _M     snU l        [        5       n[        [        5       H  nU R                  U   nU(       d  M  [        UR                  U5      5      nU H  nUR                  U5        M     UR                  U5        UR                  U5        X`R                  U'   M     [        U5      U l        g s  snf r(   )r:   r=   r;   r<   r   reversedtrackedphasesr   descendantsrE   difference_updateupdatere   r   )r   r1   clrS   
lowerrootsrK   psrA   s           r,   _computephaserevspure phasecache._computephaserevspure%  s     ^^5>?YE#%<Y?U
m,E$$U+Eu./!DFF4L "$$Z0!!"%)+& - ""g @s   C.c                :   UR                   b   eSnUR                  n[        U5      nU R                  c  SnO6X@R                  :  a'  X@R                  -
  nU[
        ::  a  U R                  nOSnUS:X  aG   U R                  U5      nUu  U l        U l        U R                  [        UR                  5      :X  d   egUS:  Ga  X R                  :X  d   eU R                  U5      (       Ga  U R                  nU R                  nS/W-  n	UR                  n
U R                   Vs0 s H  o[        5       _M     nnU R                  R                  5        H  u  pU H  nX:  d  M
  XX-
  '   M     M     [        Xt5       H  nXU-
     nU
" U5      u  nnU[         :X  a  ["        nO!UU:  a	  U	UU-
     nO[%        X" UU5      5      nU[         :X  a  ["        nO!UU:  a	  U	UU-
     nO[%        X" UU5      5      n[%        UUU5      nU["        :  d  M  XX-
  '   X   R'                  U5        M     UR                  5        H.  u  nnU(       d  M  U R                  U   U-  U R                  U'   M0     X@l        gg! [         a    U R                  U5         GNf = fs  snf )z0ensure phase information is loaded in the objectNrn   r   )
filternamer=   re   r   r   (INCREMENTAL_PHASE_SETS_UPDATE_MAX_UPDATEr   AttributeErrorr   r   rS   
parentrevsr<   r   rX   ro   r   r   maxrE   )r   r1   r   r   cl_sizemissingresstart	get_phase
rev_phasesparentsrS   setsrK   r   rU   p1p2p1_phasep2_phaseextras                        r,   r   phasecache._ensure_phase_sets5  s   &&&^^b'??"F,,,
 "$7$77FF!00FFQ;1..t47:4#T_ &&#dnn*====aZ00000&&t,,++ JJ	S7]
--26//B/su/B$($4$4$:$:$<LE":49qy1 # %=
 !0C&U{3E$S\FBW}#)u#-b5j#9#&uib.A#BW}#)u#-b5j#9#&uib.A#Bx:Ev~273;/,% 1, %)JJLLE5u151G%1O. %1 #*O  " 1**401 Cs   6 I6 #J6JJc                     SU l         S U l        g )Nr   )r   r   )r   s    r,   
invalidatephasecache.invalidatey  s    r4   c                   U[         :X  a  [        $ U[         :  a  [        [        S5      5      eX R                  :  a  U R                  UR                  5       5        [         H  nX R                  U   ;   d  M  Us  $    [        $ )Ns   cannot lookup negative revision)	r   r   
ValueErrorr   r   r   r:   r   r   )r   r1   rU   rS   s       r,   rS   phasecache.phase}  sp     '>M=QABCC %%%##DOO$56"Eooe,, # r4   c                    U R                   (       d  g UR                  SSSSS9n U R                  UR                  5       U5        UR	                  5         g ! UR	                  5         f = f)Nr9      wT)
atomictemp
checkambig)rI   rB   _writer:   rF   )r   r1   rN   s      r,   writephasecache.write  sO    zzIImTdtIL	KK)1-GGIAGGIs    A A)c           	        UR                   b   eUR                  R                  nU R                  R	                  5        H>  u  pE[        U5       H*  nU" U5      nUR                  SU[        U5      4-  5        M,     M@     SU l        g )Ns   %i %s
F)	r   r=   rT   r   rX   sortedr   r   rI   )r   r1   fpto_noderS   rK   r   hs           r,   r   phasecache._write  su    &&&..%% ,,224LEE]AJuc!fo56 # 5 
r4   c                   ^ ^ UT R                   U'   ST l        U(       a  T R                  5         UR                  b   e[        R
                  " U5      mU U4S jnUR                  SSU5        SUR                  S'   g )NTc                @   > T" 5       nUc   eTR                  X5        g r(   )r   )r   r1   r   wrepos     r,   tr_write)phasecache._updateroots.<locals>.tr_write  s"    7D###KK!r4      phase)r9      1s   phases_moved)r   rI   r   r   weakrefrefaddfilegeneratorhookargs)r   r1   rS   newrootstrr   r  r  s   `      @r,   _updaterootsphasecache._updateroots  sm    "*
OO&&&D!	"
 	H&6A'+O$r4   c                   UR                  5       nU R                  XU/ US9  UbR  SUR                  ;   aB  UR                  S   nU R                  n[	        U5       H  nU" X5      n[        XWS U5        M     UR                  5         g )N)r      phases)r:   _retractboundarychangesrS   r   r   invalidatevolatilesets)	r   r1   r  targetphaser   phasetrackingrS   rU   revphases	            r,   registernewphasecache.registernew  s~     dRdC>i2::5JJy1MJJEd| +!-dHE $ 	##%r4   c           	     0	  ^ ^^# T[         :X  a   T R                  U5      (       d
  [        5       $ UR                  5       nUR                  nUR
                  R                  m#[        5       nUb  UR                  U5        Ub  UR                  U#4S jU 5       5        U(       d
  [        5       $ Uc  Sn	OUR                  R                  S5      n	[        U U4S j[         5       5      n
Un[        5       nT R                  U5        U
 H&  nUT R                  U   -  nX-  nX-  nU(       a  M&    O   U(       d
  [        5       $ [        U5      n[        R                  n[        R                   nUR"                  nT R$                  n0 n[        5       nU
 Vs0 s H  nU[        5       _M     nn[        5       nU Vs/ s H  nU* PM     nn[        R&                  " U5        U(       a  U" U5      * nU" UU5      nUUU'   U" U5      u  nnU[(        :X  a  [         nO	U" UU5      nU[(        :X  a  [         nO	U" UU5      nUU:w  a  UU:w  a  UR+                  U5        UT:  a!  UU;  a  UR+                  U5        U" UU* 5        UT:  a!  UU;  a  UR+                  U5        U" UU* 5        UT:  a  UT:  a  UR+                  U5        U(       a  M  WnU[-        U5      -   [-        U5      :  a  [/        U[-        U5      5       H  nUU;   a  M  U" UU5      nUT::  a  M  U" U5      u  nnUU;   d  UU;   d  M5  U[(        :w  a  UU;  a  U" UU5      nUU:X  a  MV  U[(        :w  a  UU;  a  U" UU5      nUU:X  a  Mw  UU   R+                  U5        M     U(       d  UR1                  5        H  u  nn[3        U	UUT5        M     T[         :  a  T R                  T   R                  U5        U
 He  nT R4                  U   n U U-  n!U!(       d  UU   (       d  M*  T R                  U   R7                  U5        U U-
  UU   -  n"T R9                  XU"USS9  Mg     U(       a%  UT R4                  T   -  nT R9                  UTUUSS9  UR;                  5         U$ s  snf s  snf )zSet all 'nodes' to phase 'targetphase'

Nodes with a phase lower than 'targetphase' are not affected.

If dryrun is True, no actions will be performed

Returns a set of revs whose phase is changed or should be changed
Nc              3  4   >#    U  H  nT" U5      v   M     g 7fr(   r   r*   rT   torevs     r,   r-   -phasecache.advanceboundary.<locals>.<genexpr>       :EDE$KKE   r  c              3  b   >#    U  H$  oT:  d  M
  TR                   U   (       d  M   Uv   M&     g 7fr(   )r   )r*   r+   r   r  s     r,   r-   r    s)      #
 !OA8H8H8KAAys   	//	/Fr   )r   r   r<   r:   r=   r>   rU   r   r  r   r   r;   r   r   heapqheappushheappopr   rS   heapifyr   rE   re   ro   rX   r   r   r   r  r  )$r   r1   r  r  r_   r   dryrunr   new_revsr  affectable_phases
candidatesrS   foundseenpushrp   r   r   changeddelrootsr+   	new_rootsnew_target_rootsr   currentcurrent_phaser   r   r   r   min_currentrK   removedfinal_rootsr  s$   `  `                               @r,   advanceboundaryphasecache.advanceboundary  sk    & )@)@)F)F5L ^^ 5OOD!OO:E:: : MJJNN95M" #
 #
 
 
5%&E!77EHJ: ' 5L 8}~~mm--JJ	5'89'8!QX'8	95$%HqH%d4yjG%dG4M,GGW%FBW}!$T2.W}!$T2.(]h-F W%+%"D.TB3+%"D.TB3+%([*@ $$W-7 d< #g,&#b'1;B0<!$*K' Bgw=Rw%6(r2H5( =Rw%6(r2H5( % $$Q'# 1( 1!-A{C (V#,33G<*((/(*i..OOE*<<WE #(("2Yu5E"EK%%[" &  +   !D$4$4[$AA !!+'7 "  '')e : &s   R:Rc                   Uc  S nOUR                   R                  S5      nUR                  5       nU R                  XX45      nU(       a1  Ub.  [	        UR                  5       5       H  u  px[        XWX5        M     UR                  5         g )Nr  )r  r   r:   r  r   rX   r   r  )	r   r1   r  r  r_   r  	retractedr   	old_phases	            r,   retractboundaryphasecache.retractboundaryL  sr    : MJJNN95M ))$KG	2 &y'8 9!-IK !:##%r4   c           	     l  ^" U[         :X  a  0 $ U[        :X  a  [        U5      (       a  U[        :X  a4  [	        U5      (       d$  [
        U   nSU-  n[        R                  " U5      eUR                  b   eUR                  nUR                  R                  m"[        5       n	Ub  U	R                  U5        Ub  U	R                  U"4S jU 5       5        U	(       d  0 $ [        U	;   a  [        R                  " [!        S5      5      eU R#                  U5        U R$                  R'                  5        H  u  pX:  d  M  X-  n	M     U	(       d  0 $ UR(                  nU R*                  n
[        5       n0 n[        5       nU R,                  U   n[/        U	5      n[1        U5      nS /UU-
  -  nU R$                  U   n[3        UU5       GHE  nU
" UU5      nS nU" U5      u  nnUU:  a  UUU-
     nUb  UnUU:  a  UUU-
     nUb  Ub  [5        UU5      nOUnUU	;   a?  UU:  a9  Ub  UU:  a  UR7                  U5        UUUU-
  '   UUU'   UR7                  U5        O]Uc	  UUUU-
  '   OQUU:  a	  UUUU-
  '   OUUUU-
  '   UU:X  a4  UU:  a  UUU'   UR7                  U5        OUU;   a  UR7                  U5        U R$                  nU[8        :  d  GM  UR'                  5        H&  u  nnU[         :  d  M  UU   R;                  U5        M(     GMH     U(       a  U(       d   eXU-
  -  nU R=                  UUUUSS9  US:  ab  [        U5      n[3        SU5       HG  nU R,                  R?                  U5      n U c  M#  U U-  (       d  M/  U U-
  n!U R=                  UUU!USS9  MI     U$ U(       a   eU(       a   e0 $ )Ns-   this repository does not support the %s phasec              3  4   >#    U  H  nT" U5      v   M     g 7fr(   r   r  s     r,   r-   .phasecache._retractboundary.<locals>.<genexpr>k  r   r!  s!   cannot change null revision phaseFr#  r   ) r   r)   r2   archivedr7   
phasenamesr   r   r   r=   r>   rU   r<   r   r   rf   r   r   r   rX   r   rS   r   minre   ro   r   rE   r   discardr  r   )#r   r1   r  r  r_   r   namemsgr   r)  rS   r   r1  changed_revsreplaced_rootscurrentrootsr   endr   this_phase_setr   r_phasep_phaser   r   r   r   r   r   r7  r;  lower_phaselower_rootssimpler_rootsr  s#                                     @r,   r  phasecache._retractboundaryX  s   & I8##D))h&#D))k*DBTIC((--&&&^^5OOD!OO:E::Ih++a DEFF 	%??002KE#  3 I* --

E	''4H"gVsU{+
5uc"AD!nGGQZFBU{%b5j1'&GU{%b5j1'*"%gx"8"* H};!6?g&;MM!$(3
1u9%")Q""1%(/
1u9%W$,3Jq5y),3Jq5y)k)(*1Q&**1-l*&**1-??DU"*002FAsV|S	))!, 3O #V <#^&CCK    Q-	#(K#8K"&"2"2"6"6{"CK"* "Y..(3i(?)) ')', *  $9  ###%%%Ir4   c                    [        U R                  R                  5       5       H<  u  pEU Vs1 s H  ofU:  d  M
  UiM     nnU(       d  M'  U R                  XXW-
  U5        M>     U R	                  5         gs  snf )zdannounce a strip to the phase cache

Any roots higher than the stripped revision should be dropped.
N)listr   rX   r  r   )r   r1   r  	strip_revr  rK   r   filtereds           r,   register_stripphasecache.register_strip  si     #'t'7'7'='='?"@K#(;5aN5H;x!!$U5ErJ #A 	 <s
   	A5A5)r   r   r   rI   )r1   r   rH   r   r   zLiteral[False]returnNone)T)r1   localrepo.localrepositoryrH   Optional[Phasedefaults]r   boolrY  rZ  r1   r[  rY  r]  )r1   r[  rY  Set[int])r1   r[  rS   r   rY  r_  r(   )r1   r[  r   zIterable[int]r   zOptional[Any]rY  r   )r1   r[  rY  rZ  )r1   r[  rU   r   rY  r   )NNNNN)rU  r   )__name__
__module____qualname____firstlineno__typingTYPE_CHECKINGr   r   r   r   r   r   r   r   r   r   r   r   rS   r   r   r  r  r8  r=  r  rW  __static_attributes__r   r4   r,   r   r     sJ   			 	 "		
 	 
	 

 		+	 3	 		
 	 
	 	8

 '  
	2 !%	9:'9: 9: 	9:
 
9:v2>& B*H&,"	& DHL\
&IV 	r4   r   c           	         Uc  / nU R                   R                  5       nUR                  XX#XES9nU(       d  U R                   R                  U5        U$ )a]  Add nodes to a phase changing other nodes phases if necessary.

This function move boundary *forward* this means that all nodes
are set in the target phase or kept in a *lower* phase.

Simplify boundary to contains phase roots only.

If dryrun is True, no actions will be performed

Returns a set of revs whose phase is changed or should be changed
)r   r(  )_phasecacher   r8  r   )r1   r  r  r_   r   r(  r   r  s           r,   r8  r8    s\     |##%G%%+4 & G   )Nr4   c                    U R                   R                  5       nUR                  XX#5        U R                   R                  U5        g)zSet nodes back to a phase changing other nodes phases if
necessary.

This function move boundary *backward* this means that all nodes
are set in the target phase or kept in a *higher* phase.

Simplify boundary to contains phase roots only.N)ri  r   r=  r   )r1   r  r  r_   r   s        r,   r=  r=    s<     ##%GDk9W%r4   c                    U R                   R                  5       nUR                  XX#5        U R                   R                  U5        g)zregister a new revision and its phase

Code adding revisions to the repository should use this function to
set new changeset in their target phase (or higher).
N)ri  r   r  r   )r1   r  r  r   r   s        r,   r  r    s<     ##%G+4W%r4   c                z   [         R                  " 5       nS[        -  nU R                  5       R                  nUR
                  nU R                  R                  [            H;  nU R                  R                  X5      [        ::  d  M(  X![        U" U5      5      '   M=     U R                  5       (       a  SUS'   U$ )/List phases root for serialization over pushkeyr&   s   True
   publishing)r   sortdictr   r:   r=   rT   ri  r   rS   r   
publishing)r1   keysvaluer   r   rA   s         r,   
listphasesrs  #  s     ==?DEME			$	$BggG  ,,U3!!$-6',WT]#$ 4 " &]Kr4   c           
        U R                  5       n U R                  5          X   R                  5       n[        [	        U5      5      n[        [	        U5      5      nXF:X  a@  XV:  a;  U R                  S5       n[        XU[        U5      /5        SSS5         SSS5        gXE:X  a
   SSS5        g SSS5        g! , (       d  f       N1= f! , (       d  f       g= f)rm  s   pushkey-phaseNTF)r:   lockrS   absr   transactionr8  r   )r1   nhexoldphasestrnewphasestrcurrentphasenewphaseoldphaser  s           r,   	pushphaser~  C  s     ??D	z'')s;'(s;'(#(;!!"23r(SYK@ 4 
 % 
  

 43 
s0   AC7B:	C!C0C:
C	C
Cc                    U R                   n[         Vs0 s H  o3/ _M     nn[         H:  nSU-  nU R                  Xa5       Vs/ s H  orR                  U5      PM     snXE'   M<     U$ s  snf s  snf )zFinds the phase heads for a subset of a history

Returns a list indexed by phase number where each item is a list of phase
head nodes.
s   heads(%%ln & _phase(%d)))r=   r;   r   rT   )r1   r   r   rJ   ri   rS   revsetr   s           r,   subsetphaseheadsr  Z  sr     
B#,-9arE9L-,u43799V3LM3Lawwqz3LM  	 . Ns   A)A.c                    [          HQ  nSnU R                  XBU   U5       Vs/ s H  oUR                  5       PM     nnU(       d  M@  [        X" 5       X65        MS     gs  snf )z+Updates the repo with the given phase headss   %ln - _phase(%s)N)r;   r<   rT   r8  )r1   trgetterri   rS   r  cheadss          r,   updatephasesr  i  sS     $#'88F4G#OP#Oa#OP5D(*e;	 Ps   Ac                $   U R                  5       n / nU R                  R                  R                  nUR	                  5        H  u  pVUS:X  a  M  [        U5      n[        U5      nU[        :X  a;  XpR                  :w  a*  [        S5      nU R                  R                  X-  5        Mf  Mh  U[        :X  a   U" U5      n	U	b  UR                  U	5        M  M  [        S5      nU R                  R                  XU4-  5        M     [        XU5      n
X4$ )zCompute phases heads and root in a subset of node from root dict

* subset is heads of the subset
* roots is {<nodeid> => phase} mapping. key and value are string.

Accept unknown element input
rn  s2   ignoring inconsistent public root from remote: %s
s,   ignoring unexpected root from remote: %i %s
)r:   r=   r>   r?   rX   r   r   r   nullidr   r   warnr   rY   	new_heads)r1   r   rK   draft_rootsrL   rx  rS   rT   rG  rU   public_headss              r,   analyze_remote_phasesr  w  s     ??DK^^!!))F{{}= 4yE
F?{{"NOSZ( # e^,C""3'  DECGGLLt},- %" T;7L$$r4   c                  *    \ rS rSrSr    SS jrSrg)RemotePhasesSummaryi  a  summarize phase information on the remote side

:publishing: True is the remote is publishing
:public_heads: list of remote public phase heads (revs)
:draft_heads: list of remote draft phase heads (revs)
:draft_roots: list of remote draft phase root (revs)
c                    UR                  5       nX0l        [        UR                  SS5      5      U l        [        XU5      u  pVXPl        X`l        UR                  SXb5      nXpl	        g )Nrn  Fs   heads(%ld::%ld))
r:   _allremoterootsr]  r   rp  r  r  r  r   draft_heads)r   r1   remote_subsetremote_rootsunfir  rK   dheadss           r,   r   RemotePhasesSummary.__init__  s`      3? $\%5%5mU%K L,T,O-2,1-uD,2r4   )r  r  r  r  rp  N)r  Collection[int]r  Dict[bytes, bytes])ra  rb  rc  rd  __doc__r   rg  r   r4   r,   r  r    s     3 '3 )	3r4   r  c                   SSK Jn  U(       d  U$ U(       a  U[        /:X  a  / $ [        U5      nUR	                  [        5        U R                  SX$5      nUR                  U5        U R                  SX%5      nXe-  nU(       d  U(       aF  UR                  U5        U R                  SU5      nUR                  XU5      nUR                  U5        [        U5      $ )zcompute new head of a subset minus another

* `heads`: define the first subset
* `roots`: define the second we subtract from the firstr   )dagops
   (%ld::%ld)s-   parents(%ld + (%ld and merge())) and not nulls   parents(%ld) and not null)
 r  r   r<   rE  r   r   r   reachablerootsr   )	r1   r  rK   r  r  affected_zoner+  
prunestartpruneds	            r,   r  r    s     EgY&	 E
IgIImU>M. 8%J JJ$YY;YG
%%d
C##F+ )r4   c                    U R                  SS5      n [        U   $ ! [         a#    [        R                  " [        S5      U-  5      ef = f)zmhelper to get the target phase of new commit

Handle all possible values for the phases.new-commit options.

r  s
   new-commits0   phases.new-commit: not a valid phase name ('%s'))configr%   KeyErrorr   ConfigErrorr   )r   vs     r,   newcommitphaser    sS     			)]+A
A 
ABQF
 	

s	    -A
c                N    [        U R                  R                  [           5      $ )z@utility function that check if a repo have any secret changeset.)r]  ri  r   r!   r0   s    r,   	hassecretr    s      ,,V455r4   c                8    Uc  SnO	[         U   nX[         U   S.$ )Nr4   )s   nodes   oldphaser  )rC  )rT   r   r   s      r,   preparehookargsr    s&    
 {oz#GGr4   r^  r(   )r1   r[  rH   r\  rY  zTuple[Phaseroots, bool])r]   Dict[int, List[bytes]]rY  bytes)rY  r  r`  )r1   r[  rY  r  )
r1   r[  rx  r  ry  r  rz  r  rY  r]  )r   r  rK   r  rY  z'Tuple[Collection[int], Collection[int]])r  r  rK   r  rY  r  )r   zuimod.uirY  r   )rT   r  r   Optional[int]r   r  rY  r  )\r  
__future__r   r$  structre  r	  r   r   r   r   r   r	   r
   r   r   r   i18nr   rT   r   r   r   r   r   r  r   r   r   r   r   r   
Phaseroots	PhaseSetsrf  typing_extensionsr   r   r   uimodlocalrepositoryPhasedefaultsStructrZ   r   __annotations__r   r!   rB  r)   r;   r   not_public_phasescmdphasenamesdict	enumeraterC  rX   r$   r   r%   r   mutablephasesrelevant_mutable_phasesremotehiddenphaseslocalhiddenphasestupleall_internal_phasesno_bundle_phasesr2   r7   rV   ra   rl   r{   r}   r   r   r   r8  r=  r  rs  r~  r  r  r  r  r  r  r  r  )rS   rF  s   00r,   <module>r     sG  dL #          #s3x- 
c#h		 7N7)++Z8*DEM
 h' sUFHh7	(3! 0)M*+
"
8 "
8  $.#3#3#5!#5KEDK#5! 
 (3'7'7'9$ 9   z:zeE\z: ;   zBzeUU]E)zB C(3 &/ h1 x( AyAA & H
H .2'
#'*' 'T	 $3*
,57z ,/ (q	 q	h.
&&@
#
  	
 
.<"%"% "% -	"%J3 38)) ) 	)X
6
	H
	H		H 
	H 		HQ"! ;Bs   H;I-I