a
    &0É_K  ã                   @   sœ   d dl mZ d dlZddlmZmZmZ ddlmZ ej	rHddlm
Z nddlmZ ejZejZejZdd	„ Zdd
d„Zdd„ Zdd„ Zdd„ Zdd„ ZdS )é    )Úabsolute_importNé   )ÚencodingÚpycompatÚutil)Úresourceutil)Ú
scmwindows)Úscmposixc                    sB   t  | ¡‰tj ˆ¡r<tjj‰ t‡ ‡fdd„t  ˆ¡D ƒƒS ˆgS )z@path could be a file or a directory. return a list of file pathsc                 3   s&   | ]\}}|  d ¡rˆ ˆ|ƒV  qdS )ó   .rcN)Úendswith)Ú.0ÚfÚk©ÚjoinÚp© ú2/usr/lib/python3/dist-packages/mercurial/rcutil.pyÚ	<genexpr>#   s   z _expandrcpath.<locals>.<genexpr>)r   Z
expandpathÚosÚpathÚisdirr   ÚsortedÚlistdir)r   r   r   r   Ú_expandrcpath   s    
ÿr   c                 C   sR   | du rt j} g d¢}g }|D ].\}}}|| vr2q| ||| | d| f¡ q|S )zöReturn [(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.
    N))s   EDITORó   uió   editor)s   VISUALr   r   )s   PAGERó   pagerr   s   $%s)r   ÚenvironÚappend)ÚenvZ	checklistÚresultZenvnameZsectionZ
confignamer   r   r   Ú
envrcitems)   s    r"   c                  C   s   t  d¡} dd„ t| ƒD ƒS )z#return rc resource IDs in defaultrcó   mercurial.defaultrcc                 S   s*   g | ]"}t  d |¡r| d¡rd |f‘qS )r#   r
   )r   Úis_resourcer   ©r   Úrr   r   r   Ú
<listcomp>C   s   
ýz(default_rc_resources.<locals>.<listcomp>)r   Úcontentsr   )Zrsrcsr   r   r   Údefault_rc_resources@   s    
þr)   c                  C   s˜   dt ƒ f} dtjv rR| g}tjd  tj¡D ]"}|s6q,| dd„ t|ƒD ƒ¡ q,nBdd„ tƒ D ƒ}dd„ }| |t	ƒ ƒ¡ | 
| ¡ | |tƒ ƒ¡ |S )	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                 s   s   | ]}d |fV  qdS )ó   pathNr   ©r   r   r   r   r   r   a   ó    zrccomponents.<locals>.<genexpr>c                 S   s   g | ]}d |f‘qS )s   resourcer   r%   r   r   r   r'   c   r,   z rccomponents.<locals>.<listcomp>c                 S   s   dd„ | D ƒS )Nc                 S   s   g | ]}d t j |¡f‘qS )r*   )r   r   Únormpathr+   r   r   r   r'   e   s   z2rccomponents.<locals>.<lambda>.<locals>.<listcomp>r   )Úpathsr   r   r   Ú<lambda>e   s   ÿzrccomponents.<locals>.<lambda>)r"   r   r   Úsplitr   Z	ospathsepÚextendr   r)   Úsystemrcpathr   Ú
userrcpath)ZenvrcZ_rccomponentsr   Z	normpathsr   r   r   ÚrccomponentsK   s    


r4   c                   C   s
   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   LVr   r   r   r   r   Údefaultpagerenvn   s    r5   c                   C   s
   dt jvS )z5True if repositories `.hg/hgrc` config should be reads   HGRCSKIPREPO)r   r   r   r   r   r   Úuse_repo_hgrcu   s    r6   )N)Z
__future__r   r   Ú r   r   r   Zutilsr   Z	iswindowsr   Zscmplatformr	   Zfallbackpagerr2   r3   r   r"   r)   r4   r5   r6   r   r   r   r   Ú<module>   s   
#