
    6hk                       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	r	S SK
r
S SKJr  SSKJr  S SKJr  SSKJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r$J%r%  SSK&J'r'  SS	K(J)r)J*r*J+r+   " S
 S5      r,S r-S r.S r/S r0S r1S r2S(S jr3S r4S r5S r6S r7 " S S5      r8 " S S5      r9S r:S r;S r<      S)S jr=S r>S  r?S! r@S*S" jrAS# rBS$ rCS% rDS& rES' rFg)+    )annotationsN)Iterable   )_)tracing)cmdutilcolorcommandsconfigdemandimportencodingerror
extensions	fancyoptshelphghook	profilingpycompat	registrarscmutiluiutil)rcutil)procutil
stringutilurlutilc                  6    \ rS rSr       SS jrSS jrSrg)request9   Nc	                    Xl         X l        X0l        X@l        XPl        X`l        Xpl        0 U l        U=(       d    / U l        S U l	        g N)
argsr   repofinfoutferrfmsgearlyoptionsprereposetupscanonical_command)	selfr#   r   r$   r%   r&   r'   r(   r*   s	            4/usr/lib/python3/dist-packages/mercurial/dispatch.py__init__request.__init__:   sL     		 			  +0b "&    c                X   S nU R                   R                  n U(       a%  UR                  5       u  p4n U" U0 UD6  U(       a  M%  Ub  Ueg !   Uc  [        R                  " 5       S   nU R                   R                  S5        U R                   R                  SS9   Nb= f! Ub  Uef = f)Nr   s   error in exit handlers:
T)force)r   _exithandlerspopsysexc_info
warnnoi18n	traceback)r,   exchandlersfuncr#   kwargss         r-   _runexithandlersrequest._runexithandlersZ   s    77((	%-\\^"F2$)&) ( 	 2{!llnQ/GG&&'CDGG%%D%1	 s"   B" A B" ABB" "B))
r#   r+   r)   r'   r%   r(   r&   r*   r$   r   )NNNNNNN)returnNone)__name__
__module____qualname____firstlineno__r.   r=   __static_attributes__ r0   r-   r   r   9   s$     &@r0   r   c                $   S n[        U S5      (       a/  U c   eU R                  c   e U R                  R                  5         [        U S5      (       a  U c   eU R                  c   e UbZ  UR
                  [
        R                  :w  a<  U R                  R                  S[        R                  " UR                  5      -  5        U R                  R                  5         U$ U$ ! [         a  nUnSn S nANS nAff = f! [         a    Sn U$ f = f)Nr&   r'   s
   abort: %s
)hasattrr&   flushOSErrorr'   errnoEPIPEwriter   
strtolocalstrerror)r   errstatuses       r-   _flushstdiorT   l   s    Fr6~~ww"""	GGMMO
 r6~~ww"""		399#;"X%8%8%FF GGMMO M6M%  	CF	  	FM	s*   C$ )A7C? $
C<.C77C<?DDc                 2    [        5         [        R                  " S5         [        [        R
                  SS 5      n SSS5        [        W 5      n[        5         [        R                  " US-  5        g! , (       d  f       N== f! [         a    Sn N9f = f)zrun the command in sys.argvzparse args into requestr   NrH      )	initstdior   logr   r   sysargvdispatch_silencestdioKeyboardInterruptr5   exit)reqrR   s     r-   runr_      sw    
[[23(**12./C 4 #
 HHVc\ 43
   s'    B A6B 6
B B BBc                 z   [         R                  b  S[         R                  R                  S.n [        [         R                  S5      (       a  [         R                  R                  U S'   [
        R                  " [         R                  R                  [         R                  R                  [         R                  R                  40 U D6[         l        [         R                  b  S[         R                  R                  S.n [        [         R                  S5      (       a  [         R                  R                  U S'   [
        R                  " [         R                  R                  [         R                  R                  [         R                  R                  40 U D6[         l
        [         R                  b  [
        R                  " [         R                  R                  [         R                  R                  [         R                  R                  S [         R                  R                  S9[         l        g g )N
)newlineline_bufferingwrite_through)r5   stdoutrc   rI   rd   ioTextIOWrapperbufferr   errorsstderrstdin)r<   s    r-   rW   rW      sp    zz !jj77
 3:://&)jj&>&>F?#%%JJszz22CJJ4E4E
IO

 zz!jj77
 3:://&)jj&>&>F?#%%JJszz22CJJ4E4E
IO

 yy$$IIIIII9933
	 r0   c                     [         R                  [         R                  4 H  n U c  M   U R                  5         M     g ! [         a     Of = f U R                  5         MA  ! [         a     MN  f = fr"   )r5   re   rj   rJ   rK   close)fps    r-   r[   r[      sf    zz3::&:	HHJ '  			HHJ 		s!   ?
AAA""
A0/A0c                2    SR                  S U  5       5      $ )N    c              3  N   #    U  H  n[         R                  " U5      v   M     g 7fr"   r   
shellquote).0as     r-   	<genexpr>_formatargs.<locals>.<genexpr>   s     :TX((++T   #%)joinr#   s    r-   _formatargsr{      s    99:T:::r0   c                    Sn [        U 5      n[        U R                  U5      nU(       a	  U(       d  UnU$ ! [        R                   a  nUnSn SnANESnAff = f)zErun the command specified in req.args; returns an integer status codeNrH   )_rundispatchr   
StdioErrorrT   r   )r^   rQ   rR   rS   rets        r-   rZ   rZ      sY    
Cc"
 cffc
"C
6M  s   7 AAAc                f   [         R                  " S5         U R                  (       a  U R                  nO8U R                  (       a  U R                  R                  nO[        R
                  n U R                  (       d#  [        R                  R                  5       U l        U R                  R                  [        U R                  U R                  5      5        U R                  S   (       a  U R                  R                  SSSS5        U R                  (       a  U R                  U R                  l        U R                  (       a  U R                  U R                  l        U R                  (       a  U R                  U R                  l        U R                  (       a  U R                  U R                  l        [)        U R                  5      n[*        R,                  " 5       nSn [/        U 5      =(       d    Sn[*        R,                  " 5       U-
  nU R                  R?                  5         U R                  R@                  (       ab  US-  U R                  RB                  S'   U R                  R                  "   S0 [D        RF                  " U R                  RB                  5      D6  US-  nU R                  R                  SSUUUUUU RH                  S9   U RK                  5         U R                  R?                  5         UsS S S 5        $ ! [         R"                   a1  nUR%                  UR'                  5       5         S nAS S S 5        gS nAff = f! [         R0                   ao  nU R                  R!                  [3        S	5      U-  5        UR4                  (       a1  U R                  R!                  [3        S
5      UR4                  -  5        e S nAf[6         a  n [9        U[         R:                  5      (       a  [3        S5      nO[3        S5      nU R                  R!                  U5        O%! [         R:                   a     O[<         a     Of = fSn S nAGNgS nAff = f!   U=(       d    Sn GN= f! [*        R,                  " 5       U-
  nU R                  R?                  5         U R                  R@                  (       ab  US-  U R                  RB                  S'   U R                  R                  "   S0 [D        RF                  " U R                  RB                  5      D6  US-  nU R                  R                  SSUUUUUU RH                  S9   U RK                  5         O!   U=(       d    Sn O= fU R                  R?                  5         f = f! , (       d  f       g = f)Nzdispatch._rundispatch	   traceback   ui   on   --tracebackrH   r   r   s   ** ProgrammingError: %s
s   ** (%s)
s   killed!
s   interrupted!
i  s   command_durationrV   s   commandfinishs!   %s exited %d after %0.2f seconds
)return_codedurationr+   )s	   uiblockeds   ui blocked ms
)&r   rX   r'   r   r   rj   uimodloadr)   update_earlyparseoptsr#   	setconfigr%   r&   r(   r   AbortrN   formatr{   r   timer	_runcatchProgrammingErrorr   hintr\   
isinstanceSignalInterruptBrokenPipeErrorrJ   logblockedtimes_blockedtimesr   	strkwargsr+   r=   )	r^   r'   instformattedargs	starttimer   msgr   r   s	            r-   r}   r}      s   	,	-8888DVV66;;D??D	66##OCFFCHH$EF-  e^L ww WW
xx!hhxx!hhxx!hh
 $CHH-JJL	/	C.%AC* zz|i/HFFLLNvv%%<DtO$$%89

 & (()=)=>
 )KFFJJ 5'!"%"7"7  	 $$& FFLLN_ 
.	-0 {{ 	JJt{{}%5 
.	-0	 %% 	FFLL784?@yyQ|_tyy89  	dE$9$9::L/C-.CS!((  " C	J iR/ zz|i/HFFLLNvv%%<DtO$$%89

 & (()=)=>
 )KFFJJ 5'!"%"7"7  	 $$& iRFFLLN] 
.	-s   AV"/EL>,V"+M?CV"Q..V"M'MV"MV"Q+/A*OQ+'AP98Q&9QQ&	QQ&QQ& R&Q++R.Q>;V"CV!U21V2V	? VV""
V0c                @  ^ ^ [         R                  " S5         S nT R                  m S H3  n[        [        US 5      nU(       d  M  [        R                  " X15        M5     U U4S jn[        TU5      sS S S 5        $ ! [
         a     N(f = f! , (       d  f       g = f)Nzdispatch._runcatchc                 "    [         R                  er"   )r   r   rz   s    r-   	catchterm_runcatch.<locals>.catchtermJ  s    '''r0   )SIGBREAKSIGHUPSIGTERMc                   > S n  [         R                   " TR                  S S  [        R                  0 5      nUS   n[        R
                  " U[        R                  S5      u  p4US   n U S:X  a  SW;   a  SnSU;   nU(       a  US-  n[        TR                  5      U:w  dv  TR                  S   S:w  dc  TR                  S   R                  S	5      (       d@  TR                  S
   S:w  d-  TR                  S   S:w  d  U(       aT  TR                  S   S:w  aA  [        R                  " [!        S5      ["        R$                  " TR                  5      4-  5      e SnS[&        R(                  0nS[&        R*                  0n	[-        TR.                  [0        R2                  TR4                  S   5      n
[7        TR.                  TR4                  S   5      nTR8                  (       aa  U
 H*  u  ppTR8                  R.                  R;                  XXS9  M,     U H+  u  pnTR8                  R.                  R;                  XUSS9  M-     TR=                  SS5      n[&        nU(       a  TR?                  5       (       a  SnORTR4                  S   (       a>  [@        RB                  " 5           [E        [0        RF                  " U5      5      nS S S 5        UR(                  X'   UR*                  X'   TR4                  S   (       ao  TRK                  [!        S5      5        US:w  a(  X   US   :X  a  TRK                  [!        S5      U-  5        [@        RB                  " 5          X   " 5         S S S 5         [M        T5      TRO                  5         $ ! [        R                  [        R                  [        [        R                  4 a     GN\f = f! [H         a     GNf = f! , (       d  f       GN= f! , (       d  f       N= f! TRO                  5         f = f!   TR4                  S   (       a6  [P        RR                  " 5         W	W   " [T        RV                  " 5       S
   5        e = f)Nr   Fs   serves   --stdio   s   --hiddenr   s   -R   --      s/   potentially unsafe serve --stdio invocation: %ss   pdb   config_file   config)source   --configr      debuggersA   entering debugger - type c to continue starting hg or h for help
s3   %s debugger specified but its module was not found
),r   r#   r
   
globaloptsr   findcmdtabler   UnknownCommandAmbiguousCommand
IndexErrorgetoptGetoptErrorlen
startswithr   r   r   pprintpdb	set_tracepost_mortem_parse_config_filesr   r   rY   r)   _parseconfigr$   r   r   plainr   deactivated
__import__sysstrImportErrorwarn	_dispatchrJ   r8   	print_excr5   r6   )realcmdcmdargscmdaliasesentrynbargshashiddenaccessdebugger
debugtracedebugmortem	file_cfgscfgssecnamevalr   debugmodr^   r   s                    r-   _runcatchfunc _runcatch.<locals>._runcatchfuncV  s   G#--HHQK!4!4b aj!(hnne!L!!* ("zW'< "-"8"aKFMV+xx{e+xx{--e44xx{h.xx{j0&{2++LM%,,SXX689 
L!$cmm4
%s7 0FFH,,c.>.>~.N	 $CFFC,<,<Y,GH88 3<.3--c-L 3< +/3--s; .  +/ 99UK8288::%H%%k2 &113!'1(//(2K'LH 4 (0'9'9
$(0(<(<% ##K0GGN !F*&0Jv4FF!B '	' &113",. 4$S>HHJW $$&&""	 
 
Z  + ! ! 43: 43
 HHJ##K0''))#,,.*;<s   A%N EP 'O)O
BP 
O-'P 0
O> :P 8OO

OOOO
O*%P -
O;7P >PP AQ )r   rX   r   getattrsignal
ValueError
_callcatch)r^   r   r   numr   r   s   `    @r-   r   r   G  s    	)	*	( VV	7fdD13MM#1 8{	z "m,W 
+	*  		 
+	*s4   BA?	A?#B?
B	BBB
Bc                $   Sn [         R                  " X5      $ ! [        R                   aO  nSnU R	                  [        S5      UR                  SR                  UR                  5      4-  5         SnAGOSnAf[        R                   a  nSnUR                  (       a  U R                  S5        [        R                  " UR                  5      nU R	                  [        S5      UR                  U4-  5        [        R                   " XR                  SS	S
9   SnAGOU R	                  [        S5      UR                  -  5        U R	                  [        S5      5         SnAGOSnAf[        R"                   GaM  nSn[        S5      UR                  -  n [$        R&                  " U [        UR                  S	S9nU R	                  U5        U R)                  U5         SnAGO! [        R"                  [        R*                  4 a    SnUR,                  (       am  [        R.                  " UR,                  UR                  5      nU(       a;  U R	                  U5        U R	                  S[        R0                  " U5      -  5        S	nU(       d+  U R	                  U5        U R	                  [        S5      5          SnAO3f = fSnAf[2         a    e [4         a    e   [7        U 5      (       d  e  O= fU R9                  SS5      (       a  U$ g)zlike scmutil.callcatch but handles more high-level exceptions about
config parsing and commands. besides, use handlecommandexception to handle
uncaught exceptions.
rH   
   s&   hg: command '%s' is ambiguous:
    %s
rp   N   helps
   hg %s: %s
FT)fullcommands   hg: %s
s0   (use 'hg help -v' for a list of global options)
s   hg: unknown command '%s'
)
unknowncmds   (%s)
s'   (use 'hg help' for a list of commands)
r   s   detailed-exit-code)r   	callcatchr   r   r   r   prefixry   matchesCommandErrorr   pagerr   bytestrmessager
   help_r   r   formattedhelprN   r   all_commands
getsimilarsimilarity_hintrK   r\   handlecommandexception
configbool)	r   r;   detailed_exit_coder   msgbytesnocmdmsg	formatted	suggestedsims	            r-   r   r     sf   
 .  **!! 

9:{{DIIdll345	
 	
  	M<<HHW''5HGGAn%x(@@ANN2||%FFGGAkNT\\12GGAJKLL H23dllB	H **HdlltI GGHHHY$$ekk2 
	HI  &&t'8'8$,,GGGH%GGI(=(=c(BBC $I!EFG
	H   %b)) * 
}}U122!!sU    K5AA88K5BE)"AE))K5K	AG))CK?K	KK		*K5c                x  ^^ / n[        U S5      (       d  [        U SU5      nU(       a  SR                  [        [        R
                  U5      5      n/ mUU4S jn[        R                  " SXC5      n[        T5       VVs/ s H  u  pVUT;  d  M  UPM     snnm[        R                  " U5      nUT-   $ s  snnf )N	_origfuncr#   rp   c                   > [        U R                  S5      5      S-
  nTR                  U5        U[        T5      :  a  TU   $ [        R
                  " [        S5      5      e)Nr   s#   too few arguments for command alias)intgroupappendr   r   
InputErrorr   )mr   	givenargsnumss     r-   replaceraliasargs.<locals>.replacer  sR    aggaj/A%CKKS^# ~%""1%K#LMMr0   
   \$(\d+|\$))rI   r   ry   mapr   rs   resub	enumerater   
shlexsplit)fnr   r#   r   r   ixr   s    `     @r-   	aliasargsr    s    D2{##r64(iiH//67	N ff^X3#,Y#7I#7411D=Q#7I	""3') Js   B6B6c                  ^ [        U5       VVs0 s H  u  p4SUS-   -  U_M     snnmU TS'   STS'   SR                  U5      TS'   SR                  S U 5       5      TS	'   S
R                  TR                  5       5      R                  SS5      n[        R
                  " U5      nUR                  U4S jU5      $ s  snnf )zPinterpolate args into cmd for shell aliases

This also handles $0, $@ and "$@".
s   $%dr   s   $0   $s   $$rp   s   $@c              3  N   #    U  H  n[         R                  " U5      v   M     g 7fr"   rr   )rt   args     r-   rv   #aliasinterpolate.<locals>.<genexpr>8  s     #MH$7$7$<$<rx   s   "$@"   |s   \$c                *   > TU R                  5          $ r"   )r   )r
  
replacemaps    r-   <lambda>"aliasinterpolate.<locals>.<lambda><  s    :aggi0r0   )r  ry   keysreplacer  compiler  )r   r#   r   r	  r  regexrr  s          @r-   aliasinterpolater  )  s     7@oFoFA&AE"C'oFJJuJu		$Ju
 ))#M#MMJwIIjoo'(00v>E


5A550#66 Gs   B=c                  @    \ rS rSrS rS	S jr\S 5       rS rS r	Sr
g)
cmdaliasi?  c                D  ^ ^ U=T l         T l        ST l        UT l        S T l        / T l        / T l        ST l        S T l        ST l	        UT l
         [        R                  " T R                   U5      u  pgUR                  5        H  u  pXL d  M  UT l          O   ST l        T R                  (       d  [#        S5      T R                   -  T l        g T R                  R%                  S5      (       aI  T R                  SS  mST l        U U4S jn
U
T l        ST l        T R+                  XTT R                  5        g  [,        R.                  " T R                  5      n[7        U5      u  pU(       aC  [#        S	5      T R                   S
R9                  [,        R:                  " U6 S   5      4-  T l        g UR=                  S5      =T l        nUT l         [        R                  " XS5      S   n[?        U5      S:  a  Uu  T l        T l        nOUu  T l        T l        S nST l        T R+                  XUT R                  U5        g ! [        R                    a    ST l         GNf = f! [0         a=  n[#        S5      T R                   [2        R4                  " U5      4-  T l         S nAg S nAff = f! [        R                    a)    [#        S5      T R                   U4-  T l        ST l	         g [        R@                   a"    [#        S5      T R                   U4-  T l         g f = f)Nr0   FTs   no definition for alias '%s'   !r   c                   >^ ^ SSR                  TR                  4T-   5      0nUUU 4S jn[        R                  " SUT5      n[	        TR                  TU5      nT R                  XBSTR                  -  S9$ )Ns   HG_ARGSrp   c                :  > U R                  5       S   S:X  a  U R                  5       $ [        U R                  5       S   5      [        T5      ::  a  U R                  5       $ TR	                  S[        U R                  5       S   5      TR
                  4-  5        g)Nr   r  sL   No argument found for substitution of %i variable in alias '%s' definition.
r0   )groupsr   r   r   debugr   )r   r#   r,   r   s    r-   	_checkvar0cmdalias.__init__.<locals>.fn.<locals>._checkvara  s    xxz!}, wwy(QXXZ]+s4y8 wwy(J"188:a=1499=>
  #r0   r  s   alias_%s)environ
blockedtag)ry   r   r  r  r  system)r   r#   envr$  r   r,   shdefs   ``   r-   r  cmdalias.__init__.<locals>.fn^  sp    !499dii\D-@#AB# ff^Y>&tyy$<yytyy1H !  r0   s&   error in definition for alias '%s': %ssL   error in definition for alias '%s': %s may only be given on the command line   /r   r   s+   alias '%s' resolves to unknown command '%s's-   alias '%s' resolves to ambiguous command '%s')!r   r   cmdname
definitionr  r   optsr   badaliasr   r   r   r   itemsshadowsr   r   r   r   shellalias_populatehelpr   r  r   r   forcebytestr_earlysplitoptsry   ziplistr4   r   r   )r,   r   r   r.  cmdtabler   r   r   r4  rS   r  r#   r   	earlyoptsr   
tableentrycmdhelpr*  s   `                @r-   r.   cmdalias.__init__@  s   ##	DH$			!$__TYYANG$NN,:$DH -  DL =>JDM??%%d++OOAB'EDJ, DGDJr8	&&t7D *$/	5 DIIh&6&6	&B1&EFGHDM !XXa[(s	 >qAJ:".8+G%/"DJrdggw?C ## 	! DL	!P  	GH		''-L DM 	6 ## 	#> 		DM #DO%% 	@ 		DM	sI   :I I : I$ A0J. I! I!$
J+.3J&&J+.:L*2LLNc                   0 nS HT  nUR                  SSX'4-  S 5      nUc  M  [        R                  " U5      (       d  [        S5      X'4-  U l          g XU'   MV     UR                  SU=(       d    S5      U l        U R                  (       aC  U R                  R                  SU-   5      (       a   U R                  S[        U5      -   S  U l        S	U;   U l	        UR                  S	[        R                  " U5      5      n	U	b  [        R                  " U	5      n	Xl        UR                  S
[        R                  R                   5      U l        g )N)   docr      category   aliass   %s:%ss/   non-ASCII character in alias definition '%s:%s'r   r0   s   hg r   r?  r@  )r   r   
isasciistrr   r0  getr   r   r   owndocr   getdocr   __doc__r   r   CATEGORY_NONEhelpcategory)
r,   r   r   r   r  defaulthelpcfgkvdocs
             r-   r5  cmdalias._populatehelp  s   /A		(Hy$8$?Ay&&q)) !F!I! F 0 GGG[%7C8	99--fsl;;		!c#h,.1DImggfhoob12?//#&CGG**88
r0   c                    [         R                  " [        R                  U R                  5      n[        U R                  U5      $ r"   )r   maplistr   
expandpathr   r  r  )r,   r#   s     r-   r#   cmdalias.args  s-    @$''r0   c                    S[        5       SSS.nX;  a  [        U5      eU R                  (       d  [        U S5      (       a  X!   $ [	        U R
                  U5      $ )NTF)norepointentsoptionalrepo	inferrepor3  )setAttributeErrorr0  rI   r   r  )r,   r   	adefaultss      r-   __getattr__cmdalias.__getattr__  sV    u!	
	   &&==GD'22?"tww%%r0   c                T   U R                   (       ag  S nU R                  (       a5   [        R                  " XR                  5      S S u  pV[        S5      XV4-  n[        R                  " U R                   US9eU R                  (       a*  UR                  SU R                  U R                  4-  5        UR                  SSU R                  U R                  5        [        U S5      (       a  U R                  " U/UQ70 UD6$  [         R"                  " U R                  5      " U/UQ70 UD6$ ! [        R                   a     Nf = f! [        R$                   aK    SR'                  U R                  /U R(                  -   5      nUR                  SU R                  U4-  5        e f = f)	Nr   s"   '%s' is provided by '%s' extensionr   s    alias '%s' shadows command '%s'
s   commandaliass   alias '%s' expands to '%s'
r3  rp   )r0  r   r   disabledcmdr-  r   r   r   ConfigErrorr2  r#  r   rX   r.  rI   r  r   checksignatureSignatureErrorry   r#   )r,   r   r#   r/  r   r   exts          r-   __call__cmdalias.__call__  sh   ==D)55b,,GKHCBCsjPD ##DMM==<<HH4		4<<7PP 	+IIOO		
 4!!772----**4773BFFFF% ++ & '' yy$,,$))!;<8DIIt;LLMs   4D. )E .EEAF')rF  r4  r0  r   r-  r.  r  r   r   rH  r   r/  rD  r2  r3  r   r   r"   )rA   rB   rC   rD   r.   r5  propertyr#   r[  rd  rE   rF   r0   r-   r  r  ?  s,    dL
: ( (&r0   r  c                  T    \ rS rSrSrS r\R                  S 5       rS r	S r
S rSrg	)
lazyaliasentryi  z<like a typical command entry (func, opts, help), but is lazyc                l    Xl         X l        X0l        UR                  5       U l        XPl        SU l        g )NT)r   r   r.  copyr9  r   r4  )r,   r   r   r.  r9  r   s         r-   r.   lazyaliasentry.__init__  s*    	$ 
r0   c                    [        U R                  U R                  U R                  U R                  U R
                  5      $ r"   )r  r   r   r.  r9  r   r,   s    r-   	_aliasdeflazyaliasentry._aliasdef  s.    GGTYY
 	
r0   c                ~    U R                   nUS:X  a  U$ US:X  a  UR                  $ US:X  a  UR                  $ [        e)Nr   r   r   )rn  r/  r   r   )r,   naliasdefs      r-   __getitem__lazyaliasentry.__getitem__  s?    >>6O!V== !V== r0   c              #  <   #    [        S5       H	  nX   v   M     g 7fNr   )range)r,   r	  s     r-   __iter__lazyaliasentry.__iter__  s     qA'M s   c                    grv  rF   rm  s    r-   __len__lazyaliasentry.__len__  s    r0   )r4  r9  r.  r   r   r   N)rA   rB   rC   rD   rF  r.   r   propertycachern  rs  rx  r{  rE   rF   r0   r-   rh  rh    s3    F 

 

	r0   rh  c                    U R                  SSS9 H>  u  p# X   R                  U:X  a  M   U R	                  SU5      n[        XX1U5      nXQU'   M@     g ! [        [        4 a     N:f = f)NrA  T)	ignoresub)configitemsr.  KeyErrorrY  configsourcerh  )r   r9  r4  r.  r   r   s         r-   
addaliasesr    s|      ^^H^E	))Z7 8 51r*G F .) 		s   AA'&A'c                <   0 n0 n [         R                   " U[        R                  U5      nU(       a  US   USS  p[        R                  " U[        R                  U R                  SS5      5      u  pgUS   n[        US   U5      nU R                  SU5      nU(       a<  [        R                   " ["        R$                  [        R&                  " U5      5      U-   n[)        US   5      n	OS n/ n	S n
[        R                   H.  nU
" US   5      nU	R+                  US   US   X,   US   45        M0      [         R                   " XUSS	9n[        R                   H  nU
" US   5      nX=   X-'   X=	 M     XU=(       a    WS   =(       d    S XU4$ ! [        R                   a0  n[
        R                  " S [        R                  " U5      5      eS nAff = f! [        R                   a0  n[
        R                  " U[        R                  " U5      5      eS nAff = f)
Nr   r   r      stricts   defaultsc                &    U R                  SS5      $ )N   -   _)r  )opt_names    r-   global_opt_to_fancy_opt'_parse.<locals>.global_opt_to_fancy_optF  s     d++r0   r   T)gnu)r   r
   r   r   r   r   r   r   r6  r   r   r   r   r  r   r   rP  r   rQ  r  listr   )r   r#   options
cmdoptionsr   r   r   r   defaultscr  or   rq  s                 r-   _parser  +  s   GJF""4)<)<gF GT!"XT ui!@
 ajq4(99[#.  (2E2Eh2OP  qN,   &qt,
 	
!A$!gmQqT23 !E""4JDA
   #AaD)]
M !
 !q)T4*EE_  F  z'>'>t'DEEFL  E  j&=&=d&CDDEs/   &F 6G G$+GGH++HHc                   / nU Hm  n S UR                  SS5       5       u  pEUR                  SS5      u  pdU(       a  U(       d  [        eU R                  XdUS5        UR                  XdU45        Mo     U$ ! [        [        4 a7    [
        R                  " [        S5      [        R                  " U5      -  5      ef = f)z0parse the --config options from the command linec              3  @   #    U  H  oR                  5       v   M     g 7fr"   )strip)rt   cfgelems     r-   rv   _parseconfig.<locals>.<genexpr>i  s     M:Lw==??:Ls      =r      .r   s?   malformed --config option: %r (use --config section.name=value))
splitr   r   r   r   r   r   r   r   r   )r   r   configsrJ  r   valuesections          r-   r   r   c  s    G	M#))D!:LMKD JJtQ/MG$  LL{;NNG512 " N J' 	""9 ""3'	( 	s   A)A88AB?c                d   / n[         R                  " 5       nU H  n UR                  U5        M     UR                  5        H[  nUR                  U5       HC  n	U	S   n
U	S   nUR                  X5      nU R                  XX5        UR                  XX45        ME     M]     U$ ! [        R                   a:  n[        R
                  " [        S5      UR                  -  UR                  S9eSnAf[         a5    SnSU;   a  [        S5      n[        R
                  " [        S5      U-  US9ef = f)	zparse the --config-file options from the command line

A list of tuples containing (section, name, value, source) is returned,
in the order they were read.
s#   invalid --config-file content at %sr^  Ns   --cwds/   this file is resolved before --cwd is processeds#   missing file "%s" for --config-filer   r   )	configmodr   readr   r`  r   r   locationr   FileNotFoundErrorsectionsr1  r   r   r   )r   r   config_filesr  rJ  filerS   r   r  itemr   r  srcs                r-   r   r   {  s%    8:G



C	HHTN " <<>IIg&D7DGE**W+CLL3NNG567 ' " N/    	""89AJJFYY  ! 	D7"KL""89D@t 	s   B$$D/85C--AD/c           	         0 n[         R                   " U[        R                  UU R                  S5      (       + SSS/0S9  U$ )Ns   strictflagsT
   repository   repo)r  early
optaliases)r   r
   r   r   )r   r#   r  s      r-   r   r     sG    G((!G9- Nr0   c                <    Sn/ SQn[         R                  " XUSSS9$ )zCSplit args into a list of possible early options and remainder argss   R:)s   cwd=s   repository=s   repo=s   config=s   config-file=T)r  keepsep)r   earlygetopt)r#   shortoptionslongoptionss      r-   r7  r7    s,    LK   KT4 r0   c	                H   [         R                   " U USU-  SSR                  U5      UUS9   [        XEX&5      n	[         R                   " U USU-  SSR                  U5      U	UUS9  U	$ ! [         a.    [         R                   " U USU-  SSR                  U5      UUS9  e f = f)	Ns   pre-%sTrp   )r#   patsr/  s   post-%sF)r#   resultr  r/  s   fail-%s)r   ry   _runcommand	Exception)
luir$   r   fullargsr   r  dcmdpatsr  r   s
             r-   
runcommandr    s    IICYYx "s.		8$		
, J  		8$	
 	s   9A) )8B!c                z    [         R                  " 5       nSnUc  UnOUn[        R                  " U5        [        R                  " U5      =(       d    SnU(       d  U nOaU R                  5       n[        R                  " 5       (       a7  [        R                  " U5       H  u  pn
U	S:X  d   eUR!                  XS9  M     U(       a  ["        R$                  " Xq5      nUR&                  nU R                  5       n[        R                  " 5       (       a7  [        R                  " U5       H  u  pn
U	S:X  d   eUR!                  XS9  M     U(       a  [        R                  " U5        Xg4$ ! [         aE  n[        R                  " [        S5      [         R                  " UR                  5      -  5      eSnAff = f)zhReturn (path, local ui object) for the given target path.

Takes paths in [cwd]/.hg/hgrc into account."
s+   error getting current working directory: %sNr0   s   path)root)r   getcwdrK   r   r   r   rO   rP   oschdirr   findreporj  r   use_repo_hgrcrepo_components
readconfigr   get_clone_path_objrawloc)r   rpathwdcwdrS   oldcwdpathr  __c_typerc_pathpath_objs               r-   	_getlocalr    sp   

oo F	z
B&3Dggi!!'-'='=d'C#G(((w2 (D  --c9ggi!!'-'='=d'C#G(((w2 (D 
9Q  
kk<=!!!**-.
 	

s   E+ +
F:5A F55F:c                  ^ ^^^^	^
^ 0 m [         R                   " T[        R                  T5      mT(       d  g[        R
                  nTS   m TR                  SS5      n[        R                  " TX45      u  pVUS   mUS   m
T(       a3  [        T
S5      (       a!  [        T5      u  nmUU
U4S jm	UUU	U UU4S j$ gg! [        R                   a     gf = f! [        R                  [        R                  4 a     gf = f)z=Return the function to run the shell alias, if it is requiredNr   r   r  r3  c                    > T" T/T SS  Q76 $ Nr   rF   )r#   r  r   s   r-   r  "_checkshellalias.<locals>.<lambda>6  s    Br%DH%r0   c                 0   > [        TS TT S S TTT/ 0 5	      $ r  )r  )r#   r   r  r  r  r   s   r-   r  r  7  s#    zsD!Hb'1b"
r0   )r   r
   r   r   r   r   r   r   r   r   r   r   rI   r7  )r  r   r#   r9  strictr   r   
_earlyoptsr   r  r  r  s   ```     @@@@r-   _checkshellaliasr    s    G""4)<)<gF ~~H
q'Cui0 h? !*C	qB
wr7##*40
D%
 
 	
	 $s%   ""E$8$89 s#   &B? +C ?CC$D ?D c                  ^^^ ^!^"^# U R                   mU R                  m#U R                  S   nU(       a  [        R                  " U5        U R                  S   n[        T#U5      u  p4T#U1nU R                  (       a%  UR                  U R                  R                  5        U R                  S   (       d(  U R                  S   (       d  U R                  S   (       aT  S HN  n[        R                  " [        U R                  U   5      5      nU H  nUR                  SXgSU-   5        M     MP     U R                  S	   (       a  U H  nUR                  S
SSS5        M     O=U R                  S	   SL a+  UR                  S
S5      (       a  UR                  S
SSS5        UR                  S
S5      n	[        R                  " XIS9 n
[        R                   " U5        UR"                  T#l        [%        U[&        R(                  5        [+        UT#T5      nU(       a/  U H  n[        R,                  " U5        M     U" 5       sS S S 5        $ UR/                  SS5      nU(       a  U[0        l        Tn [5        UT5      u  nmmnnXl(        US   U R                  S   :w  a  [6        RL                  " [O        S5      5      eUS   U R                  S   :w  a  [6        RL                  " [O        S5      5      eUS   U R                  S   :w  a  [6        RL                  " [O        S5      5      eUS   U R                  S   :w  a  [6        RL                  " [O        S5      5      eUS   U R                  S   :w  a  [6        RL                  " [O        S5      5      eUS   (       a  US   [0        l        US   (       a  US   [0        l)        US    (       a#  S! m T " 5       m!U U!U#4S" jnT#RU                  U5        US	   (       a  U
RW                  5         US   (       d  US   (       d
  US   (       a`  S HZ  nX   U R                  U   :X  a  M  [        R                  " [        X   5      5      nU H  nUR                  SXgSU-   5        M     M\     US#   (       a  U H  nUR                  SS#S$S%5        M     US&   (       a  U H  nUR                  SS'S(S)5        M     URY                  S*S5      (       a  U H
  nS+Ul-        M     US,   nU H4  nU(       a  UR                  SS,US-5        [\        R^                  " U5        M6     [`        Rb                  " US.   5      (       a  T#Re                  S/U-   5        O"US.   S0:w  a  U H  nURg                  5         M     U H  n[        R,                  " U5        M     US1   (       a  [&        Rh                  " T#5      sS S S 5        $ US2   (       a   [&        Rj                  " T#XS LS39sS S S 5        $ U(       d   [&        Rj                  " T#S45      sS S S 5        $ S nTS S  nTc   eTRl                  (       GdY  U(       d  U(       d  U R                  nU(       am  T#Rn                  UR                  l7        T#Rp                  UR                  l8        T#Rr                  UR                  l9        T#Rt                  UR                  l:        O [v        Rx                  " T#UU Rz                  TR|                  S59nUR                  5       (       d"  [6        RL                  " [O        S65      U-  5      eUR                  R                  S7S8UR                  S95        U(       a&  UR                  m#US=   (       a  UR                  5       nTR                  S:U5        O!U(       a  T#R                  [O        S>5      5        [        U5      nT#R                  S?S@U5        [        R                  " U5      m"UUU"U#4SA jn [        UUXT#UUUU5	      U(       a   UU R                  :w  a  UR                  5         sS S S 5        $ ! [6        R8                   Ga  nUR:                  n[=        U[>        R@                  5      (       a  URB                  (       a  SRE                  URB                  5      (       a  URB                  RG                  S5      n[&        RH                   Vs1 s H  nUS   iM
     Os  snf nnU Vs/ s H  nURE                  U5      (       d  M  UPM     Os  snf nn[K        U5      S:w  a  [6        RL                  " [O        S5      5      ee S nAff = f! [6        R                   a    e [6        R                   a    U(       a  e TR                  (       d  TR                  (       a  T(       a  U(       d  [        R                  " [        R                  T5      nUS:   nU(       aO  UR                  U5      [K        U5      :X  a1  S;U/U-   U l         UU R                  S'   [        U 5      s sS S S 5        $ U(       d5  [6        RL                  " [O        S<5      [0        R                  " 5       -  5      ee  GNf = f! U(       a"  UU R                  :w  a  UR                  5         f f f = f! , (       d  f       g = f)BNs   cwdr     verbose   debug   quiet)r  r  r  r   r   s   profiles	   profilings   enableds   trues	   --profileFs   falses   --no-profile)enableds   fallbackencodingr   zlatin-1r   s&   option --config may not be abbreviatedr   r   s+   option --config-file may not be abbreviateds#   option --cwd may not be abbreviatedsr   option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repor   s(   option --debugger may not be abbreviateds   encodings   encodingmodes   timec                     [         R                  " 5       n U S   S:X  a&  U S   U S   U S   U S   [        R                  " 5       4n U $ )Nr   g        r   r   r   r   )r  timesr   r   )ts    r-   	get_times_dispatch.<locals>.get_times  sC    HHJQ43;1qtQqT1Q4>Ar0   c            
        > T" 5       n TR                  [        S5      U S   TS   -
  U S   TS   -
  U S   TS   -
  U S   TS   -
  U S   TS   -
  4-  5        g )Ns4   time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)
r   r   r   r   r   )r   r   )r  r  sr   s    r-   
print_time_dispatch.<locals>.print_time  st    KNO!qt!qt!qt!qt!qt	r0   r   r   r   s   noninteractives   interactives   offs   -ys   insecureTs   colors   --colors   pagers   internal-always-s   autos   versionr   )r   s	   shortlist)r  presetupfuncsrU  s   repository '%s' is not locals   bundles   mainreporootr  r   s   --repositorys+   no repository found in '%s' (.hg not found)s   hiddens   warning: --repository ignored
s   commands   %s
c                 D   > [         R                  " T5      " T/T Q70 TD6$ r"   )r   ra  )r#   r;   	strcmdoptr   s   r-   r  _dispatch.<locals>.<lambda>9  s    D''-bE4E9Er0   )Sr#   r   r)   r  r  r  r$   addr   r   boolr   r   r   profiler   loadall	__class__r  r
   r   r  
populateuir   r   fallbackencodingr  r   r   __context__r   r   r   optr   encoder   r   r   r   r+   encodingmodeatexitstartrC  insecureconnectionsr	   setupr   	parseboolr   disablepagerversion_r   rT  r%   r&   r'   r(   r   
repositoryr*   rU  localr  RequirementError	RepoErrorrV  rW  rP  r   r  countr   r  
unfilteredinsertr   r{   rX   r   r  rm   )$r^   r  r  r  r  uisr  r   ui_r  profilershellaliasfnfallbackr  r   r  r  rS   causer  all_longpossibler  coloroptr$   r  reposguessr   r  r#   r;   r  r  r  r   s$                                 @@@@@@r-   r   r   <  s   88D	B 

6
"C

]+E"e$IDs)C
xx 	$H%H%3C""4(8(8(=#>?CeSus{;  4
 
#CMM,
G\J 			*	%	. >>,
33
 MM,
HoNnn\:6G			3	0H 	3}} 	3' (R6%%c* >) 
1	0. ::e%89(0H%	39#t3D0CtWj" !$9!1!1)!<<""1%N#OPP>"c&6&6~&FF""@A  6?c..v66""1%K#LMM=!S%5%5m%DD""O  ;3#3#3K#@@""=> 
 ; ' 4H?#$+O$<H!7 A IIj!:NN :'("3wx7H7<3#3#3C#88&&tGL'9:CMM%53;? 	 8 < e\5.I  $%e^VUC  >>+u--*.' 
 8$CeXxDKK 
  122HH(3./X')  "  C!!#&  :$$R(] 
1	0^ 7>>"cd?Ca 
1	0b >>"l3e 
1	0h q'{{{xx ff!ww!ww!ww$==!&)&7&7 $	D  ::<<#..=>E  GG%%!?DIIw4 WW9%??,DKK4 GGA89:(#
z7C(&&z2	E	T3"gq': (

u 
1	0< !! 	MME%!3!34499!4!4UYY!?!?))**95C.6.A.AB.A!.ABHB+3I8aq||C7H8IHI8})#..GH  	f --  ,,>>d4$,$4$4W5E5Et$LE$)!HE$U);s5z)I,;U+Ch+NBG 0 0 ?'0~ 5} 
1	0~  $"'"2"2 !%=!" #+//"3	!4#  # -L (

 )ts 
1	0s   A;j1&j13aMj1 j1j1+B,j1B
e"Bj1j'j1eB	e!c10e<d!d! 7eej1Cj 4j1?=j <j1?j  j1+j..j11
j?c                     [         R                  " SU-  5         U" 5       sSSS5        $ ! , (       d  f       g= f! [        R                   a!    [        R                  " U[        S5      5      ef = f)z8Run a command function, possibly with profiling enabled.zRunning %s commandNs   invalid arguments)r   rX   r   rb  r   r   )r   r  r   cmdfuncs       r-   r  r  C  sW    ?[[-349 544 ?  a(<&=>>?s   = ,	= 
:= = 5A2c                   [         R                  " SS9nSUSS4nU R                  SS5      Gc$  [        R                  " 5        GH
  u  p4[        R
                  " [        USS5      5      n[        R                  " U5      n[        US[        S	5      5      nUR                  5       (       d  US
Xv4n  O[        R                  " U5      (       a  M  UR                  5        Vs/ s H  n[         R                  " US5      PM     n	nX;   a  M  U	 Vs/ s H  oU:  d  M
  UPM     n
n[        U
=(       d    U	5      nUS   b  XS   :  d  GM  X;Xv4nGM     US   b  Uu  p5pv[        U[        [        45      (       d6  SR!                  U Vs/ s H  n[        R
                  " U5      PM     sn5      nU=(       d    [        S5      n[        S5      X=XS[        R
                  " U5      4-  nO1U R                  SS5      nUc  [        S5      n[        S5      U-   S-   n["        R$                  " [&        R(                  5      R+                  SS5      nS nU[        S5      U-  [        S5      [         R(                  " 5       -  -   [        S5      SR!                  [-        [        R                  " 5       5       Vs/ s H  nU" U5      PM     sn5      -  -   -  nU$ s  snf s  snf s  snf s  snf )z:Produce a warning message for the current active exceptionr   )rq  Nr0   r   s   supportcontact
testedwithbuglinks   the extension author.s   unknownr   r   r  s   (version N/A)s   ** Unknown exception encountered with possibly-broken third-party extension "%s" %s
** which supports versions %s of Mercurial.
** Please disable "%s" and try your action again.
** If that fixes the bug please report it to %s
s)   https://mercurial-scm.org/wiki/BugTrackers?   ** unknown exception encountered, please report by visiting
**    
c                `    U S   n[         R                  " U S   5      nU(       a  USU-   -  nU$ )Nr   r   rp   )r   moduleversion)r
  rc  vers      r-   ext_with_ver'_exceptionwarning.<locals>.ext_with_ver  s5    d&&qt,4#:C
r0   s   ** Python %s
s*   ** Mercurial Distributed SCM (version %s)
s   ** Extensions loaded: %s
s   , )r   versiontupler   r   r   r6  r   r  r   r  ismoduleinternalr  maxr   bytesstrry   r   sysbytesr5   versionr  sorted)r   ctworstr   modr  r!  reportr  testedlowernearestr  extverwarning
bugtracker
sysversionr  r
  s                      r-   _exceptionwarningr.  L  s    
		Q	B"c3E	yy)*2#..0ID $00\3/J !..s3GS)Q/G-HIF##%%j&9 **3//7A7G7G7IJ7I!d''1-7IFJ| &11b&QE1%/6*GQx71X#5v61 12 Qx,1)&*ucl335?@Z((+Z@J /A./A
 :Z-D-DV-LMN YYu&78
GHJ2 	
  	 ""3;;/77sCJ 	
	
	*;<t||~M	O +,jj*01F1F1H*IJ*IQa*IJ	
	G Nk K 2 AJ Ks   "!K	KK K!6K&c           	         [        U 5      nU R                  SSU[        R                  " [        R
                  " 5       5      5        U R                  U5        g)zProduce a warning message for broken commands

Called when handling an exception; the exception is reraised if
this function returns False, ignored otherwise.
s   commandexceptions   %s
%s
F)r.  rX   r   r   r8   
format_excr   )r   r+  s     r-   r   r     sK      #GFF)..01	 GGGr0   )r?   r   )r   zlist[bytes]r  zIterable[bytes]r?   z'list[tuple[bytes, bytes, bytes, bytes]]r"   )G
__future__r   rL   r   rf   r  r   r  r   r5   r8   typingr   i18nr   hgdemandimportr    r   r	   r
   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   configurationr   utilsr   r   r   r   rT   r_   rW   r[   r{   rZ   r}   r   r   r  r  r  rh  r  r  r   r   r   r7  r  r  r  r   r  r.  r   rF   r0   r-   <module>r8     s   #   	 	 
 	  
   "    * " 0 0f: 3
l$;PfL-^9x.7,t tn! !H "5Fp0'',;','T
 $N/d
BDN?Slr0   