
    q&f$                         d dl Z ddlmZmZmZ ddlmZ ej                  rddlmZ	 nddlm
Z	 e	j                  Ze	j                  Ze	j                  Zd ZddZd	 Zd
 Zd Zd Zy)    N   )encodingpycompatutil)resourceutil)
scmwindows)scmposixc                     t        j                  |       t        j                  j	                        rBt        j                  j
                  t        fdt        j                        D              S gS )z@path could be a file or a directory. return a list of file pathsc              3   Z   K   | ]"  \  }}|j                  d       s |       $ yw)   .rcN)endswith).0fkjoinps      2/usr/lib/python3/dist-packages/mercurial/rcutil.py	<genexpr>z _expandrcpath.<locals>.<genexpr>"   s+      
1aajj6HDAJ
s   ++)r   
expandpathospathisdirr   sortedlistdir)r   r   r   s    @@r   _expandrcpathr      sY    A	ww}}Qww|| 
#'<<?
 
 	
 3J    c                     | t         j                  } g d}g }|D ]&  \  }}}|| vr|j                  ||| |   d|z  f       ( |S )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   
envrcitemsr)   (   sj     {I
 F(1 M$*#w
CL&7:JKLM Mr   c                      t        j                  d      } t        |       D cg c]-  }t        j                  d|      r|j	                  d      rd|f/ c}S c c}w )z#return rc resource IDs in defaultrcs   mercurial.defaultrcr   )r   contentsr   is_resourcer   )rsrcsrs     r   default_rc_resourcesr/   ?   s[    !!"89E ##$:A>JJv 
 #  s   2Ac                     dt               f} dt        j                  v r^| g}t        j                  d   j                  t        j
                        D ]&  }|s|j                  d t        |      D               ( |S t               D cg c]  }d|f }}d }|j                   |t                            |j                  |        |j                   |t                            |S c c}w )aR  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 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   HGRCPATHc              3   $   K   | ]  }d |f 
 yw)   pathN )r   r   s     r   r   zrccomponents.<locals>.<genexpr>`   s      H!'1 Hs   s   resourcec                 j    | D cg c]#  }dt         j                  j                  |      f% c}S c c}w )Nr2   )r   r   normpath)pathsr   s     r   <lambda>zrccomponents.<locals>.<lambda>d   s0    49#
/0Wbgg&&q)*#
  #
s   (0)r)   r   r!   splitr   	ospathsepextendr   r/   systemrcpathr"   
userrcpath)envrc_rccomponentsr   r.   	normpathss        r   rccomponentsr@   J   s     z|$Eh&&& !!+.44X5G5GH 	IA   H}Q7G HH	I  4H3IJa+q)JJ
	 	Y|~67U#Yz|45 Ks   	C*c                      dddS )zureturn a dict of default environment variables and their values,
    intended to be set before starting a pager.
    s   FRXs   -c)s   LESSs   LVr3   r3   r   r   defaultpagerenvrB   m   s     E**r   c                  &    dt         j                  vS )z5True if repositories `.hg/hgrc` config should be reads   HGRCSKIPREPO)r   r!   r3   r   r   use_repo_hgrcrD   t   s    ("2"222r   )N)r    r   r   r   utilsr   	iswindowsr   scmplatformr	   fallbackpagerr;   r<   r   r)   r/   r@   rB   rD   r3   r   r   <module>rJ      sh    
   +)))''##
. F+3r   