
    6hg                       % S SK Jr  S SKrS SK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  \\/(       d   e\R                   \R"                  \R$                  \R&                  1rS rS	rS
r " S S5      r/ rS\S'   S r " S S\5      r " S S\5      r\ " S S\5      5       r\ " S S\5      5       r\ " S S\5      5       r \ " S S\5      5       r!\ " S S\5      5       r"\ " S S\5      5       r#\ " S  S!\5      5       r$\ " S" S#\5      5       r%\ " S$ S%\5      5       r&\ " S& S'\5      5       r'\ " S( S)\5      5       r(\ " S* S+\5      5       r)S,\RT                  ;   =(       aA    \RT                  S,   RW                  5       =(       a    \RT                  S,   RY                  5       r-\ " S- S.\5      5       r.\ " S/ S0\5      5       r/S1 r0S2 r1/ r2S3 r3 " S4 S5\5      r4\3 " S6 S7\45      5       r5\3 " S8 S9\45      5       r6\3 " S: S;\45      5       r7\3 " S< S=\45      5       r8S> r9S? r: " S@ SA5      r; " SB SC\;5      r<SD r=SE r>SF r?SG r@SH rASI rBSJ rCSK rDg)L    )annotationsN)ListType   )_)error	localreporequirementsrevlogutil)compressionc                ^    [         R                  [         R                  1nXR                   -  $ N)r
   SHARED_REQUIREMENTNARROW_REQUIREMENT)repo	preserveds     A/usr/lib/python3/dist-packages/mercurial/upgrade_utils/actions.pypreservedrequirementsr   +   s,    ''''I ((((    s
   deficiencys   optimizationc                  L    \ rS rSrSrSrSrSrSrSr	Sr
SrSrSrSrSrSrSrSrg)improvement7   zARepresents an improvement that can be made as part of an upgrade.NTF )__name__
__module____qualname____firstlineno____doc__typenamedescriptionupgrademessagedefaultpostupgrademessagepostdowngrademessagetouches_filelogstouches_manifeststouches_changelogtouches_requirementstouches_dirstatecompatible_with_share__static_attributes__r   r   r   r   r   7   sh    K D D K N G   
       "r   r   zList[Type[formatvariant]]allformatvariantc                0    [         R                  U 5        U $ r   )r.   append)clss    r   registerformatvariantr2   t   s    C Jr   c                  <    \ rS rSrSr\r\S 5       r\S 5       r	Sr
g)formatvarianty   z6an improvement subclass dedicated to repository formatc                    [        5       e)z.current value of the variant in the repositoryNotImplementedErrorr   s    r   fromrepoformatvariant.fromrepo~        "##r   c                    [        5       e)z1current value of the variant in the configurationr7   r9   s    r   
fromconfigformatvariant.fromconfig   r<   r   r   N)r   r   r   r   r   FORMAT_VARIANTr    staticmethodr:   r>   r-   r   r   r   r4   r4   y   s0    @D$ $ $ $r   r4   c                  L    \ rS rSrSrSr\S 5       r\S 5       r	\S 5       r
Srg)requirementformatvariant   zformatvariant based on a 'requirement' name.

Many format variant are controlled by a 'requirement'. We define a small
subclass to factor the code.
Nc                X    [         R                  " U [         R                  " U 5      5      $ r   )r	   newreporequirementsdefaultcreateopts)uis    r   _newreporequirements-requirementformatvariant._newreporequirements   s%    ,,	++B/
 	
r   c                R    U R                   c   eU R                   UR                  ;   $ r   )_requirementr
   r1   r   s     r   r:   !requirementformatvariant.fromrepo   s+    +++4#4#444r   c                p    U R                   c   eU R                   U R                  UR                  5      ;   $ r   )rL   rI   rH   rM   s     r   r>   #requirementformatvariant.fromconfig   s4    +++3#;#;DGG#DDDr   r   )r   r   r   r   r   rL   rA   rI   classmethodr:   r>   r-   r   r   r   rC   rC      sJ     L
 

 5 5 E Er   rC   c                  T    \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      rSrg)fncache   s   fncacheTsY   long and reserved filenames may not work correctly; repository performance is sub-optimalss   repository will be more resilient to storing certain paths and performance of certain operations should be improvedr   N)r   r   r   r   r!   r
   FNCACHE_REQUIREMENTrL   r$   r   r"   r#   r-   r   r   r   rS   rS      s7    D33LG	1K
 	)Nr   rS   c                  l    \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      rSrSrSrSrSrSrSrg)	
dirstatev2   s   dirstate-v2Fs   version 1 of the dirstate file format requires reading and parsing it all at once.
Version 2 has a better structure,better information and lighter update mechanisms   "hg status" will be fasterTr   N)r   r   r   r   r!   r
   DIRSTATE_V2_REQUIREMENTrL   r$   r   r"   r#   r'   r(   r)   r*   r+   r,   r-   r   r   r   rW   rW      sW    D77LG	;K 45N r   rW   c                  l    \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      rSrSrSrSrSrSrSrg)	dirstatetrackedkey   s   tracked-hintFsD   Add a small file to help external tooling that watch the tracked setsH   external tools will be informated of potential change in the tracked setTr   N)r   r   r   r   r!   r
   DIRSTATE_TRACKED_HINT_V1rL   r$   r   r"   r#   r'   r(   r)   r*   r+   r,   r-   r   r   r   r[   r[      sY    D88LGOK SN  r   r[   c                  T    \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      rSrg)	dotencode   s	   dotencodeTsL   storage of filenames beginning with a period or space may not work correctlysN   repository will be better able to store files beginning with a space or periodr   N)r   r   r   r   r!   r
   DOTENCODE_REQUIREMENTrL   r$   r   r"   r#   r-   r   r   r   r_   r_      s7    D55LG	(K
 	,Nr   r_   c                  T    \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      rSrg)generaldelta   s   generaldeltaTs   deltas within internal storage are unable to choose optimal revisions; repository is larger and slower than it could be; interaction with other repositories may require extra network and CPU resources, making "hg push" and "hg pull" slowers  repository storage will be able to create optimal deltas; new repository data will be smaller and read times should decrease; interacting with other repositories using this storage model should require less network and CPU resources, making "hg push" and "hg pull" fasterr   N)r   r   r   r   r!   r
   GENERALDELTA_REQUIREMENTrL   r$   r   r"   r#   r-   r   r   r   rc   rc      s7    D88LG	<K 	Nr   rc   c                      \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      r\	" S5      r\	" S5      rSrSrSrSrS	rg
)	sharesafei  s
   share-safeTs   old shared repositories do not share source repository requirements and config. This leads to various problems when the source repository format is upgraded or some new extensions are enabled.sw   Upgrades a repository to share-safe format so that future shares of this repository share its requirements and configs.sh   repository downgraded to not use share safe mode, existing shares will not work and need to be reshared.s   repository upgraded to share safe mode, existing shares will still work in old non-safe mode. Re-share existing shares to use them in safe mode New shares will be created in safe mode.Fr   N)r   r   r   r   r!   r
   SHARESAFE_REQUIREMENTrL   r$   r   r"   r#   r&   r%   r'   r(   r)   r*   r-   r   r   r   rg   rg     sw    D55LG	#K 	IN
 	B
 	5 r   rg   c                  T    \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      rSrg)sparserevlogi;  s   sparserevlogTsX  in order to limit disk reading and memory usage on older version, the span of a delta chain from its root to its end is limited, whatever the relevant data in this span. This can severly limit Mercurial ability to build good chain of delta resulting is much more storage space being taken and limit reusability of on disk delta during exchange.s   Revlog supports delta chain with more unused data between payload. These gaps will be skipped at read time. This allows for better delta chains, making a better compression and faster exchange with server.r   N)r   r   r   r   r!   r
   SPARSEREVLOG_REQUIREMENTrL   r$   r   r"   r#   r-   r   r   r   rj   rj   ;  s7    D88LG	K 	?Nr   rj   c                  T    \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      rSrg)persistentnodemapiU  s   persistent-nodemapFs9   persist the node -> rev mapping on disk to speedup lookups#   Speedup revision lookup by node id.r   N)r   r   r   r   r!   r
   NODEMAP_REQUIREMENTrL   r$   r   r"   r#   r-   r   r   r   rm   rm   U  s1     D33LGDK =>Nr   rm   c                  \    \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      rSrSrSrg)	copiessdcid  s
   copies-sdcFs/   Stores copies information alongside changesets.sA   Allows to use more efficient algorithm to deal with copy tracing.r   N)r   r   r   r   r!   r
   COPIESSDC_REQUIREMENTrL   r$   r   r"   r#   r'   r(   r-   r   r   r   rp   rp   d  s=    D55LGFGKLN r   rp   c                  T    \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      rSrg)revlogv2iv  s	   revlog-v2Fs   Version 2 of the revlog.s   very experimentalr   N)r   r   r   r   r!   r
   REVLOGV2_REQUIREMENTrL   r$   r   r"   r#   r-   r   r   r   rs   rs   v  s-    D44LG/0K+,Nr   rs   c                  \    \ rS rSrSr\R                  rSr\	" S5      r
\	" S5      rSrSrSrg)changelogv2i  s   changelog-v2Fs7   An iteration of the revlog focussed on changelog needs.s   quite experimentalr   N)r   r   r   r   r!   r
   CHANGELOGV2_REQUIREMENTrL   r$   r   r"   r#   r'   r(   r-   r   r   r   rv   rv     s9    D77LGNOK,-Nr   rv   c                  \    \ rS rSrSrSr\" S5      r\" S5      r\	S 5       r
\	S 5       rSrg	)
removecldeltachaini  s   plain-cl-deltaTs   changelog storage is using deltas instead of raw entries; changelog reading and any operation relying on changelog data are slower than they could besz   changelog storage will be reformated to store raw entries; changelog reading will be faster; changelog size may be reducedc                F  ^ U R                  5       R                  n[        U5      S::  a  [        U5      nOF[	        [        S5       Vs1 s H&  n[        R                  " S[        U5      S-
  5      iM(     sn5      nUR                  m[        U4S jU 5       5      $ s  snf )Ni  r      c              3  8   >#    U  H  oT" U5      :H  v   M     g 7fr   r   ).0rev	chainbases     r   	<genexpr>.removecldeltachain.fromrepo.<locals>.<genexpr>  s     =HS)C.(Hs   )

unfiltered	changeloglenlistsortedrangerandomrandintr   all)r   clsome_revxr   s       @r   r:   removecldeltachain.fromrepo  s     __((r7d?BxH 9>tEA3r7Q;/EH LL	=H=== Fs   	-Bc                    gNTr   r9   s    r   r>   removecldeltachain.fromconfig  s    r   r   N)r   r   r   r   r!   r$   r   r"   r#   rA   r:   r>   r-   r   r   r   ry   ry     sT    DG	K 	1N > >  r   ry      zstdc                  p    \ rS rSrSr\(       a  SrOSr\" S5      r\" S5      r	\
S 5       r\
S 5       rS	rg
)compressionenginei     compressionr      zlibsM   Compresion algorithm used to compress data. Some engine are faster than others;   revlog content will be recompressed with the new algorithm.c                    SnUR                    H@  nUR                  nU" S5      (       d  U" S5      (       d  M+  UR                  SS5      S   nMB     U$ )Nr   s   revlog-compression-s   exp-compression-   -r   )r
   
startswithsplit)r1   r   r   reqprefixs        r   r:   compressionengine.fromrepo  sV     $$C^^F,--8K1L1L!iia03 % r   c                    UR                   R                  SS5      nU H\  nU[        R                  ;   d  M  [        R                  U   nUR	                  5       (       d  MC  UR                  5       (       d  MZ  Us  $    SR                  U5      $ )Ns   formats   revlog-compression   ,)rH   
configlistr   compengines	availablerevlogheaderjoin)r1   r   r   compes        r   r>   compressionengine.fromconfig  sn    gg((4IJDt'''$$T*;;==Q^^%5%5K	   yy%%r   r   N)r   r   r   r   r!   	_has_zstdr$   r   r"   r#   rQ   r:   r>   r-   r   r   r   r   r     sZ    D	-K
 FN 
 
 
& 
&r   r   c                  \    \ rS rSrSrSr\" S5      r\" S5      r\	S 5       r
\	S 5       rSrg	)
compressionleveli  s   compression-level   defaults   compression levels#   revlog content will be recompressedc                    [         R                  U5      nS nUS:X  a  UR                  R                  SS5      nO"US:X  a  UR                  R                  SS5      nUc  gSU-  $ Nr   s   storages   revlog.zlib.levelr   s   revlog.zstd.levelr   s   %d)r   r:   rH   	configintr1   r   r   levels       r   r:   compressionlevel.fromrepo  se     ))$/7?GG%%j2FGEW_GG%%j2FGE=u}r   c                    [         R                  U5      nS nUS:X  a  UR                  R                  SS5      nO"US:X  a  UR                  R                  SS5      nUc  gSU-  $ r   )r   r>   rH   r   r   s       r   r>   compressionlevel.fromconfig  se     ++D17?GG%%j2FGEW_GG%%j2FGE=u}r   r   N)r   r   r   r   r!   r$   r   r"   r#   rQ   r:   r>   r-   r   r   r   r   r     sH    DG()K=>N	 	 	 	r   r   c                v    / n[          H,  nUR                  U 5      (       a  M  UR                  U5        M.     U$ )zBreturns a list of format upgrades which can be perform on the repo)r.   r:   r0   )r   upgradesfvs      r   find_format_upgradesr   	  s5    H {{4  OOB  Or   c                4   / n[          H  nUR                  S:X  a7  UR                  U 5      UR                  U 5      :w  a  UR	                  U5        MJ  UR                  U 5      (       d  Mb  UR                  U 5      (       a  Mz  UR	                  U5        M     U$ )zrreturns a list of format downgrades which will be performed on the repo
because of disabled config option for themr   )r.   r!   r:   r>   r0   )r   
downgradesr   s      r   find_format_downgradesr     s     J77n$ {{4 BMM$$77!!"% ;;tR]]4%8%8b!  r   c                0    [         R                  U 5        U $ r   )ALL_OPTIMISATIONSr0   )objs    r   register_optimizationr   1  s    S!Jr   c                      \ rS rSrSr\rSrg)optimizationi6  z2an improvement subclass dedicated to optimizationsr   N)r   r   r   r   r   OPTIMISATIONr    r-   r   r   r   r   r   6  s
    <Dr   r   c                  <    \ rS rSrSr\r\" S5      r\" S5      r	Sr
g)redeltaparentsi<     re-delta-parents]  deltas within internal storage will be recalculated to choose an optimal base revision where this was not already done; the size of the repository may shrink and various operations may become faster; the first time this optimization is performed could slow down upgrade execution considerably; subsequent invocations should not run noticeably slowersH   deltas within internal storage will choose a new base revision if neededr   Nr   r   r   r   r!   r   r    r   r"   r#   r-   r   r   r   r   r   <  s,    DD	%K 	#Nr   r   c                  <    \ rS rSrSr\r\" S5      r\" S5      r	Sr
g)redeltamultibaseiR     re-delta-multibases  deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of mergess   deltas within internal storage will choose an optimal delta by computing deltas against multiple parents; may slow down execution time significantlyr   Nr   r   r   r   r   r   R  s,     DD	)
K 	Nr   r   c                  <    \ rS rSrSr\r\" S5      r\" S5      r	Sr
g)
redeltaallil     re-delta-alls   deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not neededsn   deltas within internal storage will be fully recomputed; this will likely drastically slow down execution timer   Nr   r   r   r   r   r   l  s,    DD	0K 	Nr   r   c                  <    \ rS rSrSr\r\" S5      r\" S5      r	Sr
g)redeltafulladdi     re-delta-fulladds   every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.s   each revision will be added as new content to the internal storage; this will likely drastically slow down execution time, but some extensions might need itr   Nr   r   r   r   r   r     s,    DD	0K 	Nr   r   c                     [        [        5      $ )z8Determine optimisation that could be used during upgrade)r   r   r9   s    r   findoptimizationsr     s     !""r   c                   ^ / mU H>  n[        US5      (       a  UR                  nOSnUb  Xd;  a  M-  TR                  U5        M@     TR                  U4S j[	        US S9 5       5        T$ )a  Determine upgrade actions that will be performed.

Given a list of improvements as returned by ``find_format_upgrades`` and
``findoptimizations``, determine the list of upgrade actions that
will be performed.

The role of this function is to filter improvements if needed, apply
recommended optimizations from the improvements list that make sense,
etc.

Returns a list of action names.
rL   Nc              3  8   >#    U  H  nUT;  d  M  Uv   M     g 7fr   r   )r}   o
newactionss     r   r   ,determine_upgrade_actions.<locals>.<genexpr>  s"      >AJ 	
>s   
	c                    U R                   $ r   r!   )r   s    r   <lambda>+determine_upgrade_actions.<locals>.<lambda>  s    affr   key)hasattrrL   r0   extendr   )r   format_upgradesoptimizations
sourcereqsdestreqsdr!   r   s          @r   determine_upgrade_actionsr     sz     J1n%%>>DD  4!   ,<>  r   c                      \ rS rSrSrS rSrg)BaseOperationi  zbase class that contains the minimum for an upgrade to work

(this might need to be extended as the usage for subclass alternative to
UpgradeOperation extends)
c                    Xl         X l        g r   )new_requirementsbackup_store)selfr   r   s      r   __init__BaseOperation.__init__  s    
 !1(r   )r   r   N)r   r   r   r   r   r   r-   r   r   r   r   r     s    )r   r   c                     ^  \ rS rSrSrU 4S jr\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       r\S	 5       r\S
 5       rSS jrS rS rS rS rS rS rS rSrU =r$ )UpgradeOperationi  z/represent the work to be done during an upgradec                   > [         TU ]  UU5        Xl        X0l        X@l        XPl        X`l        U R                  U R                  -
  U l        U R                  U R                  -
  U l	        U R                  U R                  -  U l
        [        S 5      nU V	s/ s H  oU R                  ;  d  M  U	PM     sn	U l        U R                  n
[        R                  R                  U l        SU
;   a   [        R                  R"                  U l        OqSU
;   a   [        R                  R$                  U l        OKSU
;   a   [        R                  R$                  U l        O%SU
;   a  [        R                  R&                  U l        SU
;   U l        g s  sn	f )Nr   r   r   r   )superr   rH   current_requirementsupgrade_actionsremoved_actionsrevlogs_to_processr   _added_requirements_removed_requirements_preserved_requirementsr   unused_optimizationsupgrade_actions_namesr   DELTAREUSEALWAYSdelta_reuse_modeDELTAREUSENEVERDELTAREUSESAMEREVSDELTAREUSEFULLADDforce_re_delta_both_parents)r   rH   r   r   r   r   r   r   all_optimizationsir   	__class__s              r   r   UpgradeOperation.__init__  sj    		
 $8!.."4 !!D$=$== 	 
 %%(=(== 	"
 %%(=(== 	$
 .d3(%
(!T5I5I,IA(%
!
 !% : : & > >33$*MM$A$AD!#88$*MM$D$DD!"&;;$*MM$D$DD! $99$*MM$C$CD! "%:: 	(#%
s   F0Fc                X    U R                    Vs1 s H  oR                  iM     sn$ s  snf r   )r   r!   r   as     r   r   &UpgradeOperation.upgrade_actions_names  s$     $ 4 45 41 4555s   'c                    U R                   =(       aY    U R                  (       + =(       aA    U R                  (       + =(       a)    U R                  (       + =(       a    U R                  (       + $ r   )r*   r'   r(   r)   r+   r   s    r   requirements_only"UpgradeOperation.requirements_only  sZ     %% *)))***** **** )))	
r   c                    U R                    H,  nUR                  [        :X  a    gUR                  (       d  M,    g   U R                   H  nUR                  (       d  M    g   gNTF)r   r    r   r'   r   r  s     r   r'   !UpgradeOperation.touches_filelogs"  sV    %%Avv%### & %%A!!! & r   c                    U R                    H,  nUR                  [        :X  a    gUR                  (       d  M,    g   U R                   H  nUR                  (       d  M    g   gr  )r   r    r   r(   r   r  s     r   r(   "UpgradeOperation.touches_manifests/  V    %%Avv%$$$ & %%A""" & r   c                    U R                    H,  nUR                  [        :X  a    gUR                  (       d  M,    g   U R                   H  nUR                  (       d  M    g   gr  )r   r    r   r)   r   r  s     r   r)   "UpgradeOperation.touches_changelog<  r  r   c                    U R                    H,  nUR                  [        :X  a  M  UR                  (       d  M,    g   U R                   H  nUR                  (       d  M    g   g r   )r   r    r   r*   r   r  s     r   r*   %UpgradeOperation.touches_requirementsI  sS    %%A vv%''' & %%A%%% &r   c                    U R                    H,  nUR                  [        :X  a  M  UR                  (       d  M,    g   U R                   H  nUR                  (       d  M    g   gr  )r   r    r   r+   r   r  s     r   r+   !UpgradeOperation.touches_dirstateV  sV    %%Avv%### & %%A!!! & r   c                    Sn[        U5       H@  nU(       d  U R                  R                  S5        U R                  R                  XBS9  SnMB     g)z;
Utility function to aid writing of a list under one label
T   , )labelFN)r   rH   write)r   lr  firstrs        r   _write_labeledUpgradeOperation._write_labeledd  sA     Ae$GGMM!M)E	 r   c                   U R                   R                  [        S5      5        U R                   R                  [        S5      5        U R                  U R                  S5        U R                   R                  S5        U R                  (       a[  U R                   R                  [        S5      5        U R                  U R                  S5        U R                   R                  S5        U R                  (       a[  U R                   R                  [        S5      5        U R                  U R                  S5        U R                   R                  S5        U R                   R                  S5        g )	Ns   requirements
s      preserved: s"   upgrade-repo.requirement.preserved   
s      removed: s    upgrade-repo.requirement.removeds
      added: s   upgrade-repo.requirement.added)rH   r  r   r  r   writenoi18nr   r   r  s    r   print_requirements#UpgradeOperation.print_requirementso  s   a)*+a)*+((*O	
 	E"%%GGMM!O,-**,O GG&##GGMM!M*+((*K GG&er   c                   U R                    Vs/ s H  oR                  [        :X  d  M  UPM     nnUR                  S S9  U(       al  U R                  R                  [        S5      5        U R                  U Vs/ s H  oR                  PM     snS5        U R                  R                  S5        g g s  snf s  snf )Nc                    U R                   $ r   r   )r  s    r   r   6UpgradeOperation.print_optimisations.<locals>.<lambda>  s    r   r   s   optimisations: s#   upgrade-repo.optimisation.performeds   

)	r   r    r   sortrH   r  r   r  r!   )r   r  optimisationss      r   print_optimisations$UpgradeOperation.print_optimisations  s    ++
+!vv/EA+ 	 
 	/0GGMM!./0!./A/6 GGMM'" 	
 0s   B6B6<B;c                    U R                    H7  nU R                  R                  SUR                  UR                  4-  5        M9     g Ns
   %s
   %s

)r   rH   statusr!   r#   r  s     r   print_upgrade_actions&UpgradeOperation.print_upgrade_actions  s7    %%AGGNN+qvvq7G7G.HHI &r   c                >   U R                   (       d  U R                  R                  S5        OUU R                  R                  S5        [        U R                   5       H!  nU R                  R                  SU-  5        M#     U R                  R                  S5        g )Ns   no revlogs to process
s   processed revlogs:
s     - %s
r!  )r   rH   r"  r   )r   r  s     r   print_affected_revlogs'UpgradeOperation.print_affected_revlogs  sn    &&GG :;GG 78D334##K!O4 5E"r   c                    U R                    H@  nU R                  R                  [        S5      UR                  UR
                  4-  5        MB     g r-  )r   rH   r.  r   r!   r"   )r   r   s     r   print_unused_optimizations+UpgradeOperation.print_unused_optimizations  s:    **AGGNN1-.!&&!--1HHI +r   c                    XR                   ;   $ )z<Check whether the upgrade operation will perform this action)r   )r   r!   s     r   has_upgrade_action#UpgradeOperation.has_upgrade_action  s    1111r   c                ,   U R                    H:  nUR                  c  M  U R                  R                  SUR                  -  5        M<     U R                   H:  nUR
                  c  M  U R                  R                  SUR
                  -  5        M<     g)z-print post upgrade operation warning messagesNs   %s
)r   r%   rH   warnr   r&   r  s     r   print_post_op_messages'UpgradeOperation.print_post_op_messages  sr    %%A##/Wq';';;< & %%A%%1Wq'='==> &r   )r   r   r   r   r   r   r   r   rH   r   r   )r  bytes)r   r   r   r   r   r   propertyr   r	  r'   r(   r)   r*   r+   r  r#  r*  r/  r2  r5  r8  r<  r-   __classcell__)r  s   @r   r   r     s    96
p 6 6 
 
 
 
 
 
 
 
 
 
  	*#J#J2? ?r   r   c                $    [         R                  1$ )zObtain requirements required to be present to upgrade a repo.

An upgrade will not be allowed if the repository doesn't have the
requirements returned by this function.
)r
   STORE_REQUIREMENTr9   s    r   requiredsourcerequirementsrC    s     	&& r   c                    S1$ )zObtain requirements that will prevent an upgrade from occurring.

An upgrade cannot be performed if the source repository contains a
requirements in the returned set.
s   parentdeltar   r9   s    r   blocksourcerequirementsrE    s     	 r   c                    [         R                  [         R                  1nUR                  U 5      (       d!  [	        S5      n[
        R                  " U5      eg)z?Check that the requirements contain at least one Revlog versions3   cannot upgrade repository; missing a revlog versionN)r
   REVLOGV1_REQUIREMENTrt   intersectionr   r   Abort)reqsall_revlogsmsgs      r   check_revlog_versionrM    sO     	))))K ##D))FGkk# *r   c                   [        U R                  5        [        U 5      nXR                  -
  nU(       a=  [        S5      nSR	                  [        U5      5      n[        R                  " X2-  5      e[        U 5      nX@R                  -  nU(       a=  [        S5      nSR	                  [        U5      5      n[        R                  " Xe-  5      e[        R                  U R                  ;   =(       a    [        R                  U R                  ;  nU(       a*  [        S5      n[        S5      n[        R                  " XhS9eg)zCEnsure that no existing requirements prevent the repository upgrades2   cannot upgrade repository; requirement missing: %sr  s=   cannot upgrade repository; unsupported source requirement: %ss>   cannot upgrade repository; share repository without share-safes-   check :hg:`help config.format.use-share-safe`)hintN)rM  r
   rC  r   r   r   r   rI  rE  r   rh   )	r   requiredmissingreqsrL  blockingblockingreqsm	bad_sharehs	            r   check_source_requirementsrW    s    **+)$/H...KEFjj!45kk#+,,&t,H///LNOzz&"67kk!*++ 	''4+<+<< 	H..d6G6GG  OP>?kk!$$ r   c           	     >   [         R                  [         R                  [         R                  [         R                  [         R
                  [         R                  [         R                  [         R                  [         R                  1	n[        R                   H  n[        R                  U   nUR                  5       (       d  M-  UR                  5       (       d  MD  UR                  SU-  5        UR                  5       S:X  d  Mn  UR                  S5        M     U$ )zObtain requirements that can be removed during an upgrade.

If an upgrade were to create a repository that dropped a requirement,
the dropped requirement must appear in the returned set for the upgrade
to be allowed.
   exp-compression-%sr      revlog-compression-zstd)r
   rk   rq   rn   rh   rt   rw   rG  r]   rY   r   r   r   r   addr!   r   	supportedr!   engines       r   supportremovedrequirementsr_    s     	--**((**)),,))--,,
I ''((.&"5"5"7"7MM/$67{{}'89 ( r   c                   [         R                  [         R                  [         R                  [         R                  [         R
                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                   1n["        R$                   H  n["        R$                  U   nUR'                  5       (       d  M-  UR)                  5       (       d  MD  UR+                  SU-  5        UR-                  5       S:X  d  Mn  UR+                  S5        M     U$ )zObtain requirements that upgrade supports in the destination.

If the result of the upgrade would have requirements not in this set,
the upgrade is disallowed.

Extensions should monkeypatch this to add their custom requirements.
rY  r   rZ  )r
   rw   rq   r]   rY   ra   rU   re   rn   rG  rt   r   rh   rk   rB  TREEMANIFEST_REQUIREMENTr   r   r   r   r   r[  r!   r\  s       r   supporteddestrequirementsrb    s    	,,**--,,**((--(())))''**--&&--''!I$ ''((.&"5"5"7"7MM/$67{{}'89 ( r   c                   [         R                  [         R                  [         R                  [         R                  [         R
                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  1n[        R                   H  n[        R                  U   nUR                  5       (       d  M-  UR!                  5       (       d  MD  UR#                  SU-  5        UR%                  5       S:X  d  Mn  UR#                  S5        M     U$ )aw  Obtain requirements that can be added to a repository during upgrade.

This is used to disallow proposed requirements from being added when
they weren't present before.

We use a list of allowed requirement additions instead of a list of known
bad additions because the whitelist approach is safer and will prevent
future, unknown requirements from accidentally being added.
rY  r   rZ  )r
   ra   rU   re   rk   rq   rn   rh   rG  rt   rw   r]   rY   r   r   r   r   r[  r!   r\  s       r   allowednewrequirementsrd  5  s     	**((----**((**)))),,--,,I ''((.&"5"5"7"7MM/$67{{}'89 ( r   c                D   U R                   n[        U R                   5        [        U 5      nX!-
  U-
  nU(       a=  [        S5      nSR	                  [        U5      5      n[        R                  " XT-  5      e[        U 5      nX-
  U-
  nU(       a=  [        S5      nSR	                  [        U5      5      n[        R                  " X-   5      e[        U 5      n	X-
  n
U
(       a=  [        S5      nSR	                  [        U
5      5      n
[        R                  " XZ-  5      eg )Ns;   cannot upgrade repository; requirement would be removed: %sr  s>   cannot upgrade repository; do not support adding requirement: sE   cannot upgrade repository; do not support destination requirement: %s)
r
   rM  r_  r   r   r   r   rI  rd  rb  )r   new_reqsold_reqssupport_removalno_remove_reqsrL  support_additionno_add_reqsrT  r]  unsupported_reqss              r   check_requirements_changesrm  V  s     H**+06O(?:NNOF>$:;kk#.//-d3%(88KOPjj!45kk!/**)$/I+
 !::f-=&>?kk#011 r   )E
__future__r   r   typingr   r   i18nr    r   r	   r
   r   r   utilsr   re   rk   rt   rw   RECLONES_REQUIREMENTSr   r@   r   r   r.   __annotations__r2   r4   rC   rS   rW   r[   r_   rc   rg   rj   rm   rp   rs   rv   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rC  rE  rM  rW  r_  rb  rd  rm  r   r   r   <module>ru     sh   # 
     	   ))))%%((	 ) 7" 7"t /1 + 0
$K $ E} E6 &  & !) ! !. !1 ! !, (  $ +  4 " ( "  " J +  2 ?0 ? ? (  " -' - - *   $ $ $P t 1!++-1!..0 
 )& )& )&X }  B,  
;  \  * |  2   & \  *#'T) )"U?} U?v	
%@6 FB2r   