
    6h_                       S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKrSSK	J
r
Jr  SSKJrJrJrJrJr  SSKJr  0 r0 r0 r/ r1 SkrS/S jrS	 rS
 rS rS0S jrS rS rSr S r!S r"S/S jr#S r$S r%S/S jr&S r'S r(S r)S r*S r+S0S jr,S r- " S S5      r.S1S jr/S/S  jr0S! r1S" r2S# r3S$ r4S% r5S& r6S' r7S( r8S) r9S2S* jr:S3S+ jr;S, r<S- r=S. r>g)4    )annotationsN   )_gettext)cmdutilconfigitemserrorpycompatutil)
stringutil>	      color   hgcia   shelve   hbisect   inotify   interhg   progress	   bookmarks   parentrevspecc              #     ^ #    T (       a  U 4S jnOS n[          H)  n[        U   nU(       d  M  U" U5      (       d  M$  X#4v   M+     g 7f)Nc                z   > S H4  nTR                  SX-  5      nUc  M  UR                  S5      (       a  M4    g   g )N)s   %ss   hgext.%s
   extensions   !T)config
startswith)nameformatconfuis      6/usr/lib/python3/dist-packages/mercurial/extensions.pyenabledextensions.<locals>.enabled5   s6    .yy>#DOOD,A,A /    c                    g)NT )r   s    r    <lambda>extensions.<locals>.<lambda><   s    tr#   )_order_extensions)r   r!   r   modules   `   r    
extensionsr+   2   s>     		  $T"6gdmm, s   )A	A	
A	c                   Sn [         U    nU(       d  [        U 5      eU$ ! [         aX    [         R                  5        H=  u  p#UR                  SU -   5      (       d  UR                  SU -   5      (       d  M9  Un   Mq      Nuf = f)z'return module with given extension nameN   .   /)r)   KeyErroritemsendswith)r   modkvs       r    findr5   C   s}    
C$ tnJ  %%'DAzz$+&&!**TD[*A*A (s   	! AB8B>BBc                   UR                  SS5      n[        R                  " [        R                  " U 5      5      n [        R
                  " U 5      n [        R                  R                  U 5      (       aq  [        R                  R                  U S5      n[        R                  R                  U5      (       d+  [        S[        R                  R                  U 5      -  5      eUn [        R                  R                  X5      n[        R                  R!                  XS9nUc   e[        R                  R#                  U5      nU[$        R&                  U'   UR(                  R+                  U5        U$ )N.r   z__init__.pyzNo module named '%s')loader)replacer   normpath
expandpathr
   fsdecodeospathisdirjoinexistsImportErrorbasename	importlib	machinerySourceFileLoaderspec_from_file_locationmodule_from_specsysmodulesr8   exec_module)r>   module_nameinit_py_pathr8   specr*   s         r    loadpathrO   R   s   %%c3/K==./DT"D	ww}}Tww||D-8ww~~l++4rww7G7G7MMNN  11+DF>>11+1MD^^,,T2F%CKKKKF#Mr#   c                l    [        U 5      nU R                  S5      nUSS  H  n[        X5      nM     U$ )z#import and return the <name> moduler7   r   N)
__import__splitgetattr)r   r2   
componentscomps       r    _importhrV   f   s8    
T
CCJ12c  Jr#   c                r   [         R                  " U 5      n U(       a  [        USU -  5      nU$  [        SU -  5      nU$ ! [         al  nU(       a  U" USU -  SU -  5         [        SU -  5      n S nAU$ ! [         a.  nU(       a  U" USU -  U 5        [        U 5      n S nA S nAU$ S nAff = fS nAff = f)Nzhgext.%szhgext3rd.%s)r
   r<   rO   rV   rB   )r   r>   
reportfuncr2   errs        r    
_importextrZ   o   s    T"D tZ$./ J
	%:,-C J  	%3
T 1=43GH%}t34
 J	  %sMD$8$?tnJ	%	%s;   A   
B6
B1"A66
B. B)B1)B..B11B6c           	        U R                  SS[        R                  " U5      [        R                  " U5      [        R                  " U5      5        U R                  (       a)  U R	                  SS5      (       a  U R                  5         g g g )N	   extensions*       - could not import %s (%s): trying %s
s   devels   debug.extensions)logr   forcebytestr	debugflag
configbool	traceback)r   rY   failednexts       r    _reportimporterrorrd      sk     FF6'$% 
||h0CDD
 E|r#   c                   [        U[        [        [        45      (       a  U H  n[	        X5        M     g [        U[
        5      (       aN  UR                  5        H9  u  p4[	        X5        [        R                  " U5      n[	        U < SU< 3U5        M;     g [        U[        5      (       a.  [        R                  " SU[        R                  " U 5      4-  SS9eg )Nr7   s   unicode %r found in %ss   use b'' to make it byte stringhint)
isinstancelistsettuple_rejectunicodedictr0   r
   sysstrstrr	   ProgrammingErrorr   r^   )r   xsxr3   r4   s        r    rl   rl      s    "tS%())A4# 	B		HHJDA4#"AdA.2  
B		$$%Z-D-DT-J(KK2
 	
 
r#   )norepooptionalrepo	inferrepoc           
     Z   UR                  5        H  u  p#US   n[         Vs/ s H  n[        XE5      (       a  M  UPM     nnU(       d  M;  SnUSR                  U Vs/ s H  n[        R
                  " U5      PM     sn5      -  nSU-  n	[        R                  " XyS9e   gs  snf s  snf )z4Check if extension commands have required attributesr   s   missing attributes: %ss   , s'   use @command decorator to register '%s'rf   N)r0   _cmdfuncattrshasattrr@   r   r^   r	   rp   )
r   cmdtablecefamissingmsgmrg   s
             r    _validatecmdtabler      s     aD+Am71=1mA'uzzwGw!:2215wGHH9A=$$S44 !A Hs   B#B# B(c           	         S H  n[        U[        X0 5      5        M     S H-  n[        XS5      nU(       d  M  [        X#R                  5        M/     [        U [        US0 5      5        g)z=Sanity check for loadable tables provided by extension module)ry   
colortableconfigtable)filesetpredicateinternalmergerevsetpredicatetemplatefiltertemplatefunctemplatekeywordNry   )rl   rS   _tabler   )r   r2   tos       r    _validatetablesr      s]    6q'#"-. 7 CD!11hh' b'#z267r#   c           	        UR                  S5      (       d  UR                  S5      (       a  USS  nOUnU[        ;   a  g U[        ;   a	  [        U   $ U R                  SSU5        S [        U'   [        R
                  " SU5       n[        X[        [        U 5      5      nS S S 5        U R                  SSUW5        Ub  X4==   UR                  -  ss'   [        WSS 5      nU(       a  [        R                  " S	S
9n[        R                  " [        R                  " U5      S	5      n	S U	;   a  U	S   =(       d    SU	S   =(       d    S4n	S U;   d  X:  a5  [        S5      n
U R                  XU[        R                   " 5       4-  5        g U R                  SSU5        [#        X5        U[        U'   [$        R'                  U5        U R                  SSU5        [        R
                  " SU5       n[(        R+                  U/ 5       H	  nU" SS9  M     S S S 5        U R                  SSU5        U$ ! , (       d  f       GN= f! , (       d  f       N5= f)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   timedcmrZ   bindrd   elapsedrS   versiontupler   r^   r   warnversionr   r(   append_aftercallbacksget)r   r   r>   loadingtime	shortnamestatsr2   minvercurverextminr   fns               r    loadr      s   y!!T__Y%?%?H		HK9%%FF<7C!K		)9	5T*<b%AB 
6FF<;YN%--/ S,d3F""Q'"":#:#:6#BAF6>Qin1fQin15F6>V_<C GGCfdlln==>FF<CYOB K	
MM)FFBI 
.		:e!%%i4BdO 5 
; FF<=uEJK 
6	5B 
;	:s   H21$I2
I
Ic                   [        [        U    SS 5      nU(       a
   U" U5        gg! [         aM  nUR                  SS9  [        R
                  " U5      nUR                  [        S5      X4-  5         S nAgS nAff = f)NuisetupTforce&   *** failed to set up extension %s: %s
FrS   r)   	Exceptionra   r   r^   r   r   )r   r   r   instr   s        r    _runuisetupr      su    k$'D9G	BK   	LLtL$))$/CGGA@ATKOP		   ' 
A>AA99A>c                   [        [        U    SS 5      nU(       a
   U" U5        gg! [         aM  nUR                  SS9  [        R
                  " U5      nUR                  [        S5      X4-  5         S nAgS nAff = f)NextsetupTr   r   Fr   )r   r   r   r   r   s        r    _runextsetupr     su    {4(*d;H	RL   	LLtL$))$/CGGA@ATKOP		r   c           
     *   [         R                  " [        5      nU R                  S5      nUb  U VVs/ s H  u  pEXA;   d  M  XE4PM     nnnU VVs/ s H  u  pESU;  d  M  XE4PM     nnn[	        [
        5      nU R                  SSU(       a  SOS5        U R                  SS[	        U5      5        [        R                  " S5       nU R                  SS	5      S
   nU HM  u  pU
(       a4  U
SS
 S:X  a+  U	[        ;  a  U R                  SSU	5        U
S
S  [        U	'   M@   [        X	X5        MO     S S S 5        U R                  SS[	        [
        5      U-
  W5        S[        S4/nU R                  SS5        [7        XU5        [9        5       nU R                  SS5        [        R                  " S5       n[
        US   H  n	U R                  SSU	5        [        R                  " SU	5       n[;        X5      (       d$  U R                  SSU	5        UR=                  U	5        S S S 5        U R                  SSX5        X)==   UR>                  -  ss'   M     S S S 5        U R                  SS W5        U R                  SS!5        [        R                  " S"5       n[
        US   H  n	U	U;   a  M  U R                  SS#U	5        [        R                  " S$U	5       n[A        X5      (       d$  U R                  SS%U	5        UR=                  U	5        S S S 5        U R                  SS&X5        X)==   UR>                  -  ss'   M     S S S 5        U R                  SS'W5        U H  n	U R                  SS(U	5        S [B        U	'   M!     U R                  SS)5        [        R                  " S*5       n[D         H8  nU[B        ;   a  M  [D        U    H  nU R                  SS+U5        U" S,S-9  M     M:     S S S 5        U R                  SS.U5        [D        RG                  5         S
S/K$J%nJ&nJ'nJ(nJ)nJ*nJ+nJ,n  U R                  SS05        S1US24S3US44S5US64S7US84S9US64S:US;4S<US=4S>US?4/n[        R                  " S@5       n[7        XU5        S S S 5        U R                  SSAU5        [[        U5       H-  n	U R                  SSBU	[        R\                  " X)   5      5        M/     U R                  SSC5        g s  snnf s  snnf ! [         Ga  n[        R                  " U5      nU
(       a  [        S5      nXX4-  nO[        S5      nXU4-  nUR!                  5       nU R                  SU	5      S
   nUR#                  U5        [        R$                  " UR'                  SS5      5      (       aa  S n[)        U[*        R,                  5      (       a  UR.                  (       a  UR.                  nUc  [        S5      n[*        R0                  " UUS9eU R3                  SU-  5        [)        U[*        R,                  5      (       a8  UR.                  (       a'  U R3                  [        S5      UR.                  -  5        U R5                  5          S nAGM  S nAff = f! , (       d  f       GNl= f! , (       d  f       GN= f! , (       d  f       GNi= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f)DNr      :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   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
ry   loadcmdtabler   loadcolortabler   loadpredicater   loadinternalmerger   r   
loadfilterr   loadfunctionr   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   ra   
_loadextrarj   r   addr   r   r)   r   clear r   r   r   r   r   r   r   r   sorted	timecount) r   	whitelistr   resultr3   r4   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     s9   ))#.K^^M*F'-@vVa&1&v@#);6!T]fqf6F;6{HFF!"
 FF<5s6{C	+	, 11-FqI JD!9$#66(D 
 15QR'-#Rt1 ! 
-\ FF2Fh	 
%67 FF<>?r./UFFF<78	m	$89%DFF<!@$GlD1U"4,,FF$B
 JJt$ 2 FF<!@$N. & 
% FF<3_EFF<89	n	%89%Dv~FF<!A4HmT2e#D--FF$C
 JJt$ 3 FF<!A4O. & 
& FF<4oF
|EtL D 
 FF<BC	&	'5(IK'%i0 F
 %  1	 ) 
( FF<H%P 	 	 	" FF<FG	X~.	u./	Wo6	)%89	FO4	?L9	7	J6	L 
1	2e2. 
3FF< {#
:NN;,-		
 $ FF<89k A;0  # --d3 !F!I !22I !"H II,I-224 11-FqI{+''K(GHHD!$

33		#yy| K   ++id;;GG[I56!$

33		- 0499 <=LLNN9#! 
-	,P 21 
%	$* 32 
&	%. 
(	'^ 
3	2s   S4S4S:"S:	AZ"T .Z87Z;/5Z)$5Z;?[5[5[-A[1=\ ZE=ZZZZ
Z&)
Z83Z;;
[

[[
[.1
\ 
\c                    [         US   HD  n[        U   nU(       d  M  U H)  u  pVn[        XES 5      nUc  M  [        Xg5      " XU5        M+     MF     g N)r(   r)   rS   )	r   r   r   r   r*   objname	loadermod
loadernameextraobjs	            r    r   r     sS    xy!T".:*G
v5H#	.rB /; "r#   c                    U [         ;   a  [         U    SLnU" US9  g[        R                  U / 5      R                  U5        g)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     s>     KY't3""9b188Br#   c           	        [        U 5       H$  u  p[        USS5      nU(       d  M   U" U 5        M&     g! [         aM  nU R                  SS9  U R	                  [        S5      U[        R                  " U5      4-  5         SnAM{  SnAff = f)a9  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+   rS   r   ra   r   r   r   r^   )r   r   r2   hookr   s        r    
populateuir     s      ^	sL$/	H $  	LLtL$GGDE00678 	s   5
BABBc                <   ^ ^ [        T 5      (       d   eUU 4S jnU$ )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                    > T" TU -   0 UD6$ r   r%   )r}   kwargsfuncs     r    closurebind.<locals>.closure  s    dQh&2&&r#   )callable)r   r   r   s   `` r    r   r     s     D>>>' Nr#   c                     UR                   U l         [        US5      U l        [        US5      U l        U R
                  R                  [        US0 5      5        Xl        X l        g! [         a     Naf = f)z.Copy and add some useful attributes to wrapper
__module____doc____dict__N)	__name__AttributeErrorrS   r   r   r  r   	_origfunc_unboundwrapper)wraporigfnunboundwrappers      r    _updatewrapperr	    sj     fl3DO69-DLMMR89N)  s   A( (
A54A5c                   [        U5      (       d   e[        R                  " X5      u  pVU R                  5        H  u  pxXL d  M  Un	  O   US   n
[        R
                  " [        R                  " U5      [        R                  " U
5      5      n[        XU5        Ub  U=R                  U-  sl	        [        U5      nXS'   Ub  US==   U-  ss'   [        U5      U W	'   U$ )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   r   )r   r   findcmdr0   	functoolspartialr   checksignaturer	  r   ri   rk   )tablecommandwrappersynopsis	docstringaliasesentryaliasr{   keyr  r  newentrys                r    wrapcommandr  "  s    : G__W4NGKKM:C "
 1XFG$d&9&9&&AD 4)	!E{HQKxxE#JLr#   c                d  ^^ [         R                  " U5      n[        T5      (       d   eU R                   HY  nXR                  ;   d  M  UR                  U   R
                  m[        T5      (       d   eUU4S jnXCR                  U   l          O   W[        L a  [        SU < SU< S35      eg)zSWraps a filecache property.

These can't be wrapped using the normal wrapfunction.
c                    > T" T/U Q70 UD6$ r   r%   )r   kwargsr  r  s     r    r  wrapfilecache.<locals>.wrapb  s    v7777r#   ztype 'z' has no property ''N)r
   rn   r   __mro__r  r   objectr  )clspropnamer  currclsr  r  s     `  @r    wrapfilecacher$  V  s    
 x(HG;;'''%%h/44FF####8 /3X&+  &hOPP r#   c                  .    \ rS rSrSrSS jrS rS rSrg)	wrappedfunctionil  z3context manager for temporarily wrapping a functionc                    [        U5      (       d   e[        U[        5      (       d.  Sn[        R                  " USSS9  [
        R                  " U5      nXl        X l        X0l	        g )Ns6   pass wrappedfunction target name as `str`, not `bytes`   6.6r   
stacklevel)
r   rh   ro   r   nouideprecwarnr
   rn   
_container	_funcname_wrapper)self	containerfuncnamer  r   s        r    __init__wrappedfunction.__init__o  sT        (C((KCV:x0H#!r#   c                Z    [        U R                  U R                  U R                  5        g r   )wrapfunctionr,  r-  r.  )r/  s    r    	__enter__wrappedfunction.__enter__z  s    T__dnndmmDr#   c                Z    [        U R                  U R                  U R                  5        g r   )unwrapfunctionr,  r-  r.  )r/  exctypeexcvaluera   s       r    __exit__wrappedfunction.__exit__}  s    tFr#   )r,  r-  r.  Nr1  ro   )	r  r   __qualname____firstlineno__r   r2  r6  r<  __static_attributes__r%   r#   r    r&  r&  l  s    =	 EGr#   r&  c                   [        U5      (       d   e[        U[        5      (       d.  Sn[        R                  " USSS9  [
        R                  " U5      n[        X5      n[        U5      (       d   e[        R                  " U 5      (       a  [        R                  " X$5      nO[        X$5      n[        XTU5        [        XU5        U$ )aY  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.
s3   pass wrapfunction target name as `str`, not `bytes`r(  r   r)  )r   rh   ro   r   r+  r
   rn   rS   inspectismoduler  r  r   r	  setattr)r0  r1  r  r   r  r  s         r    r5  r5    s    B Gh$$DCA6??8,Y)FF	""   1 G$4)I&Mr#   c                    [        X5      nUR                  5       nUc  US   nUR                  U5        [        XU5        [	        U5       H  n[        XU5        M     U$ )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.
r   )getwrapperchainpopremoverE  reversedr5  )r0  r1  r  chainr  ws         r    r9  r9    sZ     I0EYY[F(	LLI(e_Y!, Nr#   c                    / n[        X5      nU(       aD  [        U5      (       d   eUR                  [        USU5      5        [        USS5      nU(       a  MD  U$ )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)rS   r   r   )r0  r1  r   r   s       r    rG  rG    sV     F		%B
|||gb"3R89Rd+ " Mr#   c                    SSK n 0 n[        U S5      (       Ga  [        R                  R	                  [
        R                  " [        R                  " U R                  5      5      5      n [        R                  " U5      nU H  nUR                  S5      (       a5  UR                  SS5      S   n[        R                  R                  X$5      nOHUn[        R                  R                  X$S5      n[        R                  R                  U5      (       d  M  XQ;   d  U[        ;   d  US:X  a  M  XaU'   M     ["        R%                  5        H  u  pVU(       d  M  XaU'   M     U$ ! [          a     N8f = f)	zAfind paths of disabled extensions. returns a dict of {name: path}r   N__file__s   .pyr-   r   s   __init__.pys   __init__)hgextrx   r=   r>   dirnamer   abspathr
   fsencoderO  listdirr1   rsplitr@   rA   r(   OSErrorr   r0   )rP  extsextpathfilesr{   r   r>   s          r    _disabledpathsrZ    s&   D uj!!''//LL**5>>:;
	"JJw'E ::f%%88D!,Q/D77<<3DD77<<NCD77>>$// <46>T[5H!T
  *//1
 4J	 2
 K+  		s   +E$ $
E10E1c                <   / nU R                  5       nUSS S:X  d  UR                  5       (       d:  U R                  5       nU(       d  O"USS S:X  a  M#  UR                  5       (       d  M:  USS nUS:X  d  US:X  a  USS nU(       a  UR                  5       R                  U5      (       a-  UR	                  U5      S   nU(       a  UR                  U5        O4U(       d  gUR                  U5        U R                  5       nU(       a  M  OgSR                  U5      $ )	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rstripr1   rR   r   r@   )filer   linestarts       r    
_moduledocrd    s     F==?D
r(d
$**,,}} r(d
$**,,
 !HE%6/ABx{{}%%e,,zz%(+MM$'MM$==?D d 88Fr#   c                     [        U S5       n[        U5      nSSS5        W(       a  [        U5      $ [	        S5      $ ! , (       d  f       N+= f! [         a     gf = f)zBretrieve help synopsis of a disabled extension (without importing)rbN   (no help text available))openrd  rV  r   r   )r>   srcdocs      r    _disabledhelprk  &  sV    $S/C 
 s|,--  s+   A ?A 
A	A A 
AAc                     SSK Jn   U R                  R                  5        VVs0 s H  u  pU[        ;  d  M  U[        U5      _M     snn$ s  snnf ! [        [        4 a     Of = f[        5       nU(       d  0 $ 0 nUR                  5        H9  u  p[        U5      nU(       d  M  US:w  d  M!  [        R                  " U5      XA'   M;     U$ )zCfind disabled extensions from hgext. returns a dict of {name: desc}r   	__index__s	   __index__)rP  rn  docsr0   r(   r   rB   r  rZ  rk  r   	firstline)rn  r   descpathsrW  r>   rj  s          r    disabledrs  4  s    	# (nn224
4
6!  D'$-4
 	
 

 (  E	Dkkm
D!34<'#--c2DJ $
 Ks'   #A AA	A A A&%A&c                    [        5       nX;   a  [        X   5      $  SSKnSSKJn  [	        US5      (       a  gU [
        ;   a  g[        UR                  R                  U 5      5      $ ! [        [        4 a     gf = f)z<Obtain the full help text for a disabled extension, or None.r   Nrm  rO  )rZ  rk  rP  rn  rx   r(   r   ro  r   rB   r  )r   rr  rP  rn  s       r    disabled_helpru  N  st    E}U[))	' uj))v~y~~11$788^, 		s   A) 
A) #A) )A<;A<c              #    #    [         R                  " U /5      nU(       a  UR                  5       n [        U [        R
                  5      (       d'  UR                  [        R                  " U 5      5        M]  U R                   Ho  n[        U[        R                  5      (       d  M$  [        UR                  [        R                  5      (       d  MO  UR                  R                  S:w  a  Mk  Uv   Mq     U(       a  M  gg7f)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todods      r    _walkcommandr  e  s     dV$D
||~$00KK,,T23$$Aa**affchh//vvyyI%G % $s   C;D?Dc                   [         R                  " [        R                  " U 5      U 5      n0 nS[	        [         5      ;  n[        U5       GH2  nUR                  (       d  M  UR                  S   nU(       a  [        U[         R                  5      (       an  [        UR                  [        5      (       a!  [        R                  " UR                  5      nO[        UR                  [        5      (       a  UR                  nOsM  M  [        U[         R                  5      (       a!  [        R                  " UR                  5      nO/[        U[         R                   5      (       a  UR                  nOGM+  S/ S4X&'   GM5     U$ )zmConstruct a dummy command table without loading the extension module

This may raise IOError or SyntaxError.
Bytesr   Nr#   )ry  parser   readfilevarsr  r   rh   Constantvaluero   r
   sysbytesbytesStrsr  )r>   rootry   use_constantr  r}   r   s          r    _disabledcmdtabler  w  s   
 99T]]4($/DH $s)+LT"yyIIaL!S\\**aggs++#,,QWW5D//77D!SWW%%((-Asyy))ssC+ #, Or#   c                <    [        U5      n [        R                  " XU5      u  pgU H  nUR                  U5      (       d  M  Un  O   US   n[        U5      n	XU	4$ ! [        [        4 a     g f = f! [
        R                  [
        R                  4 a     g f = f)Nr   )
r  rV  SyntaxErrorr   r  r	   AmbiguousCommandUnknownCommandr   rk  )
r   cmdr   r>   strictry   r  r  rz   rj  s
             r    _finddisabledcmdr    s    $T* ? <<C 
 aj

Cs [!  ""E$8$89 s"   A A4 A10A14$BBc           	     B   [        5       nU(       d  [        R                  " U5      eSnUR                  US5      nU(       a  [	        XXUS9nU(       d-  UR                  5        H  u  pe[	        XXeUS9nU(       d  M    O   U(       a  U$ [        R                  " U5      e)zTfind cmd from disabled extensions without importing.
returns (cmdname, extname, doc)N)r  )rZ  r	   r  rH  r  r0   )r   r  r  rr  extr>   r   s          r    disabledcmdr    s     E""3''
C99S$Dr&A++-JD"2DvFCs ( 



s
##r#   c                
   0 n[        5        Hr  u  p#[        UR                  5      =(       d    [        S5      nUc   eU (       a  UR	                  S5      S   n[
        R                  " U5      R                  5       X'   Mt     U$ )z+return a dict of {name: desc} of extensionsrg  r-   )r+   r   r   r   rR   r   rp  r_  )r   rW  enamer  rj  s        r    r!   r!     sp    D l
ckk"Da(C&DKK%b)E **3/557 # Kr#   c                 j    [         R                  5        V Vs/ s H  u  pUb  M
  U PM     snn $ s  snn f )z4return short names of extensions that failed to load)r)   r0   )r   r2   s     r    	notloadedr    s)    "-"3"3"5E"5YTD"5EEEs   	//c                z   [        U S5      (       a,  [        U R                  5      (       a   U R                  5       nO [        U S5      (       a  U R                  nOSn[        U[        [        45      (       a  SR                  S U 5       5      nU$ [        R                  " U5      nU$ ! [         a    Sn N[f = f)z8return version information from given module as a string
getversions   unknown__version__r#   r-   c              3  N   #    U  H  n[         R                  " U5      v   M     g 7fr   )r
   bytestr).0r   s     r    	<genexpr> moduleversion.<locals>.<genexpr>  s     AAH,,Q//s   #%)rx   r   r  r   r  rh   ri   rk   r@   r   r^   )r*   r   s     r    moduleversionr    s    v|$$&2C2C)D)D	!'')G 
	'	'$$'D%=))))AAA
 N ))'2N  	! G	!s   B+ +B:9B:c                &    [        U SS 5      nUS:H  $ )N
testedwiths   ships-with-hg-core)rS   )r*   exttestedwiths     r    ismoduleinternalr    s    FL$7M111r#   r   )NNr>  )F)T)?
__future__r   ry  r   r  rD   rC  r=   rI   i18nr   r   r   r   r   r	   r
   r   utilsr   r)   r   r   r(   r   r+   r5   rO   rV   rZ   rd   rl   rw   r   r   r   r   r   r   r   r   r   r   r	  r  r$  r&  r5  r9  rG  rZ  rd  rk  rs  ru  r  r  r  r  r!   r  r  r  r%   r#   r    <module>r     s"   # 
     	 

   	
"(,
" 8
58$0f

y:x	CC*,
*1hQ,G G*5p*"#LB.4.$!H&$2
F
*2r#   