
aQc           @   sY   d  d l  m Z d  d l Z d  d l Z d  d l Z d a d   Z d   Z d   Z	 d S(   i(   t   _Nc   	      C   s  i d d 6d d 6d d 6} d } g  } g  } xK|  D]C} d | k r t  s^ t j d  a  n  t  j d |  } | j d	 d  } n  | j   } | s q4 n  | j d
  r | d j   } y | | } Wq4 t k
 r | j	 t
 d  |  q4 Xq4 n  | | } xb | j   D]T \ } } | j |  r7| } Pq| j | d  r| | t |  d } PqqW| j	 |  q4 W| | f S(   s   parse lines (iterable) of .hgignore text, returning a tuple of
    (patterns, parse errors). These patterns should be given to compile()
    to be validated and converted into a match function.s   relre:t   ret   regexps   relglob:t   globt   #s   ((^|[^\\])(\\\\)*)#.*s   \1s   \#s   syntax:i   s   ignoring invalid syntax '%s't   :i   (   t
   _commentreR   t   compilet   subt   replacet   rstript
   startswitht   stript   KeyErrort   appendR    t	   iteritemst   len(	   t   linest   syntaxest   syntaxt   patternst   warningst   linet   st   patt   rels(    (    s4   /sys/lib/python2.7/site-packages/mercurial/ignore.pyt
   ignorepats   s<    
c   	      C   s   i  } x | D] } | | k r% q n  y_ g  | | <t  |  } t |  \ | | <} | j   x" | D] } | d | | f  qe WWq t k
 r } | | d k r | t d  | | j f  q q Xq Wg  | D]" } | | k r | | | f ^ q S(   s:   return a dict mapping ignore-file-name to list-of-patternss   %s: %s
i    s)   skipping unreadable ignore file '%s': %s
(   t   openR   t   closet   IOErrorR    t   strerror(	   t   roott   filest   warnt   patst   ft   fpR   t   warningt   inst(    (    s4   /sys/lib/python2.7/site-packages/mercurial/ignore.pyt   readpats7   s     

c   	      C   s   t  |  | |  } g  } x! | D] \ } } | j |  q W| sI t j Sy t j |  d g  |  } Wn{ t j k
 r xh | D]\ \ } } y t j |  d g  |  Wq t j k
 r } t j d | | d f   q Xq Wn X| S(   s  return matcher covering patterns in 'files'.

    the files parsed for patterns include:
    .hgignore in the repository root
    any additional files specified in the [ui] section of ~/.hgrc

    trailing white space is dropped.
    the escape character is backslash.
    comments start with #.
    empty lines are skipped.

    lines can be of the following formats:

    syntax: regexp # defaults following lines to non-rooted regexps
    syntax: glob   # defaults following lines to non-rooted globs
    re:pattern     # non-rooted regular expression
    glob:pattern   # non-rooted glob
    pattern        # pattern of the current default typet    s   %s: %si    (   R'   t   extendt   utilt   nevert   matcht   Abort(	   R   R    R!   R"   t   allpatsR#   t   patlistt
   ignorefuncR&   (    (    s4   /sys/lib/python2.7/site-packages/mercurial/ignore.pyt   ignoreK   s    )(
   t   i18nR    R*   R,   R   t   NoneR   R   R'   R1   (    (    (    s4   /sys/lib/python2.7/site-packages/mercurial/ignore.pyt   <module>   s   	)	