+
    :1jM=                    n   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
 ^ RIHtHtHt ^ RIHt ^ RIHt ^ RIHtHtHt ^ RIHt ^ R	IHt ^R
IHt ^RIHt ^RI H!t! ^RI"H#t# ^RI$H%t%H&t& ^RI'H(t) ^RI*H+t+ ^RI,H-t- ^RI.H/t/H0t0 ^RI1H2t2 ^RI3H4t4 ^RI5H6t6 ^RI7H8t8H9t9 ]'       d   ^RI*H:t: ]Pv                  ! ]<4      t= ! R R]>4      t?R t@R tAR tBR tC ! R R4      tD]<R 8X  dG   ^ R!IEHEtE ]D! ]P                  4      tG]E! ]GP                  4       4       ]I! ]GP                  4       4       R# R# )"z,Tools interfacing with conda's history file.)annotationsN)literal_eval)EACCESEPERMEROFS)islice)
itemgetter)isdirisfilejoin)dedent)TYPE_CHECKING)__version__)dals)DEFAULTS_CHANNEL_NAME)context)ensure_text_type	open_utf8)groupby_to_dict)paths_equal)
PrefixData)CondaHistoryErrorNotWritableError)touch)dist_str_to_quad	MatchSpec)VersionOrderversion_relation_re)PathTypec                      ] tR t^)tRtR# )CondaHistoryWarning N)__name__
__module____qualname____firstlineno____static_attributes__r"       -lib/python3.14/site-packages/conda/history.pyr!   r!   )   s    r(   r!   c                   V P                  R P                  \        P                  ! R4      4      4       V P                  RP                  RP	                  R \
        P                   4       4      4      4       V P                  RP                  RP	                  \        \        P                  ! R4      ^4      4      4      4       R# )z==> {} <==
z%Y-%m-%d %H:%M:%Sz
# cmd: {}
 c              3  8   "   T F  p\        V4      x  K  	  R # 5iN)r   .0ss   & r)   	<genexpr>write_head.<locals>.<genexpr>/   s     *Q1+;A+>+>   z# conda version: {}
.N)
writeformattimestrftimer   sysargvr   CONDA_VERSIONsplit)fos   &r)   
write_headr>   -   s    HH^""4==1D#EFGHH]!!#((*Q*Q"QRSHH&&sxx}7J7J37OQR0S'TUr(   c                j    \         ;QJ d    R  V  4       F  '       g   K   R# 	  R# ! R  V  4       4      # )c              3  B   "   T F  qP                  R4      x  K  	  R# 5i)-N)rA   +)
startswithr.   s   & r)   r1   is_diff.<locals>.<genexpr>6   s     9A||J''s   TF)anycontents   &r)   is_diffrH   5   s+    3993393939999r(   c              #    "   / p/ pV  F  pVR ,          p\        V4      w  rVrxV\        8w  d   VRV R2,          pVP                  R4      '       d   WbVP                  4       &   K]  VP                  R4      '       g   Kv  WaVP                  4       &   K  	  \	        V4      \	        V4      ,          p	\        V	4       F  pRV RW%,           RW,           R2x  K  	  \        \	        V4      V	,
          4       F  pRV RW%,           2x  K  	  \        \	        V4      V	,
          4       F  pRV RW,           2x  K  	  R	# 5i)
   NNz ()rA   rB   r+   z  {z -> }N)r   r   rC   lowersetsorted)
diffaddedremovedr0   fnnameversion_channelchangeds
   &         r)   pretty_diffrZ   9   s!    EGrU$4R$8!q++G9A&G<<$+DJJL!\\#")$**,  %j3w<'Gw$tGM?$u{m2>>  s7|g-.$q(( /s5zG+,$q&& -s   AE(E?CEc                b    \        V 4      '       d   \        V 4      # \        \        V 4      4      # r-   )rH   rZ   iterrP   rF   s   &r)   pretty_contentr]   N   s'    w7##F7O$$r(   c                     ] tR t^Ut]P
                  ! R4      t]P
                  ! R4      t]P
                  ! R4      tR R lt	R t
R tR tR	 tR
 R ltR R lt]R 4       t]R 4       tR tR tR tRR ltR tR tR tRR ltRtR# )Historyz#\s*cmd:\s*(.+)z#\s*(\w+)\s*specs:\s*(.+)?z#\s*conda version:\s*(.+)c                   V ^8  d   QhRR/# )   prefixr   r"   )r6   s   "r)   __annotate__History.__annotate__Z   s     3 3x 3r(   c                	j    Wn         \        VR 4      V n        \        V P                  R4      V n        R# )z
conda-metahistoryN)rb   r   meta_dirpath)selfrb   s   &&r)   __init__History.__init__Z   s'    V\2	2	r(   c                	&    V P                  4        V # r-   )init_log_fileri   s   &r)   	__enter__History.__enter___   s    r(   c                	&    V P                  4        R # r-   )update)ri   exc_type	exc_value	tracebacks   &&&&r)   __exit__History.__exit__c   s    r(   c                	2    \        V P                  R 4       R# )TN)r   rh   rn   s   &r)   rm   History.init_log_filef   s    diir(   c                	\    \         P                  ! V P                  4      P                  ^ 8H  # )    )osstatrh   st_sizern   s   &r)   file_is_emptyHistory.file_is_emptyi   s     wwtyy!))Q..r(   c                   V ^8  d   QhRR/# )ra   returnNoner"   )r6   s   "r)   rc   rd   l   s       r(   c                     \        V P                  4       4      p\        T P                  4      pTP                  4        Uu0 uF  qDP                  4       kK  	  ppT P                  Y4       R#   \         d7   p\        P                  ! RT P
                   RT 2\        4        Rp?R# Rp?ii ; iu upi   \         dG   pTP                  \        \        \         39   d!   \#        T P
                  TP                  4      hh Rp?ii ; i)z:Update the history file (creating a new one if necessary).z	Error in z: N)rO   	get_stater   warningswarnrh   r!   r   rb   iter_recordsdist_strwrite_changesOSErrorerrnor   r   r   r   )ri   lastepd
prefix_reccurrs   &     r)   rr   History.updatel   s    	4>>+, DKK(B<>OO<MN<Mj'')<MDNt* % 	$))Bqc:<OP O 	ww65%00&tyy!''::		sG   A0 'B9 B4B9 0B1;+B,&B9 ,B11B9 9D
ADD
c                   V ^8  d   QhRR/# )ra   r   z%list[tuple[str, set[str], list[str]]]r"   )r6   s   "r)   rc   rd   }   s      < r(   c                   . p\        V P                  4      '       g   V# \        P                  ! R4      p\	        V P                  4      ;_uu_ 4       pVP                  4       P                  4       pRRR4       X F  pVP                  4       pV'       g   K  VP                  V4      pV'       d.   VP                  VP                  ^4      \        4       . 34       Kc  VP                  R4      '       d*   V'       d"   VR,          ^,          P                  V4       K  V'       g   K  VR,          ^,          P                  V4       K  	  V#   + '       g   i     L; i)zParse the history file.

Return a list of tuples(datetime strings, set of distributions/diffs, comments).

Comments appearing before the first section header (e.g. ``==> 2024-01-01 00:00:00 <==``)
in the history file will be ignored.
z==>\s*(.+?)\s*<==N#)r
   rh   recompiler   read
splitlinesstripmatchappendgrouprO   rC   add)ri   ressep_patflineslinems   &      r)   parseHistory.parse}   s     dii  J**12tyy!!QFFH'')E "D::<Dd#A

AGGAJr23%%#B
!!$'B
t$  
 "!s   EE	c                    . pV P                  R4       FW  p\        P                  ! V4      '       d(   V'       d    RP                  VR,          V.4      VR&   KF  VP	                  V4       KY  	  V# )z
Parse specifications string that use conda<4.5 syntax.

Examples
--------
  - "param >=1.5.1,<2.0'"
  - "python>=3.5.1,jupyter >=1.0.0,<2.0,matplotlib >=1.5.1,<2.0"
,r   )r<   r   r   r   r   )specs_stringspecsspecs   &  r)   _parse_old_format_specs_string&History._parse_old_format_specs_string   sa      &&s+D #((..5HHeBi%67b	T" , r(   c                `   / pV P                   P                  V4      pV'       dG   VP                  ^4      P                  4       pV^ ,          P	                  R4      '       d   RV^ &   WBR&   V P
                  P                  V4      pV'       d   VP                  ^4      VR&   V P                  P                  V4      pV'       d   VP                  4       w  rVT;'       g    RpWRR&   VP                  R4      '       d   \        V4      pMRV9  d   \        P                  V4      pX Uu. uF'  q'       g   K  VP	                  R4      '       d   K%  VNK)  	  ppV'       d   VR9   d   V;VR&   VR	&   V# V'       d   VR9   d   V;VR
&   VR	&   V# V'       d   VR9   d   V;VR&   VR	&   V# u upi )a  
Parse comment lines in the history file.

These lines can be of command type or action type.

Examples
--------
  - "# cmd: /scratch/mc3/bin/conda install -c conda-forge param>=1.5.1,<2.0"
  - "# install specs: python>=3.5.1,jupyter >=1.0.0,<2.0,matplotlib >=1.5.1,<2.0"
condacmdconda_version action[@update_specsr   remove_specsneutered_specs)rr   installcreate)remove	uninstall)neutered)com_patr   r   r<   endswithconda_v_patspec_patgroupsrC   r   r_   r   )	clsr   itemr   r:   r   r   r   r   s	   &&       r)   _parse_comment_lineHistory._parse_comment_line   s    KKd#771:##%DAw((!QKOO!!$'$%GGAJD!LLt$#$88: F'--2L#N&&s++$\2L(>>|L&+OedtTDMM#<NTTeEO#BB7<<^$tG}  6%<<7<<^$tG}  6]29>>%&g Ps   +	F+9F+F+c                   . pV P                  4        F  w  r#pRV/pV F%  pV P                  V4      pVP                  V4       K'  	  RV9   d   VP                  V4       \	        \        ^ 4      V4      pVP                  RR4      VR&   VP                  RR4      VR&   K  	  \        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      p	V	'       Ed/   \        P                  '       Eg   \        V	\        R7      R,          p
R	P                  \        V
P                  R	4      ^4      4      pR	P                  \        \        P                  ! R	4      ^4      4      p\        V4      \        V4      8  d   \!        R
4      RV P"                  R\        RV/,          p\%        V P"                  \        P&                  4      '       g,   V\)        R4      R\        P&                  RV/,          ,          pV\)        R4      ,          pV# )zReturn a list of user requested items.

Each item is a dict with the following keys:
'date': the date and time running the command
'cmd': a list of argv of the actual command which was run
'action': install/remove/update
'specs': the specs being used
dater   rA   unlink_distsrB   
link_distsc              3  F   "   T F  pR V9   g   K  VR ,          x  K  	  R# 5i)r   Nr"   )r/   xs   & r)   r1   ,History.get_user_requests.<locals>.<genexpr>   s%      ,
(+1!/CAos   	!!)keyr4   a  
                This environment has previously been operated on by a conda version that's newer
                than the conda currently being used. A newer version of conda is required.
                  target environment location: %(target_prefix)s
                  current conda version: %(conda_version)s
                  minimum conda version: %(minimum_version)s
                target_prefixr   minimum_versionz
                    Update conda and try again.
                        $ conda install -p "%(base_prefix)s" "conda>=%(minimum_version)s"
                    base_prefixz
                To work around this restriction, one can also set the config parameter
                'allow_conda_downgrades' to False at their own risk.
                r"   r   )r   r   rr   r   groupbyr   gettupler   allow_conda_downgradesrP   r   r   r   r<   r;   r   rb   r   root_prefixr   )ri   r   dtunused_contcommentsr   r   comment_itemsdistsconda_versions_from_historyminimum_conda_versionminimum_major_minorcurrent_major_minormessages   &             r)   get_user_requestsHistory.get_user_requests   s    )-%BXB<D  $ 8 8 >M* ! }

4 JqM;7E#(99S"#5D !&3!3D *6 ',e ,
(+,
ee ,
(+,
 '
# '&w/M/M/M$*+%%! #&((62G2M2Mc2RTU+V"W"%((6-2E2Ec2JA+N"O/0<@S3TT $T[[#]%': #4;;0C0CDDv  &w':':)+>  G 6  
r(   c                	X   / pV P                  4        F  pR  VP                  RR	4       4       pV F  pVP                  VP                  R4       K!  	  R VP                  RR	4       4       pVP	                  R V 4       4       R VP                  RR	4       4       pVP	                  R V 4       4       K  	  \        V P                  4      P                  4        Uu0 uF  qwP                  kK  	  ppVP                  4        U	Uu/ uF  w  rW9   g   K  WbK  	  upp	# u upi u upp	i )
c              3  8   "   T F  p\        V4      x  K  	  R # 5ir-   r   r/   r   s   & r)   r1   2History.get_requested_specs_map.<locals>.<genexpr>$       X8WIdOO8Wr3   r   Nc              3  8   "   T F  p\        V4      x  K  	  R # 5ir-   r   r   s   & r)   r1   r   '  r   r3   r   c              3  <   "   T F  qP                   V3x  K  	  R # 5ir-   rU   r.   s   & r)   r1   r   (  s     >AVVQK   c              3  8   "   T F  p\        V4      x  K  	  R # 5ir-   r   r   s   & r)   r1   r   *  s      ,MD	$,Mr3   r   c              3  <   "   T F  qP                   V3x  K  	  R # 5ir-   r   r.   s   & r)   r1   r   -  s     @AVVQKr   r"   )	r   r   poprU   rr   r   rb   r   items)
ri   spec_maprequestr   r   r   r   rW   prefix_recsrU   s
   &         r)   get_requested_specs_mapHistory.get_requested_specs_map   s   --/GXNTV8WXL$TYY- %XNTV8WXLOO>>>,3KK8H",MN OO@@@ 0 (2$++'>'K'K'MN'M!vv'MN-5^^-=U-=ztAT

-=UU OUs   D!
D&D&c                   . p\        4       pV P                  4        F  w  r4p\        V4      '       g   TpMwV Fq  pVP                  R4      '       d   VP	                  VR,          4       K4  VP                  R4      '       d   VP                  VR,          4       Ke  \        RV 24      h	  VP                  W2P                  4       34       K  	  V# )z@Return a list of tuples(datetime strings, set of distributions).rA   rJ   rB   zDid not expect: )	rO   r   rH   rC   discardr   r   r   copy)ri   r   curr   cont
unused_comr0   s   &      r)   construct_statesHistory.construct_states5  s    e$(JJL Bj4==A||C((AbE*c**"/2B1#0FGG  JJHHJ'( %1 
r(   c                l    V P                  4       pV'       g   \        4       # \        V!  w  r4WA,          # )zReturn the state, i.e. the set of distributions, for a given revision.

Defaults to latest (which is the same as the current state when
the log file is up-to-date).

Returns a list of dist_strs.
)r   rO   zip)ri   revstatestimespkgss   &&   r)   r   History.get_stateG  s/     &&(5L6lyr(   c                	    \        V P                  4       4       FF  w  pw  r#p\        R W!3,          4       \        V4       F  p\        RV 24       K  	  \        4        KH  	  R# )z%s  (rev %d)z    N)	enumerater   printr]   )ri   ir   rG   r   r   s   &     r)   	print_logHistory.print_logU  sS    .7

.E*A*z.D9,-&w/TFm$ 0G	 /Fr(   c                	   . p\        V P                  4       4       EF:  w  pw  r4pR VRVR. R. R. R. /p/ p/ p\        V4      '       Ed   V Fr  p	\        V	R,          4      w  rrV	P	                  R4      '       d   WV3WzP                  4       &   KE  V	P	                  R4      '       g   K^  WV3WP                  4       &   Kt  	  \        V4      \        V4      ,          p\        V4       F  p
W,          pWz,          pR	RP                  V
3V,           4      R
RP                  V
3V,           4      /pVV8  d   VR,          P                  V4       Kh  VR,          P                  V4       K  	  \        \        V4      V,
          4       F8  p
VR,          P                  RP                  V
3W,          ,           4      4       K:  	  \        \        V4      V,
          4       F8  p
VR,          P                  RP                  V
3Wz,          ,           4      4       K:  	  M*\        V4       F  p	VR,          P                  V	4       K  	  VP                  V4       EK=  	  V# )r   r   r   r   upgrade	downgraderJ   rB   rA   oldnew)
r  r   rH   r   rC   rN   rO   rP   r   r   )ri   resultr  r   rG   r   eventrR   rS   pkgrU   rV   buildrX   rY   r  r  detailss   &                 r)   
object_logHistory.object_log\  s	   .7

.E*A*z q2"2RE EGw"C4DSW4M1D5~~c**/6w.Gjjl+,,180I

- # e*s7|3"7OD!-C+Csxx#6sxx#6G
 Syi(//8k*11': , #3w<'#9:D(O**388TGgm4K+LM ; #3u:#78D)$++CHHdWu{5J,KL 9 "'?C)$++C0 +MM% W /FX r(   c                	   \        V P                  4      '       g!   \        P                  ! V P                  4       \	        V P
                  R RR7      ;_uu_ 4       p\        V4       \        W,
          4       F  pVP                  RV R24       K  	  \        W!,
          4       F  pVP                  RV R24       K  	  RRR4       R#   + '       g   i     R# ; i)autf-8modeencodingrA   
rB   N)	r	   rg   r|   makedirsopenrh   r>   rP   r5   )ri   
last_statecurrent_stater=   rT   s   &&&  r)   r   History.write_changes  s    T]]##KK&$))#88BrNZ781RD$ 9]781RD$ 9	 9888s   A&CC	c                	H   V Uu. uF  p\        \        V4      4      NK  	  ppV Uu. uF  p\        \        V4      4      NK  	  ppV Uu. uF  p\        \        V4      4      NK  	  pp\        W!V34      '       d   \        V P                  R RR7      ;_uu_ 4       pV'       d   VP                  RV R24       V'       d   VP                  RV R24       V'       d   VP                  RV R24       RRR4       R# R# u upi u upi u upi   + '       g   i     R# ; i)r  r  r  z# remove specs: r  z# update specs: z# neutered specs: N)strr   rE   r  rh   r5   )ri   r   r   r   r0   fhs   &&&&  r)   write_specsHistory.write_specs  s    3?@<aIaL)<@3?@<aIaL)<@5CD^#il+^DN;<<diicG<<HH/~R@AHH/~R@A!HH1.1ADE =< = A@D<<<s(   DDD%DD DD!	)rg   rh   rb   N)r   )r"   r"   r"   )r#   r$   r%   r&   r   r   r   r   r   rj   ro   rv   rm   r   rr   r   staticmethodr   classmethodr   r   r   r   r   r	  r  r   r&  r'   r"   r(   r)   r_   r_   U   s    jj+,Gzz78H**9:K3
/"6  & + +ZDLV*$.`%F Fr(   r_   __main__)pprint)K__doc__
__future__r   loggingr|   r   r9   r7   r   astr   r   r   r   r   	itertoolsr   operatorr   os.pathr	   r
   r   textwrapr   typingr   r   r   r;   
auxlib.ishr   base.constantsr   base.contextr   common.compatr   r   common.iteratorsr   r   common.pathr   core.prefix_datar   
exceptionsr   r   gateways.disk.updater   models.distr   models.match_specr   models.versionr   r   r   	getLoggerr#   logWarningr!   r>   rH   rZ   r]   r_   r+  rb   hr   r  r   r"   r(   r)   <module>rE     s    3 "  	 	 
    & &   ' '    *  1 ! 6 8 $ ( ; ' ) ( =%!	' 	:'*%LF LF^
 z 	

A
1 !	!
#
#
%& r(   