ó
ēQc           @   sų   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z i  Z g  Z	 d d d d g Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z e d  Z d   Z d   Z d   Z d   Z e d  Z d   Z d S(   i’’’’N(   t   _t   gettextt   hbisectt	   bookmarkst   parentrevspect   interhgc          c   s3   x, t  D]$ }  t |  } | r |  | f Vq q Wd  S(   N(   t   _ordert   _extensions(   t   namet   module(    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt
   extensions   s    
c         C   s   d } y t |  } Wn^ t k
 rt xN t j   D]< \ } } | j d |   sc | j d |   r1 | } Pq1 q1 Wn X| s t |    n  | S(   s'   return module with given extension namet   .t   /N(   t   NoneR   t   KeyErrort	   iteritemst   endswith(   R   t   modt   kt   v(    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   find   s    &c         C   sĪ   | j  d d  } t j |   }  t j j |   r t j j |  j d   \ } } t j	 | | g  \ } } } t j
 | | | |  Sy t j | |   SWn+ t k
 rÉ } | j sĆ |  | _ n    n Xd  S(   NR   R    R   (   t   replacet   utilt
   expandpatht   ost   patht   isdirt   splitt   rstript   impt   find_modulet   load_modulet   load_sourcet   IOErrort   filename(   R   t   module_namet   dt   ft   fdt   fpatht   desct   exc(    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   loadpath$   s    !	c         C   sļ   | j  d  s | j  d  r+ | d } n | } | t k rA d  S| t k rU t | Sd  t | <| r{ t | d |  } nY d   } y | d |  } Wn9 t k
 rÓ } |  j d | | | f  | |  } n X| t | <t j |  | S(   Ns   hgext.s   hgext/i   s   hgext.%sc         S   sC   t  |   } |  j d  } x! | d D] } t | |  } q& W| S(   NR   i   (   t
   __import__R   t   getattr(   R   R   t
   componentst   comp(    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   importhD   s
    s*   could not import hgext.%s (%s): trying %s
(	   t
   startswitht   _ignoreR   R   R*   t   ImportErrort   debugR   t   append(   t   uiR   R   t	   shortnameR   R/   t   err(    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   load4   s(    
		
c         C   s  |  j  d  } t t  } xĘ | D]¾ \ } } | rM | d d k rM q" qM n  y t |  | |  Wq" t k
 rw   q" t k
 rß } | rÆ |  j t d  | | | f  n |  j t d  | | f  |  j   rą d Sq" Xq" Wx; t | D]/ } t	 t
 | d d   } | rļ | |   qļ qļ Wxr t | D]f } t	 t
 | d d   } | r-y | |   Wqt k
 r| j j d k r  n  |   qXq-q-Wd  S(	   NR
   i    t   !s.   *** failed to import extension %s from %s: %s
s&   *** failed to import extension %s: %s
i   t   uisetupt   extsetup(   t   configitemst   lenR   R8   t   KeyboardInterruptt	   Exceptiont   warnR    t	   tracebackR,   R   R   t	   TypeErrort	   func_codet   co_argcount(   R5   t   resultt   newindexR   R   t   instR:   R;   (    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   loadallT   s>    	c   
         sĶ   t  j  d  s t  t j | |   \ } } x0 |  j   D]" \ } } | | k r= | } Pq= q= W| d      f d   } t   d  | _ t   d  | _ t	 |  }	 | |	 d <t
 |	  |  | <| S(   s~  Wrap the command named `command' in table

    Replace command in the command table with wrapper. The wrapped command will
    be inserted into the command table specified by the table argument.

    The wrapper will be called like

      wrapper(orig, *args, **kwargs)

    where orig is the original (wrapped) function, and *args, **kwargs
    are the arguments passed to it.
    t   __call__i    c             s"   t  j   t  j    |  |  S(   N(   R   t   checksignature(   t   argst   kwargs(   t   origfnt   wrapper(    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   wrap   s    t   __doc__t
   __module__(   R   t   safehasattrt   AssertionErrort   cmdutilt   findcmdR   R,   RP   RQ   t   listt   tuple(
   t   tablet   commandRN   t   aliasest   entryt   aliast   et   keyRO   t   newentry(    (   RM   RN   s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   wrapcommandx   s    

c            se   t  j  d  s t     f d   } t |  |    t  j   d  sQ t  t |  | |    S(   sµ  Wrap the function named funcname in container

    Replace the funcname member in the given container with the specified
    wrapper. The container is typically a module, class, or instance.

    The wrapper will be called like

      wrapper(orig, *args, **kwargs)

    where orig is the original (wrapped) function, and *args, **kwargs
    are the arguments passed to it.

    Wrapping methods of the repository object is not recommended since
    it conflicts with extensions that extend the repository by
    subclassing. All extensions that need to extend methods of
    localrepository should use this subclassing trick: namely,
    reposetup() should look like

      def reposetup(ui, repo):
          class myrepo(repo.__class__):
              def whatever(self, *args, **kwargs):
                  [...extension stuff...]
                  super(myrepo, self).whatever(*args, **kwargs)
                  [...extension stuff...]

          repo.__class__ = myrepo

    In general, combining wrapfunction() with subclassing does not
    work. Since you cannot control what other extensions are loaded by
    your end users, you should play nicely with others by using the
    subclass trick.
    RI   c             s      |  |  S(   N(    (   RK   RL   (   RM   RN   (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyRO   »   s    (   R   RR   RS   R,   t   setattr(   t	   containert   funcnameRN   RO   (    (   RM   RN   s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   wrapfunction   s    !c         C   s2  d d l  } t j j t j j | j   } y t j |  } Wn t k
 rT i  SXi  } xŠ | D]Č } | j d  r„ | j	 d d  d } t j j
 | |  } nQ | } t j j
 | | d  } t j j |  sŪ qb n  |  rö t j j |  } n  | | k sb | t k sb | d k r qb n  | | | <qb W| S(	   s~   find paths of disabled extensions. returns a dict of {name: path}
    removes /__init__.py from packages if strip_init is Truei’’’’Ns   .pyR   i   i    s   __init__.pyt   __init__(   t   hgextR   R   t   dirnamet   abspatht   __file__t   listdirt   OSErrorR   t   rsplitt   joint   existsR   (   t
   strip_initRf   t   extpatht   filest   extsR]   R   R   (    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   _disabledpathsĆ   s*    !$c         C   sž   g  } |  j    } x7 | d  d k s2 | j   rK |  j    } | s Pq q W| d  } | d k sn | d k rķ | d } xv | ré | j   j |  rĆ | j |  d } | ræ | j |  n  Pn
 | sĶ d S| j |  |  j    } q{ Wn d Sd j |  S(	   sÖ   return the top-level python documentation for the given file

    Loosely inspired by pydoc.source_synopsis(), but rewritten to
    handle triple quotes and to return the whole text instead of just
    the synopsisi   t   #i   s   """s   '''i    t    N(   t   readlinet   stripR   R   R   R4   R   Rm   (   t   fileRE   t   linet   start(    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt
   _moduledocŽ   s*     

	c         C   sc   y t  |   } Wn t k
 r$ d SXt |  } | j   | rU t |  j   d St d  Sd S(   sB   retrieve help synopsis of a disabled extension (without importing)Ni    s   (no help text available)(   t   openR!   R{   t   closeR   t
   splitlinesR    (   R   Rx   t   doc(    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   _disabledhelpž   s    
c          C   s   y1 d d l  m }  t d   |  j j   D  SWn t k
 rD n Xt   } | sX i  Si  } x9 | j   D]+ \ } } t |  } | rk | | | <qk qk W| S(   sC   find disabled extensions from hgext. returns a dict of {name: desc}i’’’’(   t	   __index__c         s   s3   |  ]) \ } } | t  k r | t |  f Vq d  S(   N(   R   R   (   t   .0R   R(   (    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pys	   <genexpr>  s   	(   Rf   R   t   dictt   docsR   R2   Rs   R   (   R   t   pathsRr   R   R   R   (    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   disabled  s    		c         C   su   y: d d l  m } |  t k r# d St | j j |    SWn t k
 rM n Xt   } |  | k rq t | |   Sd S(   s;   find a specific disabled extension from hgext. returns desci’’’’(   R   N(	   Rf   R   R   R   R   t   getR2   Rs   R   (   R   R   R   (    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   disabledext#  s    	c            sŚ   t  d t  } | s' t j |   n     f d   } d } | j | d  } | rl | | | |  } n  | s® x9 | j   D]( \ } } | | | |  } | r Pq q Wn  | rĒ d | j k rĒ | St j |   d S(   sU   import disabled extensions until cmd is found.
    returns (cmdname, extname, module)Ro   c            sė   y t  | d |  } Wn t k
 r+ d  SXy+ t j |  t | d i      \ } } WnP t j t j f k
 rw d  St k
 r©  j t	 d  |   j
   d  SXx1 | D] } | j |   r± | }  Pq± q± W| d }  |  | | f S(   Ns   hgext.%st   cmdtables&   warning: error finding commands in %s
i    (   R*   R?   RT   RU   R,   t   errort   AmbiguousCommandt   UnknownCommandR@   R    RA   R0   (   t   cmdR   R   R   RZ   R[   t   c(   t   strictR5   (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyRU   :  s&    	"

t
   DEPRECATEDN(   Rs   t   TrueR   R   R   t   popR   RP   (   R5   R   R   R   RU   t   extR   R   (    (   R   R5   s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   disabledcmd2  s     c          C   sl   i  }  x_ t    D]T \ } } t | j  p4 t d  } | j d  d } | j   d j   |  | <q W|  S(   s+   return a dict of {name: desc} of extensionss   (no help text available)R   i’’’’i    (   R
   R   RP   R    R   R~   Rw   (   Rr   t   enameR   R   (    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   enabled`  s    (   R   R   R   RT   R   t   i18nR    R   R   R   R1   R
   R   R*   R8   RH   R`   Rd   t   FalseRs   R{   R   R   R   R   R   (    (    (    s8   /sys/lib/python2.7/site-packages/mercurial/extensions.pyt   <module>   s&   $				 	$	!	*	 			.