
    	^c|                        d dl Z 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 ddl	m
Z
mZmZ ddlmZmZmZm	Z	mZ ddlmZ i Zi Zi Zg Zh dZd1dZd	 Zd
 Zd Zd2dZd Zd ZdZ d Z!d Z"d1dZ#d Z$d Z%d1dZ&d Z'd Z(d Z)d Z*d Z+d2dZ,d Z- G d d          Z.d Z/d1d Z0d! Z1d" Z2d# Z3d$ Z4d% Z5d& Z6d' Z7d( Z8d) Z9d3d+Z:d4d-Z;d. Z<d/ Z=d0 Z>dS )5    N   )_gettext)getattropensetattr)cmdutilconfigitemserrorpycompatutil)
stringutil>	      color   hgcia   shelve   hbisect   inotify   interhg   progress	   bookmarks   parentrevspecc              #   v    K    r fd}nd }t           D ]"}t          |         }|r ||          r||fV  #d S )Nc                 x    dD ]5}                     d|| z            }||                    d          s dS 6d S )N)s   %s   hgext.%s
   extensions   !T)config
startswith)nameformatconfuis      6/usr/lib/python3/dist-packages/mercurial/extensions.pyenabledzextensions.<locals>.enabled8   sR    .    yy>>#DOOD,A,A#44       c                     dS )NT )r   s    r#   <lambda>zextensions.<locals>.<lambda>?   s    t r%   )_order_extensions)r"   r$   r   modules   `   r#   
extensionsr,   5   s      	 	$	  	  	  	  	  	  $#  T" 	ggdmm 	, r%   c                    d}	 t           |          }nc# t          $ rV t                                           D ]9\  }}|                    d| z             s|                    d| z             r|} n:Y nw xY w|st          |           |S )z'return module with given extension nameN   .   /)r*   KeyErroritemsendswith)r   modkvs       r#   findr6   F   s    
C$   %%'' 	 	DAqzz$+&& !**TD[*A*A 
  tnnJs    AA21A2c                    |                     dd          }t          j        t          j        |                     } t	          j        |          }t	          j        |           } t          j                            |           rSt          j        	                    |           \  }}t          j        ||g          \  }}}t          j        ||||          S 	 t          j        ||           S # t          $ r}|j        s| |_         d }~ww xY w)Nr.      _)replacer   normpath
expandpathr   fsdecodeospathisdirsplitimpfind_moduleload_moduleload_sourceIOErrorfilename)r>   module_namedffdfpathdescexcs           r#   loadpathrN   U   s    %%dD11K=..//D#K00KT""D	w}}T w}}T""1/!aS11E4 UD
 
 	
	?;555 	 	 	< $#	s   C- -
D7DDc                     t          t          j        |                     }|                     d          }|dd         D ]}t	          ||          }|S )z#import and return the <name> moduler.   r   N)
__import__r   sysstrr@   r   )r   r3   
componentscomps       r#   _importhrT   l   sW    
X_T**
+
+CD!!J122 ! !c4  Jr%   c                 J   |rt          |d| z            }n	 t          d| z            }nx# t          $ rk}|r ||d| z  d| z             	 t          d| z            }n8# t          $ r+}|r ||d| z  |            t          |           }Y d }~nd }~ww xY wY d }~nd }~ww xY w|S )Nr   s   hgext3rd.%s)rN   rT   ImportError)r   r>   
reportfuncr3   errs        r#   
_importextrY   u   s     % t[4/00
	%;-..CC 	% 	% 	% K
3d 2NT4IJJJ%~455 % % % AJsNT$94@@@tnn%	% Js>   + 
B BAB
B(!B	BBBB c                     |                      dd|t          j        |          |           | j        r,|                     dd          r|                                  d S d S d S )N	   extensions*       - could not import %s (%s): trying %s
s   devels   debug.extensions)logr   forcebytestr	debugflag
configbool	traceback)r"   rX   failednexts       r#   _reportimporterrorrc      s{     FF6$$   
| h0CDD 
   r%   c                    t          |t          t          t          f          r|D ]}t	          | |           d S t          |t
                    rS|                                D ]<\  }}t	          | |           t	          d| t          j        |          fz  |           =d S t          |t          d                    rt          j        d|| fz  d          d S )Ns   %s.%s s   unicode %r found in %ss   use b'' to make it byte stringhint)
isinstancelistsettuple_rejectunicodedictr1   r   r]   typer   ProgrammingError)r   xsxr4   r5   s        r#   rl   rl      s   "tS%()) 
 	$ 	$A4####	$ 	$	B		 
HHJJ 	M 	MDAq4###8tZ-DQ-G-G&HH!LLLL	M 	M 
BS			"	" 
$%T
22
 
 
 	

 
r%   )s   norepos   optionalrepos	   inferrepoc                     |                                 D ]Q\  }}|d         fdt          D             }|s#t          j        dd                    |          z  d|z            dS )z4Check if extension commands have required attributesr   c                 >    g | ]}t          j        |          |S r'   )r   safehasattr).0arI   s     r#   
<listcomp>z%_validatecmdtable.<locals>.<listcomp>   s+    JJJ43CAq3I3IJ1JJJr%   s   missing attributes: %ss   , s'   use @command decorator to register '%s'rf   N)r1   _cmdfuncattrsr   ro   join)r"   cmdtablecemissingrI   s        @r#   _validatecmdtabler~      s       
 
1aDJJJJmJJJ 	$%

7(;(;;;a?
 
 
 	

 
r%   c           	          dD ]!}t          |t          ||i                      "dD ]*}t          ||d          }|rt          ||j                   +t          | t          |di                      dS )z=Sanity check for loadable tables provided by extension module)   cmdtable
   colortable   configtable)   filesetpredicate   internalmerge   revsetpredicate   templatefilter   templatefunc   templatekeywordNrz   )rl   r   _tabler~   )r"   r3   tos       r#   _validatetablesr      s    9 / /q'#q"--.... 
( 
( CD!! 	(1ah'''b'#z26677777r%   c           	         |                     d          s|                     d          r|dd          }n|}|t          v rd S |t          v rt          |         S |                     dd|           d t          |<   t	          j        d|          5 }t          ||t          t          |                     }d d d            n# 1 swxY w Y   |                     dd||           |||xx         |j	        z  cc<   t          |dd           }|rt	          j        d	
          }t	          j        t          j        |          d	          }	d |	v r|	d         pd|	d         pdf}	d |v s|	|k    r=t          d          }
|                     |
||t	          j                    fz             d S |                     dd|           t#          | |           |t          |<   t$                              |           |                     dd|           t	          j        d|          5 }t(                              |g           D ]} |d           	 d d d            n# 1 swxY w Y   |                     dd|           |S )Ns   hgext.s   hgext/   r[   s     - loading extension: %s
zload extension %ss     > %s extension loaded in %s
minimumhgversion   )nr   r   s^   (third party extension %s requires version %s or newer of Mercurial (current: %s); disabling)
s&       - validating extension tables: %s
s(       - invoking registered callbacks: %s
zcallbacks extension %sTloadeds        > callbacks completed in %s
)r   _builtinr*   r\   r   timedcmrY   bindrc   elapsedr   versiontupler   r]   r   warnversionr   r)   append_aftercallbacksget)r"   r   r>   loadingtime	shortnamestatsr3   minvercurverextminmsgfns               r#   loadr      s,   y!! T__Y%?%? H			HtK9%%FF<7CCC!K		)9	5	5 CtT*<b%A%ABBC C C C C C C C C C C C C C CFF<;YNNNI%-/ S,d33F "Q'''":#:6#B#BAFF6>>Qin1fQin15F6>>Vf__< C GGC9fdlnn==>>>FFF<CYOOOB K	
MM)FFBI   
.		:	: e!%%i44 	 	BBdOOOOO	               FF<=uEEEJs$   %C  CC+IIIc                 .   t          t          |          dd           }|rv	  ||           ni# t          $ r\}|                    d           t	          j        |          }|                    t          d          | |fz             Y d }~dS d }~ww xY wdS )NuisetupTforce&   *** failed to set up extension %s: %s
Fr   r*   	Exceptionr`   r   r]   r   r   )r   r"   r   instr   s        r#   _runuisetupr      s    k$'D99G 	GBKKKK 	 	 	LLtL$$$)$//CGGA@AAT3KOPPP55555		
 4   , 
BABBc                 .   t          t          |          dd           }|rv	  ||           ni# t          $ r\}|                    d           t	          j        |          }|                    t          d          | |fz             Y d }~dS d }~ww xY wdS )NextsetupTr   r   Fr   )r   r"   r   r   r   s        r#   _runextsetupr   
  s    {4(*d;;H 	HRLLLL 	 	 	LLtL$$$)$//CGGA@AAT3KOPPP55555		
 4r   c           
         t          j        t                    }|                     d          }fd|D             }d |D             }t	          t
                    }|                     dd|rdnd           |                     ddt	          |                     t          j        d	          5 }| 	                    dd
          d         }|D ]\  }}|rA|dd         dk    r3|t          vr|                     dd|           |dd          t          |<   I	 t          | |||           ]# t          $ r}	t          j        |	          }
|rt          d          }||||
fz  }nt          d          }|||
fz  }|                                }| 	                    d|          d         }|                    |           t          j        |                    dd                    rQd }t)          |	t*          j                  r|	j        r|	j        }|t          d          }t+          j        ||          |                     d|z             t)          |	t*          j                  r1|	j        r*|                     t          d          |	j        z             |                                  Y d }	~	d }	~	ww xY w	 d d d            n# 1 swxY w Y   |                     ddt	          t
                    |z
  |           dt          dfg}|                     dd           t7          | ||           t9                      }|                     dd           t          j        d          5 }t
          |d          D ]}|                     dd|           t          j        d|          5 }t;          ||           s,|                     dd|           |                    |           d d d            n# 1 swxY w Y   |                     dd ||           ||xx         |j        z  cc<   	 d d d            n# 1 swxY w Y   |                     dd!|           |                     dd"           t          j        d#          5 }t
          |d          D ]}||v r|                     dd$|           t          j        d%|          5 }tA          ||           s,|                     dd&|           |                    |           d d d            n# 1 swxY w Y   |                     dd'||           ||xx         |j        z  cc<   	 d d d            n# 1 swxY w Y   |                     dd(|           |D ]#}|                     dd)|           d tB          |<   $|                     dd*           t          j        d+          5 }tD          D ]?}|tB          v rtD          |         D ]%}|                     dd,|            |d-.           &@	 d d d            n# 1 swxY w Y   |                     dd/|           tD          #                                 dd0l$m%}m&}m'}m(}m)}m*}m+}m,} |                     dd1           d2|d3fd4|d5fd6|d7fd8|d9fd:|d7fd;|d<fd=|d>fd?|d@fg}t          j        dA          5 }t7          | ||           d d d            n# 1 swxY w Y   |                     ddB|           t[          |          D ]2}|                     ddC|t          j.        ||                              3|                     ddD           d S )ENr   c                 &    g | ]\  }}|v 	||fS r'   r'   )ru   r4   r5   	whitelists      r#   rw   zloadall.<locals>.<listcomp>  s&    @@@Vai1a&r%   c                 $    g | ]\  }}d |v	||fS )   :r'   )ru   r4   r5   s      r#   rw   zloadall.<locals>.<listcomp>  s%    ;;;!QT]]q!f]]]r%   r[   s   loading %sextensions
s   additional r%   s   - processing %d entries
zload all extensions   *r   r   r   s$     - skipping disabled extension: %s
s+   failed to import extension "%s" from %s: %ss#   failed to import extension "%s": %ss   requireds   nosS   loading of this extension was required, see `hg help config.extensions` for detailsrf   s   *** %s
s	   *** (%s)
s&   > loaded %d extensions, total time %s
r   s   loadconfigtables!   - loading configtable attributes
s   - executing uisetup hooks
zall uisetups     - running uisetup for %s
z
uisetup %ss&       - the %s extension uisetup failed
s     > uisetup for %s took %s
s   > all uisetup took %s
s   - executing extsetup hooks
zall extsetups     - running extsetup for %s
zextsetup %ss'       - the %s extension extsetup failed
s     > extsetup for %s took %s
s   > all extsetup took %s
s$       - disabling broken %s extension
s%   - executing remaining aftercallbacks
aftercallbackss.     - extension %s not loaded, notify callbacks
Fr   s+   > remaining aftercallbacks completed in %s
)colorcommands	filemergefilesetrevsettemplatefilterstemplatefuncs
templatekws)   - loading extension registration objects
r   s   loadcmdtabler   s   loadcolortabler   s   loadpredicater   s   loadinternalmerger   r   s
   loadfilterr   s   loadfunctionr   s   loadkeywordzload registration objectss0   > extension registration object loading took %s
s*   > extension %s take a total of %s to load
s   extension loading complete
)/collectionsdefaultdictintr
   lenr)   r\   r   r   configsuboptions_disabledextensionsr   r   r   r]   r   copyupdate	parseboolr   rh   r   Hintrg   Abortr   r`   
_loadextrarj   r   addr   r   r*   r   clearre   r   r   r   r   r   r   r   r   sorted	timecount)r"   r   r   resultnewindexr   default_sub_optionsr   r>   r   r   	error_msgoptionsext_optionsrg   earlyextraloadersbrokenalluisetupstatsallextetupstatsr   r   r   r   r   r   r   r   r   r   extraloaderss    `                            r#   loadallr     sP
   )#..K^^M**F@@@@v@@@;;6;;;F6{{HFF!"+  
 FF<5s6{{CCC	+	,	, ,# 11-FFqI" )	# )	#LT4 	!9$$#666(D   
 15QRR'-#Rt[1111 # # # -d33 - !F! !I $c!22II !"H I II$,I-2244 11-FFqI{+++'K(G(GHH #D!$
33 )	 )#y| K     +id;;;;GG[I5666!$
33 >	 >- 0 049 <===LLNNNNNNNN9#)	#,# ,# ,# ,# ,# ,# ,# ,# ,# ,# ,# ,# ,# ,# ,#\ FF2Fh	   
&89 FF<>???r8.///UUFFF<7888	m	$	$ /899% 	/ 	/DFF<!@$GGGlD11 %U"4,, %FF$B  
 JJt$$$% % % % % % % % % % % % % % % FF<!@$NNN.	// / / / / / / / / / / / / / / FF<3_EEEFF<8999	n	%	% /899% 	/ 	/Dv~~FF<!A4HHHmT22 %e#D"-- %FF$C  
 JJt$$$% % % % % % % % % % % % % % % FF<!A4OOO.	// / / / / / / / / / / / / / / FF<4oFFF ! !
|EtLLL D FF<BCCC	&	'	' !5( 
	! 
	!IK''%i0 ! ! F  
 %     !	
	!! ! ! ! ! ! ! ! ! ! ! ! ! ! ! FF<H%PPP 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	" FF<FGGG	h0	01	g'78	9&:;	V%56	O];	-9	Z8	L 
1	2	2 /e2x.../ / / / / / / / / / / / / / /FF<   {## 
 

:N;t,--		
 	
 	
 	
 FF<899999s   3A(KD/.K/J>:E9J93K9J>>KKK0>P=.=O7+P=7O;;P=>O;?1P==QQ	AU=T	UTUT1UU"UAX""X&)X&=[["[c                     t           |d          D ]I}t          |         }|s|D ]4\  }}}t          ||d           }| t          ||          | ||           5Jd S N)r)   r*   r   )	r"   r   r   r   r+   objname	loadermod
loadernameextraobjs	            r#   r   r     s    xyy! C CT" 	.: 	C 	C*GY
vw55H#.	:..r4BBB	CC Cr%   c                     | t           v rt           |          du} ||           dS t                              | g                               |           dS )a  Run the specified function after a named extension is loaded.

    If the named extension is already loaded, the callback will be called
    immediately.

    If the named extension never loads, the callback will be called after
    all extensions have been loaded.

    The callback receives the named argument ``loaded``, which is a boolean
    indicating whether the dependent extension actually loaded.
    Nr   )r*   r   
setdefaultr   )	extensioncallbackr   s      r#   afterloadedr     sa     KY't3""9b1188BBBBBr%   c           	      <   t          |           D ]\  }}t          |dd          }|s	  ||            &# t          $ rY}|                     d           |                     t          d          |t          j        |          fz             Y d}~d}~ww xY wdS )aM  Run extension hooks on the given ui to populate additional members,
    extend the class dynamically, etc.

    This will be called after the configuration is loaded, and/or extensions
    are loaded. In general, it's once per ui instance, but in command-server
    and hgweb, this may be called more than once with the same ui.
    
uipopulateNTr   s.   *** failed to populate ui by extension %s: %s
)r,   r   r   r`   r   r   r   r]   )r"   r   r3   hookr   s        r#   
populateuir     s      ^^  	csL$// 		DHHHH 	 	 	LLtL$$$GGDEE06678       	 s   6
B ABBc                 8     t                     sJ  fd}|S )zPartial function application

    Returns a new function that is the partial application of args and kwargs
    to func.  For example,

        f(1, 2, bar=3) === bind(f, 1)(2, bar=3)c                       | z   i |S r   r'   )rv   kwargsfuncs     r#   closurezbind.<locals>.closure  s    tdQh&2&&&r%   )callable)r   r   r   s   `` r#   r   r   
  s=     D>>' ' ' ' ' ' Nr%   c                    	 |j         | _         n# t          $ r Y nw xY wt          |d          | _        t          |d          | _        | j                            t          |di                      || _        || _        dS )z.Copy and add some useful attributes to wrapper
__module____doc____dict__N)	__name__AttributeErrorr   r   r   r   r   	_origfunc_unboundwrapper)wraporigfnunboundwrappers      r#   _updatewrapperr     s       fl33DO69--DLMR88999DN)Ds    
c                    t          |          sJ t          j        ||           \  }}|                                 D ]\  }}||u r|}	 n|d         }
t	          j        t          j        |          t          j        |
                    }t          ||
|           ||xj	        |z  c_	        t          |          }||d<   ||dxx         |z  cc<   t          |          | |	<   |S )a.  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.

    Optionally append to the command synopsis and docstring, used for help.
    For example, if your extension wraps the ``bookmarks`` command to add the
    flags ``--remote`` and ``--all`` you might call this function like so:

      synopsis = ' [-a] [--remote]'
      docstring = """

      The ``remotenames`` extension adds the ``--remote`` and ``--all`` (``-a``)
      flags to the bookmarks command. Either flag will show the remote bookmarks
      known to the repository; ``--remote`` will also suppress the output of the
      local bookmarks.
      """

      extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks,
                             synopsis, docstring)
    r   Nr   )r   r	   findcmdr1   	functoolspartialr   checksignaturer   r   ri   rk   )tablecommandwrappersynopsis	docstringaliasesentryaliasr|   keyr   r   newentrys                r#   wrapcommandr  &  s   : G_We44NGUKKMM  q::CE  1XFG$$d&9&&A&A D 4)))	!E{{HHQKxxE#JLr%   c                 2   t          j        |          }t                    sJ | j        D ]H}||j        v r=|j        |         j        t                    sJ fd}||j        |         _         nI|t          u rt          d| d|d          dS )z[Wraps a filecache property.

    These can't be wrapped using the normal wrapfunction.
    c                       g| R i |S r   r'   )r   kwargsr   r  s     r#   r   zwrapfilecache.<locals>.wrapf  s#    wv7777777r%   ztype 'z' has no property ''N)r   rQ   r   __mro__r   r   objectr   )clspropnamer  currclsr   r   s     `  @r#   wrapfilecacher  Z  s    
 x((HG; 	 	w'''%h/4FF#####8 8 8 8 8 8 /3GX&+E ( &nhhhOPPP r%   c                   $    e Zd ZdZd Zd Zd ZdS )wrappedfunctionz3context manager for temporarily wrapping a functionc                 R    t          |          sJ || _        || _        || _        d S r   )r   
_container	_funcname_wrapper)self	containerfuncnamer  s       r#   __init__zwrappedfunction.__init__s  s/         #!r%   c                 F    t          | j        | j        | j                   d S r   )wrapfunctionr  r  r   )r!  s    r#   	__enter__zwrappedfunction.__enter__y  s     T_dndmDDDDDr%   c                 F    t          | j        | j        | j                   d S r   )unwrapfunctionr  r  r   )r!  exctypeexcvaluer`   s       r#   __exit__zwrappedfunction.__exit__|  s     tFFFFFr%   N)r   r   __qualname__r   r$  r'  r,  r'   r%   r#   r  r  p  sO        ==     E E EG G G G Gr%   r  c                 "   t          |          sJ t          | |          }t          |          sJ t          j        |           rt	          j        ||          }nt          ||          }t          |||           t          | ||           |S )a  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.
    )	r   r   inspectismoduler  r  r   r   r   )r"  r#  r  r   r   s        r#   r&  r&    s    B GY))FF	"" %  &11 GV$$4)))Ix&&&Mr%   c                     t          | |          }|                                }||d         }|                    |           t          | ||           t	          |          D ]}t          | ||           |S )a/  undo wrapfunction

    If wrappers is None, undo the last wrap. Otherwise removes the wrapper
    from the chain of wrappers.

    Return the removed wrapper.
    Raise IndexError if wrapper is None and nothing to unwrap; ValueError if
    wrapper is not None but is not found in the wrapper chain.
    Nr   )getwrapperchainpopremover   reversedr&  )r"  r#  r  chainr   ws         r#   r)  r)    s     Ix00EYY[[F(	LLIx(((e__ - -Y!,,,,Nr%   c                     g }t          | |          }|rHt          |          sJ |                    t          |d|                     t          |dd          }|H|S )zget a chain of wrappers of a function

    Return a list of functions: [newest wrapper, ..., oldest wrapper, origfunc]

    The wrapper functions are the ones passed to wrapfunction, whose first
    argument is origfunc.
    r   r   N)r   r   r   )r"  r#  r   r   s       r#   r2  r2    ss     F	H	%	%B
 ,||gb"3R88999Rd++  , Mr%   c                     ddl } i }t          j        | d          r!t          j                            t          j        t          j        | j	                                      }	 t          j
        |          }|D ]}|                    d          r=|                    dd          d         }t          j                            ||          }nC|}t          j                            ||d          }t          j                            |          s||v s|t          v s|dk    r|||<   n# t           $ r Y nw xY wt"                                          D ]\  }}|r|||<   |S )	zAfind paths of disabled extensions. returns a dict of {name: path}r   N__file__s   .pyr.   r   s   __init__.pys   __init__)hgextr   rt   r=   r>   dirnameabspathr   fsencoder:  listdirr2   rsplitry   existsr)   OSErrorr   r1   )r;  extsextpathfilesr|   r   r>   s          r#   _disabledpathsrF    s}   LLLD z** "'//L*5>::;;
 
	"Jw''E  " "::f%% !88D!,,Q/D7<<33DDD7<<NCCD7>>$// ! 4<<46>>T[5H5H!T

"  	 	 	D	  *//11  
d  	DJKs   &D. .
D;:D;c                 j   g }|                                  }|dd         dk    s|                                s9|                                  }|sn"|dd         dk    %|                                9|dd         }|dk    s|dk    r|dd         }|r|                                                    |          r3|                    |          d         }|r|                    |           n/|sdS |                    |           |                                  }|ndS d                    |          S )	zreturn 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 synopsisNr      #   s   """s   '''r   r%   )readlinestriprstripr2   r@   r   ry   )filer   linestarts       r#   
_moduledocrP    sF    F==??D
rr(d

$**,,
}} 	 rr(d

$**,,

 !HE%6//ABBx 		#{{}}%%e,, zz%((+ (MM$''' tMM$==??D  		# t88Fr%   c                     	 t          | d          5 }t          |          }ddd           n# 1 swxY w Y   n# t          $ r Y dS w xY w|rt          |          S t	          d          S )zBretrieve help synopsis of a disabled extension (without importing)   rbN   (no help text available))r   rP  rE   r   r   )r>   srcdocs      r#   _disabledhelprV    s    $ 	"#S//C	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"     .s||,---s'   : .: 2: 2: 
AAc                  @   	 ddl m}  d | j                                        D             S # t          t
          f$ r Y nw xY wt                      }|si S i }|                                D ]3\  }}t          |          }|r|dk    rt          j	        |          ||<   4|S )zCfind disabled extensions from hgext. returns a dict of {name: desc}r   	__index__c                 F    i | ]\  }}|t           v|t          |          S r'   )r)   r   )ru   r   rL   s      r#   
<dictcomp>zdisabled.<locals>.<dictcomp>2  s9     
 
 
d6!! '$--!!!r%   s	   __index__)
r;  rY  docsr1   rV   r   rF  rV  r   	firstline)rY  pathsrC  r   r>   rU  s         r#   disabledr_  -  s    	######
 
'n2244
 
 
 	

 (    E 	Dkkmm 3 3
dD!! 	34<''#-c22DJKs   (+ ??c                 (   t                      }| |v rt          ||                    S 	 ddl}ddlm} t	          j        |d          rdS | t          v rdS t          |j        	                    |                     S # t          t          f$ r Y dS w xY w)z<Obtain the full help text for a disabled extension, or None.r   NrX  r:  )rF  rV  r;  rY  r   rt   r)   r   r\  r   rV   r   )r   r^  r;  rY  s       r#   disabled_helpra  G  s    Eu}}U4[)))	LLL'''''' z22 v~~y~11$77888^, 	 	 	DD	s   A< 
	A< &A< <BBc              #     K   t          j        | g          }|r|                                } t          | t          j                  s(|                    t	          j        |                      X| j        D ]R}t          |t          j	                  st          |j
        t          j                  s=|j
        j        dk    rN|V  S|dS dS )z7Scan @command() decorators in the tree starting at noder  N)r   dequepopleftrh   astFunctionDefextenditer_child_nodesdecorator_listCallr   Nameid)nodetodorH   s      r#   _walkcommandro  ^  s      dV$$D
 ||~~$00 	KK,T22333$ 	 	Aa** afch// vyI%%GGGG      r%   c                    t          | d          5 }t          j        |                                |           }ddd           n# 1 swxY w Y   i }t	          |          D ]v}|j        s
|j        d         }t          |t          j                  rt          j	        |j
                  }n#t          |t          j                  r|j
        }nndg df||<   w|S )zuConstruct a dummy command table without loading the extension module

    This may raise IOError or SyntaxError.
    rR  Nr   r%   )r   re  parsereadro  r   rh   Strr   sysbytessBytes)r>   rT  rootrz   rm  rv   r   s          r#   _disabledcmdtablerx  p  s   
 
dE		 +cyT**+ + + + + + + + + + + + + + +HT"" 
) 
)y 	IaLa!! 	$QS))DD39%% 	3DDCOs   (AA	A	c                 B   	 t          |          }n# t          t          f$ r Y d S w xY w	 t          j        |||          \  }}n"# t
          j        t
          j        f$ r Y d S w xY w|D ]}|                    |          r|} n	|d         }t          |          }	|||	fS )Nr   )
rx  rE   SyntaxErrorr	   r  r   AmbiguousCommandUnknownCommandr   rV  )
r"   cmdr   r>   strictrz   r  r  r{   rU  s
             r#   _finddisabledcmdr    s    $T**[!    h??"E$89     << 	CE	 aj


Css    ''A A$#A$Fc                 >   t                      }|st          j        |          d}|                    |d          }|rt	          | ||||          }|s2|                                D ]\  }}t	          | ||||          }|r n|r|S t          j        |          )zXfind cmd from disabled extensions without importing.
    returns (cmdname, extname, doc)N)r~  )rF  r   r|  r3  r  r1   )r"   r}  r~  r^  extr>   r   s          r#   disabledcmdr    s     E ("3'''
C99S$D Br3T&AAA ++-- 	 	JD$"2sD$vFFFC 
 


s
#
##r%   Tc                    i }t                      D ]r\  }}t          |j                  pt          d          }|J | r|                    d          d         }t          j        |                                          ||<   s|S )z+return a dict of {name: desc} of extensionsrS  Nr.   )r,   r   r   r   r@   r   r]  rK  )r   rC  enamer  rU  s        r#   r$   r$     s    D ll 8 8
sck""Da(C&D&D 	*KK%%b)E *3//5577UKr%   c                  H    d t                                           D             S )z4return short names of extensions that failed to loadc                     g | ]	\  }}||
S r   r'   )ru   r   r3   s      r#   rw   znotloaded.<locals>.<listcomp>  s    EEEYT3Dr%   )r*   r1   r'   r%   r#   	notloadedr    s"    EE+"3"3"5"5EEEEr%   c                    t          j        | d          r<t          | j                  r(	 |                                 }n1# t          $ r d}Y n#w xY wt          j        | d          r| j        }nd}t          |t          t          f          r d	                    d |D                       }nt          j        |          }|S )z8return version information from given module as a strings
   getversions   unknowns   __version__r%   r.   c              3   >   K   | ]}t          j        |          V  d S r   )r   bytestr)ru   r   s     r#   	<genexpr>z moduleversion.<locals>.<genexpr>  s-      AAAH,Q//AAAAAAr%   )r   rt   r   
getversionr   __version__rh   ri   rk   ry   r   r]   )r+   r   s     r#   moduleversionr    s    .. 	8F<M3N3N 		!''))GG 	! 	! 	! GGG	! 
	&.	1	1 $'D%=)) 3))AAAAAAA )'22Ns   A   AAc                 0    t          | dd           }|dk    S )N
testedwiths   ships-with-hg-core)r   )r+   exttestedwiths     r#   ismoduleinternalr    s    FL$77M111r%   r   )NN)F)T)?re  r   r  rA   r/  r=   i18nr   r   r   r   r   r   re   r	   r
   r   r   utilsr   r*   r   r   r)   r   r,   r6   rN   rT   rY   rc   rl   rx   r~   r   r   r   r   r   r   r   r   r   r   r  r  r  r&  r)  r2  rF  rP  rV  r_  ra  ro  rx  r  r  r$   r  r  r  r'   r%   r#   <module>r     s   


         



  				                                    	
 
 
   "    .     *  
 
 
  ;

 

 

8 8 8$0 0 0 0f
 
 

 
 
y: y: y: y:x	C 	C 	CC C C*  ,  
* 
* 
*1 1 1 1hQ Q Q,G G G G G G G G / / /d   *  "# # #L  B. . .  4  .  $  ,  &$ $ $ $2
 
 
 
F F F
  *2 2 2 2 2r%   