
    6hW"                        S SK Jr  SSKJr  SSKJrJrJr  SSKJ	r	J
r
   " S S\	R                  5      rS	 rS
 rS r\\\/rS rg)    )annotations   )_)errorrequirementsscmutil   )actionsenginec                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )AutoUpgradeOperation   zfA limited Upgrade Operation used to run simple auto upgrade task

(Expand it as needed in the future)
c                "   > [         TU ]  USS9  g )NF)new_requirementsbackup_store)super__init__)selfreq	__class__s     F/usr/lib/python3/dist-packages/mercurial/upgrade_utils/auto_upgrade.pyr   AutoUpgradeOperation.__init__   s      	 	
     )__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__)r   s   @r   r   r      s    

 
r   r   c                  ^ ^^^^^	 T R                   m	T R                  mT	R                  SS5      nT	R                  SS5      mSnU(       a  [        R                  T;  as  T	R                  SS5      n[        R
                  T;   nU(       a!  U(       d  [        S5      mSmUUUU UU	4S jnU$ U(       a  U(       d  [        S	5      mSmUUUU UU	4S
 jnU$ )zreturn an automatic-upgrade action for `share-safe` if applicable

If no action is needed, return None, otherwise return a callback to upgrade
or downgrade the repository according the configuration and repository
format.
   formats<   use-share-safe.automatic-upgrade-of-mismatching-repositoriessB   use-share-safe.automatic-upgrade-of-mismatching-repositories:quietNs   use-share-safes?   automatically upgrading repository to the `share-safe` feature
s9   (see `hg help config.format.use-share-safe` for details)
c                    > TR                   (       d)  T (       d"  TR                  T5        TR                  T5        TR                  [        R                  5        [
        R                  " TT5        g N)quiet	write_erraddrequirementsmodSHARESAFE_REQUIREMENTr   writereporequirementsauto_upgrade_quiethintmsgrepor   uis   r   action%get_share_safe_action.<locals>.actionF   sI    $6LL%LL&  !F!FG--dLAr   sC   automatically downgrading repository from the `share-safe` feature
c                    > TR                   (       d)  T (       d"  TR                  T5        TR                  T5        TR                  [        R                  5        [
        R                  " TT5        g r%   )r&   r'   discardr)   r*   r   r+   r,   s   r   r2   r3   T   sI    $6LL%LL&$$_%J%JK--dLAr   )r1   r   
configboolr)   SHARED_REQUIREMENTr*   r   )
r0   auto_upgrade_share_sourcer2   	sf_configsf_localr-   r.   r/   r   r1   s
   `    @@@@@r   get_share_safe_actionr;   %   s     
B$$L "G! M
 F 	"..lBMM)->?	"88LHXC QDB B* M iC QDB B Mr   c                  ^ ^^^^^	 T R                   m	[        T R                  5      mT	R                  SS5      nT	R                  SS5      mSnU(       as  T	R                  SS5      n[        R
                  T;   nU(       a!  U(       d  [        S5      mSmUUUU UU	4S jnU$ U(       a  U(       d  [        S	5      mSmUUUU UU	4S
 jnU$ )zreturn an automatic-upgrade action for `tracked-hint` if applicable

If no action is needed, return None, otherwise return a callback to upgrade
or downgrade the repository according the configuration and repository
format.
r#   sG   use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositoriessM   use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories:quietNs   use-dirstate-tracked-hintsA   automatically upgrading repository to the `tracked-hint` feature
sD   (see `hg help config.format.use-dirstate-tracked-hint` for details)
c                    > TR                   (       d)  T(       d"  TR                  T5        TR                  T5        TR                  [        R                  5        [        T5      n [        R                  " TTU SS9  g )NTr(   )r&   r'   r(   r)   DIRSTATE_TRACKED_HINT_V1r   r   upgrade_tracked_hintopr-   r.   r/   r0   r   r1   s    r   r2   'get_tracked_hint_action.<locals>.action|   sW    $6LL%LL&  !I!IJ),7++BbdCr   sE   automatically downgrading repository from the `tracked-hint` feature
c                    > TR                   (       d)  T(       d"  TR                  T5        TR                  T5        TR                  [        R                  5        [        T5      n [        R                  " TTU SS9  g )NFr>   )r&   r'   r5   r)   r?   r   r   r@   rA   s    r   r2   rC      sW    $6LL%LL&$$_%M%MN),7++BbeDr   )r1   setr   r6   r)   r?   r   )
r0   auto_upgrade_tracked_hintr2   	th_configth_localr-   r.   r/   r   r1   s
   `    @@@@@r   get_tracked_hint_actionrI   ^   s     
Bt(()L "R! X
 F MM)-IJ	";;|KXC \DD D. M iC \DE E Mr   c                  ^ ^^^^^	 T R                   m	[        T R                  5      mT	R                  SS5      nT	R                  SS5      mSnU(       as  T	R                  SS5      n[        R
                  T;   nU(       a!  U(       d  [        S5      mSmUUUU UU	4S jnU$ U(       a  U(       d  [        S	5      mSmUUUU UU	4S
 jnU$ )zreturn an automatic-upgrade action for `dirstate-v2` if applicable

If no action is needed, return None, otherwise return a callback to upgrade
or downgrade the repository according the configuration and repository
format.
r#   s=   use-dirstate-v2.automatic-upgrade-of-mismatching-repositoriessC   use-dirstate-v2.automatic-upgrade-of-mismatching-repositories:quietNs   use-dirstate-v2s@   automatically upgrading repository to the `dirstate-v2` feature
s:   (see `hg help config.format.use-dirstate-v2` for details)
c                   > TR                   (       d)  T(       d"  TR                  T5        TR                  T5        TR                  [        R                  5        [        T5      n [        R                  " TR                  TU SS5        g )N   v1   v2)	r&   r'   r(   r)   DIRSTATE_V2_REQUIREMENTr   r   upgrade_dirstater1   fake_opauto_upgrade_dv2_quietr.   r/   r0   r   r1   s    r   r2   &get_dirstate_v2_action.<locals>.action   s]    $:LL%LL&  !H!HI.|<''wuMr   sD   automatically downgrading repository from the `dirstate-v2` feature
c                   > TR                   (       d)  T(       d"  TR                  T5        TR                  T5        TR                  [        R                  5        [        T5      n [        R                  " TR                  TU SS5        g )NrM   rL   )	r&   r'   r5   r)   rN   r   r   rO   r1   rP   s    r   r2   rS      s]    $:LL%LL&$$_%L%LM.|<''wuMr   )r1   rE   r   r6   r)   rN   r   )
r0   auto_upgrade_dv2r2   	d2_configd2_localrR   r.   r/   r   r1   s
   `    @@@@@r   get_dirstate_v2_actionrX      s     
Bt(()L}}H  ]]N
 FMM)-?@	"::lJXC
 O N N2 M# iC
 O N N Mr   c                   SnSn U(       d  US-  nUS:  a  [         R                  " S5      eSn[         H[  nU" U 5      nUc  M  SnU R                  SS9   U R	                  SS9   U" U 5      nUb  U" 5         U" 5       n SSS5        SSS5        M]     U(       d  M  U $ ! , (       d  f       N%= f! , (       d  f       M  = f! [         R
                   a     U $ f = f)	a  potentially perform auto-upgrade and return the final repository to use

Auto-upgrade are "quick" repository upgrade that might automatically be run
by "any" repository access. See `hg help config.format` for automatic
upgrade documentation.

note: each relevant upgrades are done one after the other for simplicity.
This avoid having repository is partially inconsistent state while
upgrading.

repo: the current repository instance
maker_func: a factory function that can recreate a repository after an upgrade
Fr   r	   d   zToo many auto upgrade loopsTN)wait)r   ProgrammingErrorAUTO_UPGRADE_ACTIONSwlocklock	LockError)r0   
maker_funcclearloop
get_actionr2   s         r   may_auto_upgradere      s     EDAIDcz,,-JKKE2
#D)%!E/1F!+D!1!-"H)|	 2G//	 3 %* K 2G1F//
 ??  	KsG   <C C B1'B B1	C  
B.*B11
C 	;C CCN)
__future__r   i18nr    r   r   r)   r   r
   r   BaseOperationr   r;   rI   rX   r]   re   r   r   r   <module>rj      sX    #  

700 

6r5p9z  (r   