
    q&fȷ                        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Zd dlZd dlZddl	m
Z
 d dlmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z"m#Z#m$Z$ ddl%m&Z&m'Z'm(Z(  G d d      Z)d	 Z*d
 Z+d Z,d Z-d Z.d Z/d Z0d Z1d Z2d Z3d Z4 G d d      Z5 G d d      Z6d Z7d Z8d Z9d Z:d Z;d Z<d Z=d%dZ>d  Z?d! Z@d" ZAd# ZBd$ ZCy)&    N   )_)tracing)cmdutilcolorcommandsdemandimportencodingerror
extensions	fancyoptshelphghook	localrepo	profilingpycompatrcutil	registrarrequirementsscmutiluiutilvfs)procutil
stringutilurlutilc                   (    e Zd Z	 	 	 	 	 	 	 ddZd Zy)requestNc	                     || _         || _        || _        || _        || _        || _        || _        i | _        |xs g | _        d | _	        y 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__zrequest.__init__8   sZ     		 			  +0b "&    c                 B   d }| j                   j                  }	 |r |j                         \  }}}	  ||i | |r ||y #  |t        j                         d   }| j                   j                  d       | j                   j                  d       Y \xY w# ||w xY w)Nr   s   error in exit handlers:
T)force)r   _exithandlerspopsysexc_info
warnnoi18n	traceback)r+   exchandlersfuncr"   kwargss         r,   _runexithandlerszrequest._runexithandlersX   s    77((	%-\\^"dF2$)&)  	 2{!llnQ/GG&&'CDGG%%D%1	 s"   B A B ABB B)NNNNNNN)__name__
__module____qualname__r-   r;    r.   r,   r   r   7   s$     &@r.   r   c                    d }t        | d      r-| J | j                  J 	 | j                  j                          t        | d      r| J | j                  J 	 |X|j
                  t
        j                  k7  r;| j                  j                  dt        j                  |j                        z         | j                  j                          |S |S # t        $ r}|}d}Y d }~d }~ww xY w# t        $ r d}Y |S w xY w)Nr%   r&   s
   abort: %s
)hasattrr%   flushIOErrorr&   errnoEPIPEwriter
   
strtolocalstrerror)r   errstatuses       r,   _flushstdiorM   j   s    Fr6~~ww"""	GGMMO
 r6~~ww"""		399#;"X%8%8%FF GGMMO M6M%  	CF	  	FM	s*   C A4C- 	C*C%%C*-C<;C<c                  "   	 t                t        j                  d      5  t        t        j
                  dd       } ddd       t               }t                t        j                  |dz         y# 1 sw Y   7xY w# t        $ r d}Y 2w xY w)zrun the command in sys.argvzparse args into requestr   NrA      )	initstdior   logr   r   sysargvdispatch_silencestdioKeyboardInterruptr3   exit)reqrK   s     r,   runrX      s~    
[[23 	0(**12./C	0 #
 HHVc\	0 	0
   s'   B  A4B  4A=9B   BBc                  `   t         j                  dt         j                  j                  d} t        t         j                  d      rt         j                  j                  | d<   t        j                  t         j                  j                  t         j                  j                  t         j                  j                  fi | t         _        t         j                  dt         j                  j                  d} t        t         j                  d      rt         j                  j                  | d<   t        j                  t         j                  j                  t         j                  j                  t         j                  j                  fi | t         _
        t         j                  t        j                  t         j                  j                  t         j                  j                  t         j                  j                  d t         j                  j                        t         _        y y )N
)newlineline_bufferingwrite_through)r3   stdoutr\   rB   r]   ioTextIOWrapperbufferr
   errorsstderrstdin)r:   s    r,   rP   rP      sj    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
	 r.   c                      t         j                  t         j                  fD ]  } | 	 | j                           y # t        $ r Y nw xY w	 | j                          ;# t        $ r Y Fw xY wr!   )r3   r^   rc   rC   rD   close)fps    r,   rT   rT      sk    zz3::& :	HHJ  			HHJ 		s!   ;	AAA	A('A(c                 2    dj                  d | D              S )N    c              3   F   K   | ]  }t        j                  |        y wr!   r   
shellquote).0as     r,   	<genexpr>z_formatargs.<locals>.<genexpr>   s     :X((+:   !)joinr"   s    r,   _formatargsrs      s    99:T:::r.   c                     d}	 t        |       }t        | j                  |      }|r|s|}|S # t        j                  $ r}|}d}Y d}~:d}~ww xY w)zErun the command specified in req.args; returns an integer status codeNrA   )_rundispatchr   
StdioErrorrM   r   )rW   rJ   rK   rL   rets        r,   rS   rS      sY    
Cc"
 cffc
"C
6M  s   - A A		Ac                 
   t        j                  d      5  | j                  r| j                  }n3| j                  r| j                  j                  }nt        j
                  }	 | j                  s#t        j                  j                         | _        | j                  j                  t        | j                  | j                               | j                  d   r| j                  j                  dddd       | j                  r| j                  | j                  _        | j                  r| j                  | j                  _        | j                  r| j                  | j                  _        | j                  r| j                  | j                  _        t)        | j                        }t+        j,                         }d}	 t/        |       xs d}t+        j,                         |z
  }| j                  j?                          | j                  j@                  ra|dz  | j                  jB                  d<    | j                  j                  	 	 di tE        jF                  | j                  jB                         |dz  }| j                  j                  dd|||||| jH                         	 | jK                          | j                  j?                          |cd d d        S # t         j"                  $ r1}|j%                  |j'                                Y d }~d d d        yd }~ww xY w# t         j0                  $ rj}| j                  j!                  t3        d	      |z         |j4                  r1| j                  j!                  t3        d
      |j4                  z          d }~wt6        $ r~}	 t9        |t         j:                        rt3        d      }nt3        d      }| j                  j!                  |       n## t         j:                  $ r Y nt<        $ r Y nw xY wd}Y d }~Td }~ww xY w#  |xs d}Y |xY w# t+        j,                         |z
  }| j                  j?                          | j                  j@                  ra|dz  | j                  jB                  d<    | j                  j                  	 	 di tE        jF                  | j                  jB                         |dz  }| j                  j                  dd|||||| jH                         	 | jK                          n#  |xs d}Y nxY w| j                  j?                          w xY w# 1 sw Y   y xY w)Nzdispatch._rundispatch	   traceback   ui   on   --tracebackrA   r   r   s   ** ProgrammingError: %s
s   ** (%s)
s   killed!
s   interrupted!
i  s   command_durationrO   s   commandfinishs!   %s exited %d after %0.2f seconds
)return_codedurationr*   )s	   uiblockeds   ui blocked ms
)&r   rQ   r&   r   r   rc   uimodloadr(   update_earlyparseoptsr"   	setconfigr$   r%   r'   r   AbortrG   formatrs   r   timer	_runcatchProgrammingErrorr   hintrU   
isinstanceSignalInterruptBrokenPipeErrorrC   logblockedtimes_blockedtimesr   	strkwargsr*   r;   )	rW   r&   instformattedargs	starttimerw   msgr~   r}   s	            r,   ru   ru      s"   	,	- O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_O O0 {{ 	JJt{{}%5O O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]O Os   AU$D1K +UL'CU+P,;U L$3LUL$$U'P):A%NP),AO98P$9PP$PP$PP$P:$P))P:,P74U:CUT'&U'T1	/ UUUc                 "    t        j                  d      5  d } j                  	 dD ],  }t        t        |d       }|st	        j                  ||       . 	  fd}t        |      cd d d        S # t
        $ r Y &w xY w# 1 sw Y   y xY w)Nzdispatch._runcatchc                  "    t         j                  r!   )r   r   rr   s    r,   	catchtermz_runcatch.<locals>.catchtermH  s    '''r.   )SIGBREAKSIGHUPSIGTERMc                  x   d } 	 t        j                   j                  d d  t        j                  i       }|d   }t	        j
                  |t        j                  d      \  }}|d   } | dk(  rdv rd}d|v }|r|dz  }t        j                        |k7  shj                  d   dk7  sVj                  d   j                  d	      s8j                  d
   dk7  s&j                  d   dk7  s|rQj                  d   dk7  r?t        j                  t!        d      t#        j$                  j                        fz        	 d}dt&        j(                  i}dt&        j*                  i}	t-        j.                  j0                  d         }
j2                  r4|
D ]/  \  }}}j2                  j.                  j5                  |||d       1 j7                  dd      }t&        }|rj9                         rd}nKj0                  d   r<t;        j<                         5  	 t?        tA        jB                  |            }d d d        |j(                  ||<   |j*                  |	|<   j0                  d   rnjG                  t!        d             |dk7  r(||   |d   k(  rjG                  t!        d      |z         t;        j<                         5   ||           d d d        	 tI              jK                          S # t        j                  t        j                  t        t        j                  f$ r Y w xY w# tD        $ r Y 	w xY w# 1 sw Y   xY w# 1 sw Y   xY w# jK                          w xY w#  j0                  d   r4tM        jN                           	   tQ        jR                         d
           xY w)Nr   Fs   serves   --stdio   s   --hiddenr   s   -R   --      s/   potentially unsafe serve --stdio invocation: %ss   pdb   config   --config)sourcerz      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_parseconfigr   r(   r#   r   configplainr	   deactivated
__import__r   sysstrImportErrorwarn	_dispatchrC   r6   	print_excr3   r4   )realcmdcmdargscmdaliasesentrynbargshashiddenaccessdebugger
debugtracedebugmortemcfgssecnamevaldebugmodrW   r   s                  r,   _runcatchfuncz _runcatch.<locals>._runcatchfuncT  s   G#--HHQK!4!4b aj!(hnne!L!!* ("zW'< "-"8"aKFMV+xx{e+xx{--e4xx{h.xx{j0&{2++LM%,,SXX689 
C!$cmm4
%s7 $CFFC,<,<Y,GH88 +/ T3--s; .  99UK8288:%H%%k2 &113 !!'1(//(2K'LH! (0'9'9
8$(0(<(<H% ##K0GGN !F*&x0Jv4FF!B '	' &113 /,
8,./$S>HHJE $$&&""	 
 
H  + ! !! !:/ /
 HHJ##K0''))K)#,,.*;<s   A$K7 ?CM3 ML58BM3 MM3 
M &M3 77L21L25	M>MMMM
M3 MM3 M00M3 3AN9)r   rQ   r   getattrsignal
ValueError
_callcatch)rW   r   r   numr   r   s   `    @r,   r   r   E  s    	)	* B-	( VV	7 2fdD1MM#y12r	h "m,EB- B-  		B- B-s4   BA6A6B6	B?BBBBc                    d}	 t        j                  | |      S # t        j                  $ rO}d}| j	                  t        d      |j                  dj                  |j                        fz         Y d}~n[d}~wt        j                  $ r}d}|j                  r}| j                  d       t        j                  |j                        }| j	                  t        d      |j                  |fz         t        j                   | |j                  dd	
       nA| j	                  t        d      |j                  z         | j	                  t        d             Y d}~nsd}~wt        j"                  $ r9}d}t        d      |j                  z  }	 t%        j&                  | t        |j                  d	      }| j	                  |       | j)                  |       n# t        j"                  t        j*                  f$ r d}|j,                  rft        j.                  |j,                  |j                        }|r:| j	                  |       | j	                  dt        j0                  |      z         d	}|s+| j	                  |       | j	                  t        d             Y nw xY wY d}~n(d}~wt2        $ r  t4        $ r   t7        |       s Y nxY w| j9                  dd      r|S y)zlike scmutil.callcatch but handles more high-level exceptions about
    config parsing and commands. besides, use handlecommandexception to handle
    uncaught exceptions.
    rA   
   s&   hg: command '%s' is ambiguous:
    %s
ri   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)
rz   s   detailed-exit-code)r   	callcatchr   r   r   r   prefixrq   matchesCommandErrorr   pagerr   bytestrmessager   help_r   r   formattedhelprG   r   all_commands
getsimilarsimilarity_hintrD   rU   handlecommandexception
configbool)	r   r9   detailed_exit_coder   msgbytesnocmdmsg	formatted	suggestedsims	            r,   r   r     s]   
 .  T**!! 

9:{{DIIdll345	
 	
  	M<<HHW''5HGGAn%x(@@ANN2t||%FGGAkNT\\12GGAJK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!!sT    KAA77KCEK6J*A	GJ*CJ"J*!J""J**#Kc                 V   g }t        | d      st        | d|      }|rdj                  t        t        j
                  |            }g fd}t        j                  d||      }t              D cg c]  \  }}|vs| c}}t        j                  |      }|z   S c c}}w )N	_origfuncr"   ri   c                     t        | j                  d            dz
  }j                  |       |t              k  r|   S t	        j
                  t        d            )Nr   s#   too few arguments for command alias)intgroupappendr   r   
InputErrorr   )mr   	givenargsnumss     r,   replacerzaliasargs.<locals>.replacer  sR    aggaj/A%CKKS^# ~%""1%K#LMMr.   
   \$(\d+|\$))rB   r   rq   mapr   rl   resub	enumerater   
shlexsplit)fnr   r"   r   r   ixr   s    `     @r,   	aliasargsr     s    D2{#r64(iiH//67	N ff^Xs3#,Y#7I41a1D=QI	""3') Js   6B%B%c                 ~   t        |      D ci c]  \  }}d|dz   z  | c}}| d<   dd<   dj                  |      d<   dj                  d |D              d	<   d
j                  j                               j                  dd      }t	        j
                  |      }|j                  fd|      S c c}}w )zXinterpolate args into cmd for shell aliases

    This also handles $0, $@ and "$@".
    s   $%dr   s   $0   $s   $$ri   s   $@c              3   F   K   | ]  }t        j                  |        y wr!   rk   )rm   args     r,   ro   z#aliasinterpolate.<locals>.<genexpr>-  s     #MH$7$7$<#Mrp   s   "$@"   |s   \$c                 *    | j                            S r!   )r   )r   
replacemaps    r,   <lambda>z"aliasinterpolate.<locals>.<lambda>1  s    :aggi0 r.   )r   rq   keysreplacer   compiler   )r   r"   r   r   r  regexrr  s          @r,   aliasinterpolater    s     7@oFFAs&AE"C'FJJuJu		$Ju
 ))#M#MMJwIIjoo'(00v>E


5A550#66 Gs   B9c                   6    e Zd Zd ZddZed        Zd Zd Zy)cmdaliasc                     |x _          _        d _        | _        d  _        g  _        g  _        d _        d  _        d _	        | _
        	 t        j                   j                   |      \  }}|j                         D ]  \  }}	|	|u s| _         n d _         j                  st#        d       j                   z   _        y  j                  j%                  d      rI j                  dd  d _         fd}
|
 _        d _         j+                  || j                         y 	 t-        j.                   j                        }t7        |      \  }}|rBt#        d	       j                   d
j9                  t-        j:                  | d         fz   _        y |j=                  d      x _        }| _        	 t        j                  ||d      d   }t?        |      dkD  r|\   _         _        }n|\   _         _        d }d _         j+                  ||| j                  |       y # t        j                   $ r d _        Y w xY w# t0        $ r<}t#        d       j                   t3        j4                  |      fz   _        Y d }~y d }~ww xY w# t        j                   $ r) t#        d       j                   |fz   _        d _	        Y y t        j@                  $ r" t#        d       j                   |fz   _        Y y w xY w)Nr.   FTs   no definition for alias '%s'   !r   c                      ddj                  j                  fz         i} fd}t        j                  d|      }t	        j                  |      } j                  ||dj                  z        S )Ns   HG_ARGSri   c                 6   | j                         d   dk(  r| j                         S t        | j                         d         t              k  r| j                         S j	                  dt        | j                         d         j
                  fz         y)Nr   r   sL   No argument found for substitution of %i variable in alias '%s' definition.
r.   )groupsr   r   r   debugr   )r   r"   r+   r   s    r,   	_checkvarz0cmdalias.__init__.<locals>.fn.<locals>._checkvarV  s    xxz!}, wwy(QXXZ]+s4y8 wwy(J"188:a=1499=>
  #r.   r   s   alias_%s)environ
blockedtag)rq   r   r   r   r  system)r   r"   envr  r   r+   shdefs   ``   r,   r   zcmdalias.__init__.<locals>.fnS  sr    !499dii\D-@#AB# ff^Y>&tyy$<yytyy1H !  r.   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_earlysplitoptsrq   ziplistr2   r   r   )r+   r   r   r  cmdtabler   r   r   r#  rL   r   r"   r   	earlyoptsr   
tableentrycmdhelpr  s   `                @r,   r-   zcmdalias.__init__5  s   ##	DH$			!$__TYYANGU$NN, q:$DH  DL =>JDM??%%d+OOAB'EDJ, DGDJr48	&&t7D *$/	45 DIIh&6&6	&B1&EFGHDM !XXa[(s	 h>qAJ:".8+G%/"DJr4dggw?C ## 	! DL	!P  	GH		''-L DM 	6 ## 	#> 		DM #DO%% 	@ 		DM	sI   =H1 H1 /I  A0J 1II	J2JJ9L	1L	L	Nc                 n   i }dD ]N  }|j                  dd||fz  d       }|t        j                  |      st        d      ||fz  | _         y |||<   P |j                  d|xs d      | _        | j                  r>| j                  j                  d|z         r | j                  dt        |      z   d  | _        d	|v | _	        |j                  d	t        j                  |            }	|	t        j                  |	      }	|	| _        |j                  d
t        j                  j                         | _        y )N)   docr      category   aliass   %s:%ss/   non-ASCII character in alias definition '%s:%s'r   r.   s   hg r   r-  r.  )r   r
   
isasciistrr   r  getr   r   r   owndocr   getdocr   __doc__r   r   CATEGORY_NONEhelpcategory)
r+   r   r   r   r   defaulthelpcfgkvdocs
             r,   r$  zcmdalias._populatehelp  s   / 		A		(Hay$8$?Ay&&q) !F!1I! CF		 GGG[%7C8	99--fsl;		!c#h,.1DImggfhoob12?//#&CGG**88
r.   c                     t        j                  t        j                  | j                        }t        | j                  |      S r!   )r   maplistr   
expandpathr   r   r   )r+   r"   s     r,   r"   zcmdalias.args  s-    @$''r.   c                     dt               ddd}||vrt        |      | j                  st        | d      r||   S t	        | j
                  |      S )NTF)norepointentsoptionalrepo	inferrepor"  )setAttributeErrorr  rB   r   r   )r+   r   	adefaultss      r,   __getattr__zcmdalias.__getattr__  sW    u!	
	 y  &&==GD'2T?"tww%%r.   c                 .   | j                   rfd }| j                  r7	 t        j                  || j                        d d \  }}t        d      ||fz  }t        j                  | j                   |      | j                  r*|j                  d| j                  | j                  fz         |j                  dd| j                  | j                         t        | d      r | j                  |g|i |S 	  t!        j"                  | j                        |g|i |S # t        j                  $ r Y w xY w# t        j$                  $ rK dj'                  | j                  g| j(                  z         }|j                  d| j                  |fz          w xY w)	Nr   s"   '%s' is provided by '%s' extension)r   s    alias '%s' shadows command '%s'
s   commandaliass   alias '%s' expands to '%s'
r"  ri   )r  r   r   disabledcmdr  r   r   r   ConfigErrorr!  r  r   rQ   r  rB   r   r   checksignatureSignatureErrorrq   r"   )r+   r   r"   r  r   r   exts          r,   __call__zcmdalias.__call__  so   ==D)55b$,,GKHCBCsCjPD ##DMM==<<HH4		4<<7PP 	+IIOO		
 4!4772----3t**4773BFFFF% ++ & '' yy$,,$))!;<8DIIt;LLMs   6D 4(D6 D32D36AFr!   )	r<   r=   r>   r-   r$  propertyr"   rG  rN  r?   r.   r,   r  r  4  s,    dL
: ( (&r.   r  c                   L    e Zd ZdZd Zej                  d        Zd Zd Z	d Z
y)lazyaliasentryz<like a typical command entry (func, opts, help), but is lazyc                 t    || _         || _        || _        |j                         | _        || _        d| _        y )NT)r   r   r  copyr(  r   r#  )r+   r   r   r  r(  r   s         r,   r-   zlazyaliasentry.__init__  s2    	$ 
r.   c                     t        | j                  | j                  | j                  | j                  | j
                        S r!   )r  r   r   r  r(  r   r+   s    r,   	_aliasdefzlazyaliasentry._aliasdef  s.    GGTYY
 	
r.   c                 x    | j                   }|dk(  r|S |dk(  r|j                  S |dk(  r|j                  S t        )Nr   r   r   )rV  r  r   r   )r+   naliasdefs      r,   __getitem__zlazyaliasentry.__getitem__  s?    >>6O!V== !V== r.   c              #   :   K   t        d      D ]	  }| |     y wNr   )range)r+   r   s     r,   __iter__zlazyaliasentry.__iter__  s"     q 	Aq'M	s   c                      yr\  r?   rU  s    r,   __len__zlazyaliasentry.__len__  s    r.   N)r<   r=   r>   r4  r-   r   propertycacherV  rZ  r^  r`  r?   r.   r,   rQ  rQ    s3    F 

 

	r.   rQ  c                     | j                  dd      D ]@  \  }}	 ||   j                  |k(  r	 | j	                  d|      }t        | ||||      }|||<   B y # t        t        f$ r Y :w xY w)Nr/  T)	ignoresub)configitemsr  KeyErrorrE  configsourcerQ  )r   r(  r#  r  r   r   s         r,   
addaliasesrg    s      ^^H^E 
 z	))Z7 8 51r5*hG
  .) 		s   AA*)A*c                    i }i }	 t        j                   |t        j                  |      }|r|d   |dd  }}t        j                  |t        j                  | j                  dd            \  }}|d   }t        |d   |      }| j                  d|      }|r:t        j                   t"        j$                  t        j&                  |            |z   }t)        |d         }	nd }g }	t        j                  D ]&  }
|	j+                  |
d   |
d   ||
d      |
d   f       ( 	 t        j                   ||	|d      }t        j                  D ]  }
|
d   }||   ||<   ||=  ||xr d   xs d |||fS # t        j                  $ r.}t        j                  d t        j                  |            d }~ww xY w# t        j                  $ r.}t        j                  |t        j                  |            d }~ww xY w)	Nr   r   rz      stricts   defaultsr   T)gnu)r   r   r   r   r   r   r   r   r%  r   r   r   r   r   r   r   r=  r   r>  r   listr   )r   r"   options
cmdoptionsr   r   r   r   defaultscorX  s               r,   _parserq     s    GJF""4)<)<gF GT!"XT ui!@
 ajq4(99[#.  (2E2Eh2OP  qN    4	!A$!gadmQqT234E""4JDA
    aD]
qM
 !q)T4*EEI  F  z'>'>t'DEEF6  E  j&=&=d&CDDEs/   %E. F2 .F/)F**F/2G3)G..G3c                    g }|D ]{  }	 |j                  dd      D cg c]  }|j                          c}\  }}|j                  dd      \  }}|r|st        | j                  |||d       |j	                  |||f       } |S c c}w # t        t
        f$ r5 t        j                  t        d      t        j                  |      z        w xY w)z0parse the --config options from the command line   =r      .r   s?   malformed --config option: %r (use --config section.name=value))splitstripr   r   r   r   r   r   r   r   r   )r   r   configsr8  cfgelemr   valuesections           r,   r   r   M  s    G 	:=))D!:LMw7==?MKD% JJtQ/MGT$  LL${;NNGT512" N N J' 	""9 ""3'	( 	s   B
BAB
B

ACc           	          i }t        j                   |t        j                  || j                  d       dddgi       |S )Ns   strictflagsT
   repository   repo)rj  early
optaliases)r   r   r   r   )r   r"   rl  s      r,   r   r   e  sG    G((!G9- Nr.   c                 B    d}g d}t        j                  | ||dd      S )zCSplit args into a list of possible early options and remainder argss   R:)s   cwd=s   repository=s   repo=s   config=T)rj  keepsep)r   earlygetopt)r"   shortoptionslongoptionss      r,   r&  r&  r  s*    LAK  lKT4 r.   c	           
      V   t        j                   | |d|z  ddj                  |      ||       	 t        ||||      }	t        j                   | |d|z  ddj                  |      |	||       |	S # t        $ r0 t        j                   | |d|z  ddj                  |      ||        w xY w)	Ns   pre-%sTri   )r"   patsr  s   post-%sF)r"   resultr  r  s   fail-%s)r   rq   _runcommand	Exception)
luir#   r   fullargsr   rl  dcmdpatsrm  rw   s
             r,   
runcommandr  |  s    IICYYx "gsA.		8$		
, J  		8$	
 	s   =A/ /9B(c                 :   	 t        t        j                  j                  |dd      d      5 }t	        |j                         j                               }t        j                  |v rt        j                  |v s
	 ddd       yt        j                  t        j                  j                  |d            }t        j                  ||      }|j                  }| j                  |j                  d      |       ddd       y# 1 sw Y   yxY w# t        $ r Y yw xY w)a!  if the current repository is shared one, this tries to read
    .hg/hgrc of shared source if we are in share-safe mode

    Config read is loaded into the ui object passed

    This should be called before reading .hg/hgrc or the main repo
    as that overrides config set in shared source   .hgs   requiresrbN   hgrc)openospathrq   rD  read
splitlinesrequirementsmodSHARESAFE_REQUIREMENTSHARED_REQUIREMENTr   r   _getsharedvfsbase
readconfigrD   )r   r  rg   r   hgvfs	sharedvfsroots          r,   _readsharedsourceconfigr    s    "'',,tV[94@ 
	9Brwwy3356L55E#66,F
	9 
	9 GGBGGLLv67E!//|DI>>DMM)..148
	9 
	9 
	9  s<   +D AD:D A6D9D DD D 	DDc                    	 t        j                         }d}||}n|}t        j                  |       t        j                  |      xs d}|s| }n| j                         }t        j                         rnt        ||       |j!                  t        j"                  j%                  |dd      |       |j!                  t        j"                  j%                  |dd      |       |rt'        j(                  ||      }|j*                  }| j                         }t        j                         rnt        ||       |j!                  t        j"                  j%                  |dd      |       |j!                  t        j"                  j%                  |dd      |       |rt        j                  |       ||fS # t        $ rC}t        j                  t        d      t        j                  |j                        z        d}~ww xY w)zpReturn (path, local ui object) for the given target path.

    Takes paths in [cwd]/.hg/hgrc into account."
    s+   error getting current working directory: %sNr.   r  r  s   hgrc-not-shared)r
   getcwdOSErrorr   r   r   rH   rI   r  chdirr   findreporS  r   use_repo_hgrcr  r  r  rq   r   get_clone_path_objrawloc)	r   rpathwdcwdrL   oldcwdr  r  path_objs	            r,   	_getlocalr    s   

oo F	z
B&3Dggi!#C.NN277<<fg>ENN277<<f6HI4P--c59ggi!#C.NN277<<fg>ENN277<<f6HI4P
9K  
kk<=!!!**-.
 	

s   F5 5	H>>G<<Hc                    	
 i 	 t        j                   t        j                        syt        j
                  }d   	 j                  dd      }t        j                  ||      \  }}|d   |d   
r,t        
d      rt              \  }
fd		 fdS yy# t        j                  $ r Y yw xY w# t        j                  t        j                  f$ r Y yw xY w)z=Return the function to run the shell alias, if it is requiredNr   rz   ri  r"  c                       g dd   S Nr   r?   )r"   r   r   s   r,   r  z"_checkshellalias.<locals>.<lambda>  s    Br%DH% r.   c                  0    t        d  d d g i 	      S r  )r  )r"   r   r  r  rl  r   s   r,   r  z"_checkshellalias.<locals>.<lambda>  s%    zsD!Hb'1b"
 r.   )r   r   r   r   r   r   r   r   r   r   r   r   rB   r&  )r  r   r"   r(  strictr   r   
_earlyoptsr   r  r   rl  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#C-,C-c                    | j                   | j                  | j                  d   }|rt        j                  |       | j                  d   }t        |      \  }}|h}| j                  r%|j                  | j                  j                         | j                  d   s| j                  d   s| j                  d   rPdD ]K  }t        j                  t        | j                  |               }|D ]  }|j                  d||d|z           M | j                  d	   r|D ]  }|j                  d
ddd        n7| j                  d	   du r&|j                  d
d      r|j                  d
ddd       |j                  d
d      }	t        j                  ||	      5 }
t        j                   |       |j"                  _        t%        |t&        j(                         t+        |      }|r,|D ]  }t        j,                  |         |       cd d d        S |j/                  dd      }|r|t0        _        }t5        |      \  }}}|| _        |d   | j                  d   k7  rt9        j:                  t=        d            |d   | j                  d   k7  rt9        j:                  t=        d            |d   | j                  d   k7  rt9        j:                  t=        d            |d   | j                  d   k7  rt9        j:                  t=        d            |d   r|d   t0        _        |d   r|d   t0        _        |d   r"d         fd}jA                  |       |d	   r|
jC                          |d   s
|d   s|d   r\dD ]W  }||   | j                  |   k(  rt        j                  t        ||               }|D ]  }|j                  d||d|z           Y |d   r|D ]  }|j                  dddd         |d!   r|D ]  }|j                  dd"d#d$        |jE                  d%d      r|D ]	  }d&|_#         |d'   }|D ]-  }|r|j                  dd'|d(       tI        jJ                  |       / tM        jN                  |d)         rjQ                  d*|z          n|d)   d+k7  r|D ]  }|jS                           |D ]  }t        j,                  |        |d,   rt'        jT                        cd d d        S |d-   r#t'        jV                  ||d u.      cd d d        S |st'        jV                  d/      cd d d        S d }d d  }J jX                  s<|s|s| j                  }|rmjZ                  |j                  _-        j\                  |j                  _.        j^                  |j                  _/        j`                  |j                  _0        n	 tc        jd                  || jf                  jh                  0      }|jk                         s!t9        j:                  t=        d1      |z        |j                  j                  d2d3|jl                  d4       |r!|j                  |d8   r|j                         }j                  d5|       n|rj                  t=        d9             t        |      }j                  d:d;|       t        j                  |      fd<}	 t        ||||||||	      |r|| j                  k7  r|j                          cd d d        S # t8        jn                  $ r  t8        jp                  $ r |r jr                  sjt                  r}r{|syt        jv                  tx        jz                        }|d5   }|rN|j}                  |      t        |      k(  r1d6|g|z   | _         || j                  d<   t        |       cY cd d d        S |s3t9        j:                  t=        d7      t1        j                         z         Y w xY w# |r!|| j                  k7  r|j                          w w w xY w# 1 sw Y   y xY w)=Ns   cwdr|     verbose   debug   quiet)r  r  r  rz   r   s   profiles	   profilings   enableds   trues	   --profileFs   falses   --no-profile)enableds   fallbackencodingr   s&   option --config 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                      t        j                         } | d   dk(  r%| d   | d   | d   | d   t        j                         f} | S )Nr   g        r   r   r   r   )r  timesr   r   )ts    r,   	get_timesz_dispatch.<locals>.get_timesm  sC    HHJQ43;1qtQqT1Q4>Ar.   c            
                  } j                  t        d      | d   d   z
  | d   d   z
  | d   d   z
  | d   d   z
  | d   d   z
  fz         y )Ns4   time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)
r   r   r   r   r   )r   r   )r  r  sr   s    r,   
print_timez_dispatch.<locals>.print_timev  st    KNO!qt!qt!qt!qt!qt	r.   ry   r{   r|   s   noninteractives   interactives   offs   -ys   insecureTs   colors   --colors   pagers   internal-always-s   autos   versionr   )r   s	   shortlist)r  presetupfuncsrA  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                  B     t        j                        g i S r!   )r   rK  )r"   r9   	strcmdoptr   s   r,   r  z_dispatch.<locals>.<lambda>  s$    -D''-bE4E9E r.   )Jr"   r   r(   r  r  r  r#   addr   r   boolr   r   r   profiler   loadall	__class__rg  r   r   r  
populateuir   r
   fallbackencodingrq  r*   r   r   r   encodingmodeatexitstartr1  insecureconnectionsr   setupr   	parseboolr   disablepagerversion_r   r@  r$   r%   r&   r'   r   
repositoryr)   rA  localr  RequirementError	RepoErrorrB  rC  r=  r   r  countr   r   r  
unfilteredinsertr   rs   rQ   r   r  rf   )rW   r  r  r  r  uisoptr   ui_r  profilershellaliasfnfallbackr  r   rl  rm  r  coloroptr#   r  reposguessr   r  r"   r9   r  r  r  r   s                            @@@@@@r,   r   r     sR   88D	B 

6
"C

]+E"e$ID#s)C
xx 	$H%H%3 	<C""4(8(8(=#>?C <eS#us{;<	<
 
# 	KCMM,
G\J	K			*	%	. >>,
3
 MM,
HoNnn\:6G			3	0 GH 	3}} 	3' (R6 +%%c*+>)G G. ::e%89(0H%/5c4/@,T4* !$9!1!1)!<<""1%N#OPP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#3#3C#88&&tGCL'9: @CMM%c53;?@	@ <  Je\5.IJ $% De^VUCD >>+u- /*.'/
 8$ 	CeXxDKK	
  12HH(3./X') #  "#  	'C!!#&	' :$$R(wG Gx 7>>"c3d?C{G G| >>"l3G GB 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': (

OG G| --  ,,>>d4$,$4$4W5E5Et$LE$)!HE$U);s5z)I,;U+Ch+NBG 0 0 ?'0~ 5WG GX  $"'"2"2 !%=!" #+//"3	!4#  # -L (

 )tMG Gsr    A2a&K+a&a&9a&Ba&2B]8Ba&`>!a&B3`;6a&6`;7a&:`;;a&>%a##a&&a/c                     	 t        j                  d|z        5   |       cddd       S # 1 sw Y   yxY w# t        j                  $ r  t        j                  |t        d            w xY w)z8Run a command function, possibly with profiling enabled.zRunning %s commandNs   invalid arguments)r   rQ   r   rL  r   r   )r   rl  r   cmdfuncs       r,   r  r    s`    ?[[-34 	9	 	 	 ?  a(<&=>>?s   7 +	7 47 7 3A*c                 p   t        j                  d      }d|ddf}| j                  dd      t        j                         D ]  \  }}t	        j
                  t        |dd            }t        j                  |      }t        |dt        d	            }|j                         s|d
||f} nt        j                  |      r|j                         D cg c]  }t        j                  |d       }	}||	v r|	D cg c]
  }||k  s	| }
}t        |
xs |	      }|d   	||d   k  s||||f} |d   |\  }}}}t        |t        t        f      s2dj!                  |D cg c]  }t	        j
                  |       c}      }|xs t        d      }t        d      ||||t	        j
                  |      fz  }n0| j                  dd      }|t        d      }t        d      |z   dz   }t#        j$                  t&        j(                        j+                  dd      }d }|t        d      |z  t        d      t        j(                         z  z   t        d      dj!                  t-        t        j                               D cg c]
  } ||       c}      z  z   z  }|S c c}w c c}w c c}w c c}w )z:Produce a warning message for the current active exceptionr   )rX  Nr.   rz   s   supportcontact
testedwithbuglinks   the extension author.s   unknownr   r   rt  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                 T    | d   }t        j                  | d         }|r|d|z   z  }|S )Nr   r   ri   )r   moduleversion)r   rM  vers      r,   ext_with_verz'_exceptionwarning.<locals>.ext_with_verJ  s5    d&&qt,4#:C
r.   s   ** Python %s
s*   ** Mercurial Distributed SCM (version %s)
s   ** Extensions loaded: %s
s   , )r   versiontupler   r   r   r%  r   r  r   rv  ismoduleinternalru  maxr   bytesstrrq   r   sysbytesr3   versionr  sorted)r   ctworstr   modr  r  reportr  testedlowernearestro  extverwarning
bugtracker
sysversionr  r   s                      r,   _exceptionwarningr    s    
		Q	B"c3E	yy)*2#..0 	7ID# $00\3/J !..s3GS)Q/G-HIF##%j&'9 **3/7A7G7G7IJ!d''1-JFJV| &11!b&Q1E1%/6*GQx7U1X#5gvw61	72 Qx,1)j&'*ucl35?@((+@J /A./A
 6:tZ-D-DV-LMN YYu&78
GHJ2 	
  	 ""3;;/77sCJ 	
	
	*;<t||~M	O +,jj*01F1F1H*IJQaJ	
	G Nk K 2 AJ Ks   J$=
J)J)$J.J3c           	          t        |       }| j                  dd|t        j                  t	        j
                                      | j                  |       y)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  rQ   r   r  r6   
format_excr   )r   r  s     r,   r   r   ^  sK      #GFF)..01	 GGGr.   r!   )DrE   r   r_   r  r   r   r   r3   r6   i18nr   hgdemandimportr    r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   utilsr   r   r   r   rM   rX   rP   rT   rs   rS   ru   r   r   r   r  r  rQ  rg  rq  r   r   r&  r  r  r  r  r   r  r  r   r?   r.   r,   <module>r	     s      	 	 
 	  
   "     0 0 0f: 3
l$;PfC-L9x.7,t tn! !H "*FZ0
$N0,^
Bqh?Slr.   