
    q&fM                        d dl Z d dlZdZddddddddZ	 d	d
lmZ ej                  Zdej                  v rdZde j                  v re j                  d   j                  d      Zd Zd	dd	dddZdddddZd Zd Zd ZddZy# e$ r Y cw xY w)    N   allow)cextN)r   pure)cffiN)r   r   )Nr   )   cr      cffis
   cffi-allows   pys   rust+cs   rust+c-allow   )__modulepolicy____pypy__r   HGMODULEPOLICYzutf-8c                     i }t        | t               ||gd      }	 t        ||      x||<   }t        |dd        ||   S # t        $ r t	        d|z        w xY w)Nr	   )levelzcannot import name %s__doc__)
__import__globalsgetattrAttributeErrorImportError)pkgnamemodname
fakelocalspkgmods        2/usr/lib/python3/dist-packages/mercurial/policy.py_importfromr   :   ss    J
WgigYa
HC=$+C$99
7c CD!g	  =1G;<<=s   A   A         ))r   base85)r   bdiff)r   mpatch)r   osutilr   parsersr#   )r   r   )r   
charencode)r   r$   ))r   r%   )r   r   )r   r%   )r   r$   c                 z    t         j                  | |f      }t        |dd       }||k7  rt        d| |||fz        y )Nversionz=cannot import module %s.%s (expected version: %d, actual: %r))_cextversionsgetr   r   )r   r   r   expectedactuals        r   	_checkmodr,   Y   sU      '7!34HS)T*F1623
 	
     c                 d   	 t         t           \  }}|s|sJ |r>t        j                  || f|| f      \  }}	 t        ||      }||k(  rt        |||       |S t        j                  || f|| f      \  }}t        ||      S # t        $ r t        dt        z        w xY w# t        $ r |s Y Vw xY w)z7Import module according to policy and check API versionzinvalid HGMODULEPOLICY %r)_packageprefspolicyKeyErrorr   _modredirectsr)   r   r,   )r   verpkgpurepkgpnmnr   s         r   	importmodr7   d   s    @'/ W""FG#4vw6GHB	b"%CV|"b#&J 1GW3EFFBr2  @5>??@  	 	s   B B  B B/.B/c                  ,    t         j                  d      S )z;Assuming the policy is a Rust one, tell if it's permissive.s   -allow)r0   endswith r-   r   _isrustpermissiver;   y   s    ??9%%r-   c                     t         j                  d      s|S 	 t        d|       }||S 	 t        ||      S # t        $ r t	               r|cY S  w xY w# t        $ r t	               r|cY S t        d|z        w xY w)a  Import Rust module according to policy and availability.

    If policy isn't a Rust one, this returns `default`.

    If either the module or its member is not available, this returns `default`
    if policy is permissive and raises `ImportError` if not.
    s   rustrustextzCannot import name %s)r0   
startswithr   r   r;   r   r   )r   memberdefaultr   s       r   
importrustrA   ~   s     W%)W-
 ~
<sF##  N  <N1F:;;<s    6 A AAA8)A8)NN)ossysr0   r/    r
   modulepolicyr   builtin_module_namesenvironencoder   r(   r2   r,   r7   r;   rA   r:   r-   r   <module>rI      s    
 
  
 #%
	"**F )))F rzz!ZZ()009F
  0*2,	
*&
<g  		s   B BB