
    6hg                       S SK Jr  S SKrS SKJrJrJr  SSKJr	J
r
JrJrJrJrJr  SSKJr  \R&                  (       a  SSKJr  OSSKJr  \R.                  r\R0                  r\R2                  r\	R4                  r\	R6                  r\	R8                  r\	R:                  rSS	 jrSSS
 jjrSS jr SSS jjr!SS jr"SS jr#SS jr$SS jr%SS jr&g)    )annotationsN)DictListOptional   )configurationencoding	localrepopycompatrequirementsutilvfs)resourceutil)
scmwindows)scmposixc                  ^^ [         R                  " U 5      m[        R                  R	                  T5      (       aD  [        R                  R
                  m[        UU4S j[         R                  " T5       5       5      $ T/$ )z@path could be a file or a directory. return a list of file pathsc              3  j   >#    U  H(  u  pUR                  S 5      (       d  M  T" TU5      v   M*     g7f)   .rcN)endswith).0fkjoinps      @/usr/lib/python3/dist-packages/mercurial/configuration/rcutil.py	<genexpr> _expandrcpath.<locals>.<genexpr>2   s+      
#241ajj6HJDAJJ?s   33)r   
expandpathospathisdirr   sortedlistdir)r    r   r   s    @@r   _expandrcpathr$   -   s\    A	ww}}Qww|| 
#'<<?
 
 	
 3J    c                    U c  [         R                  n / SQn/ nU H&  u  p4nX0;  a  M  UR                  XEX   SU-  45        M(     U$ )zReturn [(section, name, value, source)] config items.

The config items are extracted from environment variables specified by env,
used to override systemrc, but not userrc.

If env is not provided, encoding.environ will be used.
))s   EDITOR   ui   editor)s   VISUALr'   r(   )s   PAGER   pagerr)   s   $%s)r	   environappend)env	checklistresultenvnamesection
confignames         r   
envrcitemsr2   8   s[     {I
 F(1$*wCL&7:JKL )2 Mr%   c                     [         R                  " S5      n [        U 5       Vs/ s H=  n[         R                  " SU5      (       d  M!  UR	                  S5      (       d  M9  SU4PM?     sn$ s  snf )z#return rc resource IDs in defaultrcs   mercurial.defaultrcr   )r   contentsr"   is_resourcer   )rsrcsrs     r   default_rc_resourcesr8   O   sj    !!"89E A##$:A> 	$ JJv 	$	#  s    A+A+ A+c                   [         R                  S[        5       4n/ nUR                  nS[        R
                  ;   a|  U (       au  U" U5        [        R
                  S   R                  [        R                  5       H7  nU(       d  M  [        U5       H  nU" [         R                  SU45        M     M9     U$ [        5        H  nU" [         R                  SU45        M     [        5        H9  nU" [         R                  S[        R                  R!                  U5      45        M;     U" U5        [#        5        H9  nU" [         R$                  S[        R                  R!                  U5      45        M;     U$ )a`  return an ordered [(type, obj)] about where to load configs.

respect $HGRCPATH. if $HGRCPATH is empty, only .hg/hgrc of current repo is
used. if $HGRCPATH is not set, the platform default will be used. If
`use_hgrcpath` is False, it is never used.

if a directory is provided, *.rc files under it will be used.

type could be either 'path', 'items' or 'resource'. If type is 'path',
obj is a string, and is the config file path. if type is 'items', obj is a
list of (section, name, value, source) that should fill the config directly.
If type is 'resource', obj is a tuple of (package name, resource name).
s   itemss   HGRCPATH   paths   resource)conf_modLEVEL_ENV_OVERWRITEr2   r+   r	   r*   splitr   	ospathsepr$   r8   LEVEL_BUNDLED_RESOURCEsystemrcpathLEVEL_GLOBALr   r    normpath
userrcpath
LEVEL_USER)use_hgrcpathenvrc_rccomponentscompr   r7   s         r   rccomponentsrI   Z   s-    ))8Z\BEMDh&&&< 	U!!+.44X5G5GHA"1%h22GQ?@ & I  &'A(11;BC ( A(''"''2B2B12EFG  UA(%%w0@0@0CDE r%   c                     [        [        R                  R                  U SS5      S5       n[	        UR                  5       R                  5       5      n[        R                  U;   a  [        R                  U;   d  / sSSS5        $ [        R                  " [        R                  R                  U S5      5      n[        R                  " X25      nUR                  S5      /sSSS5        $ ! , (       d  f       / $ = f! [         a     / $ f = f)zif the current repository is shared one, this tries to read
.hg/hgrc of shared source if we are in share-safe mode

This should be called before reading .hg/hgrc or the main repo
as that overrides config set in shared source   .hgs   requiresrbN   hgrc)openr   r    r   setread
splitlinesrequirementsmodSHARESAFE_REQUIREMENTSHARED_REQUIREMENTr   r
   _getsharedvfsOSError)r    fpr   hgvfs	sharedvfss        r   _shared_source_componentrZ      s    "'',,tV[94@Brwwy3356L55E#66,F A@ GGBGGLLv67E!//DINN7+, A@@ I  Is<   +C? AC->	C? AC-#	C? -
C<7C? <C? ?
DDc           	     X   / nUR                   n[        U 5       H  nU" [        R                  SU45        M     U" [        R                  S[
        R                  R                  U SS5      45        U" [        R                  S[
        R                  R                  U SS5      45        U$ )z7return the list of config file to read for a repositoryr:   rK   rM   s   hgrc-not-shared)	r+   rZ   r;   LEVEL_SHAREDLEVEL_LOCALr   r    r   LEVEL_NON_SHARED)	repo_path
componentsrH   r   s       r   repo_componentsra      s    JD%i0h##Wa01 1  GGLLFG4	
 	%%GGLLF,>?	
 r%   c                t    / nUR                  [        SS95        U b  UR                  [        U 5      5        U$ )NF)rE   )extendrI   ra   )r_   r`   s     r   all_rc_componentsrd      s9    Jl67/)45r%   c                     SSS.$ )zmreturn a dict of default environment variables and their values,
intended to be set before starting a pager.
s   FRXs   -c)s   LESSs   LV rf   r%   r   defaultpagerenvrg      s     E**r%   c                 (    S[         R                  ;  $ )z5True if repositories `.hg/hgrc` config should be reads   HGRCSKIPREPO)r	   r*   rf   r%   r   use_repo_hgrcri      s    ("2"222r%   )r    bytesreturnzList[FileRCT])N)r,   zOptional[Dict[bytes, bytes]]rk   zList[ConfigItemT])rk   zList[ResourceIDT])T)rk   List[ComponentT])r_   rj   rk   rl   )r_   zOptional[bytes])rk   zDict[bytes, bytes])rk   bool)'
__future__r   r   typingr   r   r    r   r;   r	   r
   r   r   rR   r   r   utilsr   	iswindowsr   scmplatformr   fallbackpagerr@   rC   
ComponentTConfigItemTFileRCTResourceIDTr$   r2   r8   rI   rZ   ra   rd   rg   ri   rf   r%   r   <module>ry      s    # 	    !,*))''##
  
""


"".%P,.+3r%   