
    6hx                       S SK Jr  S SKrS SK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  SSKJrJr  \R:                  r\R<                  r\R>                  r\R@                  r \RB                  r!\RD                  r"\RF                  r#\RH                  r$0 r%\RL                  " \%5      r&\&" S5      S	 5       r'\&" S
SS9S 5       r(\&" SSS1S9S 5       r)\&" SSSS1S9S 5       r*\&" SS1S9S 5       r+\&" S5      S 5       r,\&" S5      S 5       r-\&" SS1S9S 5       r.\&" S S!S1S9S" 5       r/\&" S#S$S9S% 5       r0\&" S&5      S' 5       r1\&" S(5      S) 5       r2\&" S*S1S9S+ 5       r3\&" S,S1S9S- 5       r4\&" S.S1S9S/ 5       r5S0 r6\&" S15      S2 5       r7\&" S35      S4 5       r8\&" S55      S6 5       r9\&" S75      S8 5       r:\&" S9S1S9S: 5       r;\&" S;5      S< 5       r<\&" S=5      S> 5       r=\&" S?5      S@ 5       r>\&" SA5      SB 5       r?\&" SC5      SD 5       r@\&" SE5      SF 5       rA\&" SG5      SH 5       rB\&" SI5      SJ 5       rC\&" SK5      SL 5       rD\&" SMS!1S9SN 5       rE\&" SOS!S1S9SP 5       r\&" SQ5      SR 5       rF\&" SS5      ST 5       rG\&" SUSVS9SW 5       rH\&" SXS!S1S9SY 5       rI\&" SZ5      S[ 5       rJ\&" S\5      S] 5       rK\&" S^5      S_ 5       rL\&" S`SaS!S1S9Sb 5       rM\&" Sc5      Sd 5       rNSe rO\%R                  5       rQg)f    )annotationsN   )_)bin)colordagopdiffutilencodingerrorminirstobsutilpycompat	registrarrevset
revsetlangscmutiltemplatefilters
templatekwtemplateutilutil)dateutil
stringutils   date(date[, fmt])c                B   S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        U UUS   [        S5      5      nSn[        U5      S:X  a  [        XUS   5      nUc  [        R                  " U5      $ [        R                  " X45      $ )zFormat a date. The format string uses the Python strftime format.
The default is a Unix date format, including the timezone:
"Mon Sep 04 15:13:13 2006 0700".r      s!   date expects one or two argumentsr   s   date expects a date informationN)lenr   
ParseErrorr   evaldate
evalstringr   datestr)contextmappingargsdatefmts        9/usr/lib/python3/dist-packages/mercurial/templatefuncs.pyr#   r#   4   s    
 Taq!EFGGQ	
,-D C
4yA~473
{%%**    s   dict([[key=]value...])s   *args **kwargs)argspecc                  ^ ^ [         R                  " 5       nUS    H}  n[        R                  " U5      nU(       d  [        R
                  " [        S5      5      eXS;   d  XRS   ;   a"  [        R
                  " [        S5      U-  5      e[        T TU5      X5'   M     UR                  U U4S jUS   R                  5        5       5        [        R                  " U5      $ )zrConstruct a dict from key-value pairs. A key may be omitted if
a value expression can provide an unambiguous name.   argss   dict key cannot be inferreds   kwargss!   duplicated dict key '%s' inferredc              3  F   >#    U  H  u  pU[        TTU5      4v   M     g 7fN)evalfuncarg).0kvr    r!   s      r%   	<genexpr>dict_.<locals>.<genexpr>[   s(      +DA 
K!,-+s   !)r   sortdictr   findsymbolicnamer   r   r   r,   updateitems
hybriddict)r    r!   r"   datar/   r.   s   ``    r%   dict_r8   M   s     ==?D']))!,""1%C#DEE9)_,""1%I#JQ#NOOgw2  	KK O))+  ""4((r&   s)   diff([includepattern [, excludepattern]])   ctx   ui)requiresc           	     d  ^ ^^ [        T5      S:  a  [        R                  " [        S5      5      eUU U4S jnT R	                  TS5      nT R	                  TS5      n[
        R                  " U5      nUR                  UR                  / U" S5      U" S5      5      US9nS	R                  U5      $ )
z?Show a diff, optionally
specifying files to include or exclude.r   s(   diff expects zero, one, or two argumentsc                v   > U [        T5      :  a(  [        TTTU    5      R                  5       nU(       a  U/$ / $ r+   )r   r   strip)isr"   r    r!   s     r%   getpatternsdiff.<locals>.getpatternsl   s8    s4y=7GT!W5;;=As
	r&   r9   r:   r   r   )matchoptsr&   )
r   r   r   r   resourcer	   diffalloptsdiffrC   join)r    r!   r"   rA   ctxuidiffoptschunkss   ```     r%   rG   rG   b   s     4y1}q!LMNN 

7F
+C			'5	)B##B'HXXiiKNKN;(  F 88Fr&   s   extdata(source)   source   cache)r'   r;   c                X   SU;  a  [         R                  " [        S5      5      e[        XUS   5      nU(       di  [        R
                  " US   5      nU(       a*  [         R                  " [        S5      [        S5      U-  S9e[         R                  " [        S5      5      eU R                  US5      R                  S0 5      nU R                  US5      nX5;   a  XS   nO)[        R                  " UR                  5       U5      =ouU'   UR                  UR                  5       S	5      $ )
zBShow a text read from the specified extdata source. (EXPERIMENTAL)rM   s   extdata expects one arguments   empty data source specifieds   did you mean extdata('%s')?hintrN   s   extdatar9   r&   )r   r   r   r   r   r3   rE   
setdefaultr   extdatasourcerepogetrev)r    r!   r"   sourcesymcacherI   r7   s           r%   extdatarZ   }   s   
 q!@ABB$y/:F++DO<""0156< 
 ""1%C#DEEWh/:::rJE


7F
+C}&44SXXZHHV}88CGGIs##r&   s   files(pattern)c                (   [        U5      S:X  d  [        R                  " [        S5      5      e[	        XUS   5      nU R                  US5      nUR                  U/5      n[        UR                  U5      5      n[        R                  " XSU5      $ )zQAll files of the current changeset matching the pattern. See
:hg:`help patterns`.r   s   files expects one argumentr   r9   s   file)r   r   r   r   r   rE   rC   listmatchesr   compatfileslist)r    r!   r"   rawrI   mfiless          r%   ra   ra      s     t9>q!>?@@
WtAw
/C


7F
+C		3%AQ E'''5IIr&   s1   fill(text[, width[, initialident[, hangindent]]])c                   S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        XUS   5      nSnSnSnS[        U5      s=::  a  S::  a<  O  O9[        U UUS   [        S5      5      n [	        XUS   5      n[	        XUS	   5      n[        R                  " X4XV5      $ ! [         a     N#f = f)
zFFill many
paragraphs with optional indentation. See the "fill" filter.r      s"   fill expects one to four argumentsr   L   r&   r   s   fill expects an integer width   )	r   r   r   r   r   evalinteger
IndexErrorr   fill)r    r!   r"   textwidth
initindent
hangindents          r%   rh   rh      s     Taq!FGHHgQ0DEJJCIG./
	#Gd1g>J#Gd1g>J ZDD  		s   B6 6
CCs   filter(iterable[, expr])c                   ^ ^^ S[        T5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        T TTS   5      n[        T5      S:X  a  U U4S jnOUU U4S jnUR                  T TU5      $ )zoRemove empty elements from a list or a dict. If expr specified, it's
applied to each element to test emptiness.r   r   s#   filter expects one or two argumentsr   c                (   > U R                  TT5      $ r+   )tobool)wr    r!   s    r%   selectfilter_.<locals>.select   s    88GW--r&   c                   > [        U [        R                  5      (       d  [        R                  " [        S5      5      eTR                  TU R                  T5      5      n[        TUTS   5      $ )Ns   not filterable by expressionr   )	
isinstancer   mappabler   r   r   
overlaymaptomapevalboolean)rp   lmr"   r    r!   s     r%   rq   rr      s[    a!6!677&&q)H'IJJ##GQWWW-=>BwDG44r&   )r   r   r   r   evalwrappedfilter)r    r!   r"   iterablerq   s   ```  r%   filter_r}      si     Taq!GHII7GT!W5H
4yA~	.
	5 ??7GV44r&   s   formatnode(node)c                    [        U5      S:w  a  [        R                  " [        S5      5      eU R	                  US5      n[        XUS   5      nUR                  (       a  U$ [        R                  " U5      $ )z;Obtain the preferred form of a changeset hash. (DEPRECATED)r   s   formatnode expects one argumentr:   r   )	r   r   r   r   rE   r   	debugflagr   short)r    r!   r"   rJ   nodes        r%   
formatnoder      se     4yA~q!CDEE			'5	)BgQ0D	||  &&r&   s   mailmap(author)   repoc                l   [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      nU R                  US5      nU R                  US5      nSU;  a4  UR                  R                  S5      n[        R                  " U5      US'   [        R                  " US   U5      $ )zJReturn the author, updated according to the value
set in the .mailmap filer   s   mailmap expects one argumentr   rN   r   s   mailmaps   .mailmap)r   r   r   r   r   rE   wvfstryreadr   parsemailmapmapname)r    r!   r"   authorrY   rT   r7   s          r%   mailmapr      s     4yA~q!@ABB$q'2FWh/EGW-Dyy  -&33D9jeJ/88r&   s@   pad(text, width[, fillchar=' '[, left=False[, truncate=False]]])s!   text width fillchar left truncatec                   SU;  d  SU;  a  [         R                  " [        S5      5      e[        U UUS   [        S5      5      n[	        XUS   5      nSnSnSnSU;   aQ  [	        XUS   5      n[        [        R                  " U5      5      S:w  a  [         R                  " [        S	5      5      eS
U;   a  [        XUS
   5      nSU;   a  [        XUS   5      nU[        R                  " [        R                  " U5      5      -
  nUS:  a0  U(       a)  [        R                  " [        R                  " U5      X6S9$ US::  a  U$ U(       a  Xx-  U-   $ XGU-  -   $ )zPad text with a
fill character.s   texts   widths#   pad() expects two to four argumentss   pad() expects an integer widthF    s   fillcharr   s%   pad() expects a single fill characters   lefts   truncater   )leftside)r   r   r   rf   r   r   r   stripeffectsrx   r
   colwidthtrim)	r    r!   r"   rj   ri   truncateleftfillchar	fillwidths	            r%   padr      sS    dhd2q!GHIIX	
+,E gW6DHDHdg[0ABu!!(+,1""1%M#NOO$7T'];dwk1BC))%*<*<T*BCCI1}}}U//5uLLA~#d*****r&   s&   indent(text, indentchars[, firstline])c                   S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        XUS   5      n[	        XUS   5      nUn[        U5      S:X  a  [	        XUS   5      n[
        R                  " X4US9$ )zIndents all non-empty lines
with the characters given in the indentchars string. An optional
third parameter will override the indent for the first line only
if present.r   re   s'   indent() expects two or three argumentsr   r   )	firstline)r   r   r   r   r   r   indent)r    r!   r"   ri   r   r   s         r%   r   r   +  s     Taq!KLMMgQ0D$q'2FI
4yA~wa9	!!$)DDr&   s   get(dict, key)c                J   [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n[        XUS   5      n UR                  XU5      $ ! [        R                   a.  n[        S5      n[        R                  " [        U5      US9eSnAff = f)zGet an attribute/key from an object. Some keywords
are complex types. This function allows you to obtain the value of an
attribute on these types.r   s   get() expects two argumentsr   r   s&   get() expects a dict as first argumentrP   N)r   r   r   r   rz   
evalrawexp	getmemberbytes)r    r!   r"   dictargkeyerrrQ   s          r%   rU   rU   ?  s    
 4yA~q!?@AA'DG4G
WtAw
/C6  377 6:;uSz556s   A   B"4)BB"s    config(section, name[, default])c                \    U R                  US5      R                  n[        XX#[        5      $ )z5Returns the requested hgrc config option as a string.r:   )rE   config_configr   r    r!   r"   fns       r%   r   r   R  s+     
		'5	)	0	0B7Tz::r&   s$   configbool(section, name[, default])c                \    U R                  US5      R                  n[        XX#[        5      $ )z6Returns the requested hgrc config option as a boolean.r:   )rE   
configboolr   rx   r   s       r%   r   r   Y  s+     
		'5	)	4	4B7T{;;r&   s#   configint(section, name[, default])c                \    U R                  US5      R                  n[        XX#[        5      $ )z7Returns the requested hgrc config option as an integer.r:   )rE   	configintr   rf   r   s       r%   r   r   `  s+     
		'5	)	3	3B7T{;;r&   c                   S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        XUS   5      n[	        XUS   5      n[        U5      S:X  a  U" XUS   5      nU" XVU5      $ U" XV5      $ )Nr   re   s%   config expects two or three argumentsr   r   )r   r   r   r   evalstringliteral)r    r!   r"   configfn	defaultfnsectionnamedefaults           r%   r   r   g  s    Taq!IJKK
  $q':GWtAw7D
4yA~Gd1g6w//&&r&   s   if(expr, then[, else])c                    S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        XUS   5      nU(       a  [        XUS   5      $ [        U5      S:X  a  [        XUS   5      $ g)z;Conditionally execute based on the result of
an expression.r   re   s!   if expects two or three argumentsr   r   N)r   r   r   r   rx   r   )r    r!   r"   tests       r%   if_r   w  sq     Taq!EFGGwa1D'DG44	Ta'DG44 
r&   s*   ifcontains(needle, haystack, then[, else])c                t   S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        XUS   5      n [        XUS   5      nUR                  XU5      nU(       a  [        XUS   5      $ [        U5      S:X  a  [        XUS   5      $ g! [        R                   a    Sn NMf = f)	zJConditionally execute based
on whether the item "needle" is in "haystack".re   rc   s*   ifcontains expects three or four argumentsr   r   Fr   N)r   r   r   r   rz   r   contains)r    r!   r"   haystackneedlefounds         r%   
ifcontainsr     s     Taq!NOPP7T!W5HGd1g6!!'F; 'DG44	Ta'DG44 
  s   !B B76B7s    ifeq(expr1, expr2, then[, else])c                   S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        XUS   5      n[	        XUS   5      nX4:X  a  [        XUS   5      $ [        U5      S:X  a  [        XUS   5      $ g)z>Conditionally execute based on
whether 2 items are equivalent.re   rc   s$   ifeq expects three or four argumentsr   r   r   N)r   r   r   r   r   r   )r    r!   r"   r   rC   s        r%   ifeqr     s     Taq!HIJJgQ0Dwa1E}'DG44	Ta'DG44 
r&   s   join(list, sep)c                    S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        XUS   5      nSn[        U5      S:  a  [        XUS   5      nUR                  XU5      $ )z&Join items in a list with a delimiter.r   r   s!   join expects one or two argumentsr   r   )r   r   r   r   rz   r   rH   )r    r!   r"   joinsetjoiners        r%   rH   rH     sm     Taq!EFGG'DG4GF
4y1}Gd1g6<<&11r&   s   label(label, expr)c                    [        U5      S:w  a  [        R                  " [        S5      5      eU R	                  US5      n[        XUS   5      n[        XUS   5      nUR                  XE5      $ )zApply a label to generated content. Content with a label
applied can result in additional post-processing, such as
automatic colorization. In order to receive effects, labels must
have a dot, such as `log.secret` or `branch.active`.r   s   label expects two argumentsr:   r   r   )r   r   r   r   rE   r   r   label)r    r!   r"   rJ   thingr   s         r%   r   r     si     4yA~q!?@AA			'5	)Bwa1E gQ8E88E!!r&   s   latesttag([pattern])c                    [        U5      S:  a  [        R                  " [        S5      5      eSn[        U5      S:X  a  [	        XUS   5      n[
        R                  " XU5      $ )zThe global tags matching the given pattern on the
most recent globally tagged ancestor of this changeset.
If no such tags exist, the "{tag}" template resolves to
the string "null". See :hg:`help revisions.patterns` for the pattern
syntax.
r   s&   latesttag expects at most one argumentNr   )r   r   r   r   r   r   showlatesttags)r    r!   r"   patterns       r%   	latesttagr     sY     4y1}q!JKLLG
4yA~WtAw7$$Ww??r&   s   localdate(date[, tz])c                >   S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        U UUS   [        S5      5      n[        U5      S:  aX  Sn[        XUS   5      n[        U[        5      (       a!  [        R                  " U5      u  pFU(       a  SnUc   [        U5      nOO[        R                  " 5       S   n[        R                  " US   U45      $ ! [        [        4 a     [        R                  " [        S5      5      ef = f)zEConverts a date to the specified timezone.
The default is local date.r   r   s&   localdate expects one or two argumentsr   s$   localdate expects a date informationNs   localdate expects a timezone)r   r   r   r   r   r,   rt   r   r   parsetimezoneint	TypeError
ValueErrormakedater   r#   )r    r!   r"   r#   tzoffsettz	remainders          r%   	localdater     s    Taq!JKLLQ	
12D 4yA~473b%  "*"8"8"<HKr7  $$&q)d1gx011 z* K&&q)H'IJJKs   ,C, ,0Ds   max(iterable)c                *   [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n UR                  X5      $ ! [        R                   a.  n[        S5      n[        R                  " [        U5      US9eSnAff = f)zReturn the max of an iterabler   s   max expects one argumentr   s(   max first argument should be an iterablerP   N)r   r   r   r   rz   getmaxr   r    r!   r"   kwargsr|   r   rQ   s          r%   max_r          4yA~q!<=>>7T!W5H6w00 6<=uSz556   A B$)BBs   min(iterable)c                *   [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n UR                  X5      $ ! [        R                   a.  n[        S5      n[        R                  " [        U5      US9eSnAff = f)zReturn the min of an iterabler   s   min expects one argumentr   s(   min first argument should be an iterablerP   N)r   r   r   r   rz   getminr   r   s          r%   min_r     r   r   s	   mod(a, b)c                    [        U5      S:X  d  [        R                  " [        S5      5      eS n[        R
                  " XX2S   US   45      $ )z0Calculate a mod b such that a / b + a mod b == ar   s   mod expects two argumentsc                
    X-  $ r+    )abs     r%   <lambda>mod.<locals>.<lambda>&  s    r&   r   r   )r   r   r   r   r   runarithmetic)r    r!   r"   funcs       r%   modr     sP     t9>q!=>??D%%4a$q'2 r&   s   obsfateoperations(markers)c                >   [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n [
        R                  " U5      n[        R                  " USS9$ ! [        [        4 a"    [        S5      n[        R                  " U5      ef = f)CCompute obsfate related information based on markers (EXPERIMENTAL)r   s&   obsfateoperations expects one argumentr   s	   operationr   s6   obsfateoperations first argument should be an iterable)r   r   r   r   r,   r   markersoperationsr   
hybridlistr   KeyErrorr    r!   r"   markersr7   errmsgs         r%   obsfateoperationsr   ,  s     4yA~q!JKLL'DG4G'((1&&t,??x  'LMv&&'s   *A* *2Bs   obsfatedate(markers)c                @   [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n [
        R                  " U5      n[        R                  " USSS9$ ! [        [        4 a"    [        S5      n[        R                  " U5      ef = f)r   r   s    obsfatedate expects one argumentr   s   dates   %d %d)r   r$   s0   obsfatedate first argument should be an iterable)r   r   r   r   r,   r   markersdatesr   r   r   r   r   s         r%   obsfatedater   >  s     4yA~q!DEFF'DG4G'##G,&&t'xHHx  'FGv&&'s   +A+ +2Bs   obsfateusers(markers)c                H   [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n [
        R                  " U5      n[        R                  " USS9$ ! [        [        [        4 a"    [        S5      n[        R                  " U5      ef = f)r   r   s!   obsfateusers expects one argumentr   s   userr   s>   obsfateusers first argument should be an iterable of obsmakers)r   r   r   r   r,   r   markersusersr   r   r   r   r   )r    r!   r"   r   r7   msgs         r%   obsfateusersr   Q  s     4yA~q!EFGG'DG4G	$##G,&&t'::x, $
 s##$s   *A* *7B!s    obsfateverb(successors, markers)c                &   [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n[	        XUS   5      n [
        R                  " X45      $ ! [         a"    [        S5      n[        R                  " U5      ef = f)zFCompute obsfate related information based on successors (EXPERIMENTAL)r   s!   obsfateverb expects two argumentsr   r   s.   obsfateverb first argument should be countable)r   r   r   r   r,   r   obsfateverbr   )r    r!   r"   
successorsr   r   s         r%   r   r   f  s     4yA~q!EFGGWtAw7J'DG4G'"":77 'DEv&&'s   A$ $,Bs   relpath(path)c                    [        U5      S:w  a  [        R                  " [        S5      5      eU R	                  US5      n[        XUS   5      nUR                  U5      $ )zdConvert a repository-absolute path into a filesystem path relative to
the current working directory.r   s   relpath expects one argumentr   r   )r   r   r   r   rE   r   pathto)r    r!   r"   rT   paths        r%   relpathr   x  sW     4yA~q!@ABBGW-DgQ0D;;tr&   s   revset(query[, formatargs...])c                  ^ [        U5      S:  d  [        R                  " [        S5      5      e[	        XUS   5      nU R                  US5      mU4S jn[        U5      S:  a?  SnUSS  Vs/ s H  n[        XU5      PM     nnU" [        R                  " U/UQ76 5      nO<U R                  US5      n	U	R                  S0 5      n
UnXZ;   a  X   nOU" U5      nXU'   [        R                  " TUS	US
9$ s  snf )z4Execute a revision set query. See
:hg:`help revset`.r   s$   revset expects one or more argumentsr   c                |   > [         R                  " TR                  U [         R                  " T5      S9nU" T5      $ )N)lookup)	revsetmodrC   rJ   lookupfn)exprr`   rT   s     r%   queryrevset.<locals>.query  s-    OODGGT)2D2DT2JKwr&   r   NrN   s   revsetcaches   revision)r   cachekey)r   r   r   r   r   rE   r,   r   
formatspecrR   r   revslist)r    r!   r"   r_   r  r   r   
formatargsrevsrY   revsetcacherT   s              @r%   r   r     s     t9q=q!HIJJ
WtAw
/CGW-D 4y1}@DQRI1k'A6
IZ**3<<=  (3&&~r:#D:D#  t+LL Js   /C8s   rstdoc(text, style)c                    [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n[	        XUS   5      n[
        R                  " X4S/S9$ )zFormat reStructuredText.r   s   rstdoc expects two argumentsr   r   s   verbose)stylekeep)r   r   r   r   r   r   format)r    r!   r"   ri   r
  s        r%   rstdocr    sY     4yA~q!@ABBgQ0Dwa1E>>$:,??r&   s   search(pattern, text)c           	        [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n[	        XUS   5      n [
        R                  " U5      nU R                  5       [        [        R                  " UR                  5      5      -  nU(       aD  [        R                  " [        S5      SR                  S [        U5       5       5      US	.-  5      eUR                  U5      nU(       d  [        R                   " 5       $ S
UR#                  S5      0nUR%                  S ['        UR)                  5       S5       5       5        UR%                  [        R                  " UR+                  5       5      5        [        R,                  " USS9$ ! [
        R                   a#    [        R                  " [        S5      U-  5      ef = f)zLook for the first text matching the regular expression pattern.
Groups are accessible as ``{1}``, ``{2}``, ... in %-mapped template.r   s   search expects two argumentsr   r   s!   search got an invalid pattern: %ss2   invalid group %(group)s in search pattern: %(pat)ss   , c              3  ,   #    U  H
  nS U-  v   M     g7f)s   '%s'Nr   )r-   gs     r%   r0   search.<locals>.<genexpr>  s     $L:KQWq[:Ks   )s   groups   pat   0c              3  4   #    U  H  u  pS U-  U4v   M     g7f)s   %dNr   )r-   r?   r/   s      r%   r0   r    s     F)Euqy!n)Es   s   {0})tmpl)r   r   r   r   r   recompileknownresourcekeyssetr   byteskwargs
groupindexrH   sortedsearchr   mappingnonegroupr4   	enumerategroups	groupdictmappingdict)	r    r!   r"   patsrcpatre	badgroupsrC   ry   s	            r%   r  r    s    4yA~q!@ABB
WtAw
/C
WtAw
/CN

3
 ))+cU--./ I CD**$L&:K$LL
 	
 LLE''))
A	BIIF5<<>1)EFFIIh""5??#456##BV441 88 Nq!EFLMMNs   F! !7Gs   separate(sep, args...)s	   sep *argsc              #     #    SU;  a  [         R                  " [        S5      5      e[        XUS   5      nSnUS    H*  n[        XU5      nU(       d  M  U(       a  SnOUv   Uv   M,     g7f)z,Add a separator between non-empty arguments.s   seps&   separate expects at least one argumentTr)   FN)r   r   r   r   )r    r!   r"   sepfirstargargstrs          r%   separater,    sm      Tq!JKLL
WtF|
4CEG}Gc2EI s   A+A-s   shortest(node, minlength=4)c                &   S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        XUS   5      nSn[        U5      S:  a  [        U UUS   [        S5      5      nU R                  US5      nSUR                  R                  -  n[        U5      U:  a  U$ [        U5      U:X  a   [        U5      nO  [        R                  " XS5      nU(       d  U$ U R                  US5      n [        R"                  " XWXH5      $ ! [        R                   a    Us $ f = f! [        R                   a    UR                  R                  n N{[        R                    a    Us $ f = f! [        R$                   a    Us $ f = f)	z-Obtain the shortest representation of
a node.r   r   s'   shortest() expects one or two argumentsr   rc   s'   shortest() expects an integer minlengthr   rN   )r   r   r   r   r   rf   rE   nodeconstantsnodelenr   binasciiErrorr   resolvehexnodeidprefixWdirUnsupportedwdiridLookupErrorshortesthexnodeidprefixRepoLookupError)	r    r!   r"   hexnode	minlengthrT   
hexnodelenr   rY   s	            r%   shortestr;    sy    Taq!KLMM473GI
4y1}G89
	 GW-DT''///J
7|j 	W	#	w<D	11$@D
 NWh/E..t9LL ~~ 	N	
 $$ 	-%%,,D   	N	    s<   >D D0 =E7 D-,D-0*E4E43E47FFs   strip(text[, chars])c                   S[        U5      s=::  a  S::  d!  O  [        R                  " [        S5      5      e[	        XUS   5      n[        U5      S:X  a   [	        XUS   5      nUR                  U5      $ UR                  5       $ )zWStrip characters from a string. By default,
strips all leading and trailing whitespace.r   r   s"   strip expects one or two argumentsr   )r   r   r   r   r   r>   )r    r!   r"   ri   charss        r%   r>   r>     sr     Taq!FGHHgQ0D
4yA~7T!W5zz%  ::<r&   s%   sub(pattern, replacement, expression)c              #     #    [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n[	        XUS   5      n[	        XUS   5      n [
        R                  " U5      n UR                  XE5      v   g! [
        R                   a#    [        R                  " [        S5      U-  5      ef = f! [
        R                   a#    [        R                  " [        S5      U-  5      ef = f7f)	z4Perform text substitution
using regular expressions.re   s   sub expects three argumentsr   r   r   s   sub got an invalid pattern: %ss"   sub got an invalid replacement: %sN)r   r   r   r   r   r  r  sub)r    r!   r"   r#  rplr$  r%  s          r%   r?  r?  (  s      4yA~q!?@AA
WtAw
/C
WtAw
/C
WtAw
/CK

3Oii!!	 88 Kq!BCcIJJK
 88 Oq!FG#MNNOs0   AC>B
 6C 	C>
7CC>7C;;C>s   startswith(pattern, text)c                    [        U5      S:w  a  [        R                  " [        S5      5      e[	        XUS   5      n[	        XUS   5      nUR                  U5      (       a  U$ g)zeReturns the value from the "text" argument
if it begins with the content from the "pattern" argument.r   s    startswith expects two argumentsr   r   r&   )r   r   r   r   r   
startswith)r    r!   r"   patnri   s        r%   rB  rB  ?  s]     4yA~q!DEFFgQ0DgQ0Dtr&   s   subsetparents(rev, revset)s
   rev revsetc                   SU;  d  SU;  a  [         R                  " [        S5      5      eU R                  US5      n[        R
                  " XUS   5      n[        R                  " XUS   5      n[        U[        R                  5      (       d  [         R                  " [        S5      5      eUR                  X5      nUR                  nU(       aI  U R                  US5      nUR                  S0 5      n	Xy;   a  X   n
O0[        R                  " X65      n
XU'   O[        R                  " X6US9n
[        R                  " X:R                  U5      5      $ )	z@Look up parents of the rev in the sub graph given by the revset.s   revs   revsets#   subsetparents expects two argumentsr   s&   subsetparents expects a queried revsetrN   s   subsetparentswalker)startrev)r   r   r   rE   r   rf   rz   rt   r  tovaluer  rR   r   subsetparentswalker
parentsset)r    r!   r"   rT   rV   qsubsetr   rY   walkercachewalkers              r%   subsetparentsrM  N  s)    TYd2q!GHIIGW-D

"
"7T&\
BC 	  4	?CAa..//q!JKLLYYw(F
**C
  (3&&'=rB %F..t<F% **4#F  '8'8'=>>r&   s   word(number, text[, separator])c                   S[        U5      s=::  a  S::  d-  O  [        R                  " [        S5      [        U5      -  5      e[	        U UUS   [        S5      5      n[        XUS   5      n[        U5      S:X  a  [        XUS   5      nOSnUR                  U5      nU[        U5      :  d  U[        U5      * :  a  gXc   $ )	z"Return the nth word from a string.r   re   s+   word expects two or three arguments, got %dr   s   word expects an integer indexr   Nr&   )r   r   r   r   rf   r   split)r    r!   r"   numri   splittertokenss          r%   wordrS  u  s     Ta<=D	I
 	
 Q	
*+C gQ0D
4yA~gQ8ZZ!F
c&kSCK</{r&   c                \    UR                   R                  5        H  u  p4U[        U'   M     g)z2Load template function from specified registrarobjN)_tabler5   funcs)rJ   extnameregistrarobjr   r   s        r%   loadfunctionrY    s&    "))//1
d 2r&   )R
__future__r   r0  r  i18nr   r   r    r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   utilsr   r   r   rz   r,   rx   r   rf   r   r   rV  templatefuncr#   r8   rG   rZ   ra   rh   r}   r   r   r   r   rU   r   r   r   r   r   r   r   rH   r   r   r   r   r   r   r   r   r   r   r   r  r  r,  r;  r>   r?  rB  rM  rS  rY  valuesi18nfunctionsr   r&   r%   <module>ra     sB   #  	      $
 $$
&&&&&&  &&$$
 22  	%%e, "#+ $+0 '1BC) D)( 0FE?0 	VX4F$$2 6(3J 4J BCE DE8 )*5 +5. !UG4
' 5
'  GX+>?9 @9$ I0&+	&+R 78E 9E&  6 !6$ 1UGD; E; 5H< I< 4wG< H<'  '(5 )5 ;<5 =5( 125 35  !
2 "
2 #ug6" 7"$ %&@ '@" &'2 (2@ 6  6 6  6 l	 	 +,' -'" %&' ''$ &'$ ($( 12' 3'" '3	 4	 /7H:MNM OM< $%	@ &	@ &'#5 (#5L '> ?& ,7JK) L)X %& ' 67O 8O, *+ , !x 
?
?D 01 28 r&   