
    si!                        S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  \	(       a
  SS	KJrJrJr  SS
 jr\" SSSS9SSS jj5       r\" SSSS9SS j5       rSS jrg)zCLI implementation for `conda rename`.

Renames an existing environment by cloning it and then removing the original environment.
    )annotationsN)partial)Path)TYPE_CHECKING)
deprecated)CondaEnvException)ArgumentParser	Namespace_SubParsersActionc                    SSK Jn  SSKJnJn  SnU" SU S35      nU" S5      nU R
                  "  SUUUS	.UD6nU" U5        UR                  S
SS9  U" U5        UR                  SS9  U$ )N   )dals   )add_output_and_prompt_optionsadd_parser_prefixzRename an existing environment.z	
        z

        This command renames a conda environment via its name (-n/--name) or
        its prefix (-p/--prefix).

        The base environment and the currently-active environment cannot be renamed.
        z
        Examples::

            conda rename -n test123 test321

            conda rename --name test123 test321

            conda rename -p path/to/test123 test321

            conda rename --prefix path/to/test123 test321

        )helpdescriptionepilogdestinationz#New name for the conda environment.)r   zconda.cli.main_rename.execute)func)rename)
auxlib.ishr   helpersr   r   
add_parseradd_argumentset_defaults)	sub_parserskwargsr   r   r   summaryr   r   ps	            5lib/python3.13/site-packages/conda/cli/main_rename.pyconfigure_parserr"      s    !I/G			 			K 	F 				
 	A aNN='LNM!!$NN7N8H    z25.9z26.3zUse PrefixData.validate_path())addendumc                    SSK Jn  U" [        U 5      R                  5      R	                  5       (       a  [        SU  S3U5      eg)zBEnsure that the new prefix does not contain protected directories.r   
PrefixDatazThe specified prefix 'aB  ' appears to be a top level directory within an existing conda environment (i.e., {history_file} exists). Creating an environment in this location has the potential to irreversibly corrupt your conda installation and/or other conda environments, please choose a different location for your new conda environment. Aborting.N)conda.core.prefix_datar'   r   parentis_environmentr   )prefixjsonr'   s      r!   check_protected_dirsr-   G   sM     2$v,%%&5577$VH -/ / 
 	
 8r#   z:Use PrefixData.validate_path(), PrefixData.validate_name()c                 N   SSK Jn   SSKJn  [	        U R
                  5      nU" U5        UR                  U R                  5      (       a  [        S5      eU R                  (       a+  UR                  U R                  5      (       a  [        S5      e[        U5        [        U5      $ )z
Ensure that we are receiving at least one valid value for the environment
to be renamed and that the "base" environment is not being renamed
r   contextr   )validate_prefix_exists(The 'base' environment cannot be renamed$Cannot rename the active environment)base.contextr0   installr1   r   target_prefixsamefileroot_prefixr   active_prefixr-   str)r0   r1   r+   s      r!   validate_srcr;   X   s~     '/'''(F6"w**++ JKK1F1F!G!G FGGV$v;r#   c                  ^ ^^^	^
^^ SSK Jm  SSKJm  SSKJm
  SSKJn  SSKJ	m  SSK
Jn  UR                  5       nUR                  5         UR                  5       (       a  [        S5      eTR                   (       a5  UR"                  R%                  TR                   5      (       a  [        S	5      eXB" TR&                  5      :X  a  [        S
5      e[)        UR"                  5      m[*        R,                  T R.                  ;   a"  U" T R.                  5      nUR1                  SS9  OUR3                  T R.                  5      n[)        UR"                  5      m	T R4                  (       d.  UR7                  5       (       a  [        SUR"                   S35      eSUU UU	U
UU4S jjnT R4                  (       a"  U" T	T R8                  S9   U" 5         SSS5        gU" 5         g! , (       d  f       g= f)z:Executes the command for renaming an existing environment.r   )DRY_RUN_PREFIXr/   )r5   r&   )rm_rf)rename_contextr2   r3   zMCannot rename an environment if it is configured as `default_activation_env`.T)expand_pathzThe environment 'z&' already exists. Override with --yes.c            
     :  > [        TR                  TTTR                  TR                  S9[        TT5      4n U  H]  nTR                  (       aB  [        T SUR                  R                   SSR                  UR                  5       35        MV  U" 5         M_     g )N)quietr,    ,)
r   clonerB   r,   dry_runprintr   __name__joinargs)	actionsr   r=   rJ   r0   r   r5   r>   sources	     r!   clone_and_remove!execute.<locals>.clone_and_remove   s    mm\\ E6"	(
 D||($))*<*<)=Qsxx		?R>STU	 r#   )rF   Nr   )returnNone)base.constantsr=   r4   r0   clir5   core.prefix_datar'   gateways.disk.deleter>   gateways.disk.updater?   from_contextassert_environmentis_baser   r9   prefix_pathr7   default_activation_prefixr:   ossepr   validate_path	from_nameyesexistsrF   )rJ   parserr'   r?   source_prefix_datadest_prefix_datarM   r=   r0   r   r5   r>   rL   s   `      @@@@@@r!   executerd   r   s   /&-,5 $002))+!!## JKK!3!?!?!H!H" "   FGGZ(I(IJJ[
 	
 #//0F 
vv!!!%d&6&67&&4&8%//0@0@A&223K88(//11 0 < <==cd
 	
 & xxK> ?  		 ?> s   G
G-)r   r   rO   r	   )F)r+   z
str | Pathr,   boolrO   rP   )rO   r:   )rJ   r
   ra   r	   rO   int)__doc__
__future__r   r[   	functoolsr   pathlibr   typingr   conda.deprecationsr   conda.exceptionsr   argparser	   r
   r   r"   r-   r;   rd    r#   r!   <module>rp      sv   
 # 	     ) .EE.b FF%EF
 G
  

I

*>r#   