
    6h<                       S SK J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
JrJrJrJrJrJrJr  SSKJrJrJr  \R,                  r\R.                  r0 r\R2                  " \5      r\" S\S	9S
 5       r/ SQr\" S\R:                  S	9ScS j5       r\" S\S	9S 5       rS r \" S5      S 5       r!\" S5      S 5       r"\" S5      S 5       r#\" S\S	9S 5       r$\" S\S	9S 5       r%\" S\S	9S 5       r&\" S\S	9S 5       r'Sq(Sq)SdS jr*\" S \S	9S! 5       r+\" S"\S	9S# 5       r,\" S$\S	9S% 5       r-\" S&\S	9S' 5       r.\" S(\R:                  S	9S) 5       r/\" S*\R:                  S	9S+ 5       r0\" S,\R:                  S	9S- 5       r1SeS. jr2\" S/5      SfS0 j5       r3\" S1\S	9S2 5       r4\" S3\S	9S4 5       r5\" S5\S	9S6 5       r6\" S7\S	9S8 5       r7\" S9\S	9S: 5       r8\" S;5      S< 5       r9\" S=\S	9S> 5       r:\" S?\R:                  S	9S@ 5       r;\" SA\R:                  S	9SB 5       r<\" SC\S	9SD 5       r=\" SE\S	9SF 5       r>\" SG\R:                  S	9SH 5       r?\" SI\S	9SJ 5       r@\" SK\S	9SL 5       rA\" SM\S	9SN 5       rB\" SO\S	9SP 5       rC\" SQ\S	9SR 5       rD\" SS\S	9ST 5       rE\" SU\S	9SV 5       rF\" SW\S	9SX 5       rG\" SY\S	9SZ 5       rH\" S[\S	9S\ 5       rI\" S]\S	9S^ 5       rJ\" S_\S	9S` 5       rKSa rLSb rM\R                  5       rOg)g    )annotationsN   )_hex)encodingerrorpycompat	registrarsmartsettemplateutilurlutil)cborutildateutil
stringutils	   addbreaks)intypec                &    U R                  SS5      $ )zRAny text. Add an XHTML "<br />" tag before the end of
every line except the last.
   
s   <br/>
)replacetexts    ;/usr/lib/python3/dist-packages/mercurial/templatefilters.py	addbreaksr   ,   s    
 <<z**    ))s   yeari3   Y)s   monthi '    M)s   weeki:	    W)s   dayiQ    d)s   houri     h)s   minute<      m)s   secondr      ss   agec                  ^^ S mUU4S jn[         R                   " 5       nU S   nSnXC:  a.  Sn[        S[        XC-
  5      5      nU[        S   S   S-  :  a  gO@[        S[        X4-
  5      5      nU[        S   S   S	-  :  a  [        R
                  " U 5      $ [         H9  u  pxn	Xh-  n
U
S	:  d  US:X  d  M  U(       a  S
U" XzU	5      -  s  $ SU" XzU	5      -  s  $    g)zkDate. Returns a human-readable date/time difference between the
given date/time and the current date/time.
c                    US:X  a  U $ U S-   $ )Nr   r#    )tcs     r   pluralage.<locals>.pluralE   s    6H4xr   c                8   > T(       a  SX4-  $ SUT" X5      4-  $ )Ns   %d%ss   %d %sr&   )r'   r(   aabbrevr)   s      r   fmtage.<locals>.fmtJ   s'    aV##1fQl+++r   r   FTr      s   in the distant future   s   %s from nows   %s agoN)timemaxint	agescalesr   	shortdate)dater-   r.   nowthenfuturedeltar'   sr,   nr)   s    `         @r   ager>   ?   s    
,
 ))+C7DFzAs4:'9Q<?R''+ ( As3:'9Q<?Q&&%%d++aJ6Q!V%A!44s1|++ r   s   basenamec                @    [         R                  R                  U 5      $ )zAny text. Treats the text as a path, and returns the last
component of the path after splitting by the path separator.
For example, "foo/bar/baz" becomes "baz" and "foo/bar//" becomes "".
)ospathbasenamerA   s    r   rB   rB   d   s     77D!!r   c                Z    [        U [        R                  5      (       a  [        U 5      $ U $ N)
isinstancer   abstractsmartsetlistobjs    r   _tocborencodablerK   m   s$    #x0011CyJr   s   cborc                    [         R                  " [        U 5      n SR                  [        R
                  " U 5      5      $ )z0Any object. Serializes the object to CBOR bytes.r   )r
   rapplyrK   joinr   streamencoderI   s    r   cborrP   s   s/     //*C
0C88H))#.//r   s	   commondirc                   S n U (       d  gU  Vs/ s H%  o"R                  S5      R                  S5      SS PM'     nn[        U5      S:X  a  SR                  US   5      $ [	        U5      n[        U5      nSR                  U" XE5      5      $ s  snf ! [         a     [        R                  " [        S5      5      ef = f)	a  List of text. Treats each list item as file name with /
as path separator and returns the longest common directory
prefix shared by all list items.
Returns the empty string if no common prefix exists.

The list items are not normalized, i.e. "foo/../bar" is handled as
file "bar" in the directory "foo/..". Leading slashes are ignored.

For example, ["foo/bar/baz", "foo/baz/bar"] becomes "foo" and
["foo/bar", "baz"] becomes "".
c                   [        U 5      [        U5      :  a  US [        U 5       n O&[        U5      [        U 5      :  a  US [        U 5       nX:X  a  U $ [        [        U 5      5       H  nX   X   :w  d  M  U S U s  $    U $ rE   )lenrange)r,   bis      r   commoncommondir.<locals>.common   sw    q6CF?(CFAVc!f_(CFA6Hs1vAtqt|!u  r   r      /Nr   r   s   argument is not a list of text)
lstripsplitrS   rN   minr3   	TypeErrorr	   
ParseErrorr   )filelistrW   fdirlistr,   rU   s         r   	commondirrc   {   s    
E<DEHq88D>''-cr2HEw<199WQZ((LL yy&& F  Eq!BCDDEs&   B B ,B$B ",B B *B>s   countc                t     [        U 5      $ ! [         a     [        R                  " [	        S5      5      ef = f)z/List or text. Returns the length as an integer.s   not countable)rS   r^   r	   r_   r   )rV   s    r   countre      s6    41v 4q!12334s   
 *7s   dirnamec                @    [         R                  R                  U 5      $ )zvAny text. Treats the text as a path, and strips the last
component of the path after splitting by the path separator.
)r@   rA   dirnamerC   s    r   rg   rg      s    
 77??4  r   s   domainc                |    U R                  S5      nUS:X  a  gXS-   S n U R                  S5      nUS:  a  U SU n U $ )zAny text. Finds the first string that looks like an email
address, and extracts just the domain component. Example: ``User
<user@example.com>`` becomes ``example.com``.
   @rZ   r   r   N   >r   )find)authorra   s     r   domainrm      sN     	DABwEG_FDAAvMr   s   emailc                .    [         R                  " U 5      $ )zAny text. Extracts the first string that looks like an email
address. Example: ``User <user@example.com>`` becomes
``user@example.com``.
)r   emailr   s    r   ro   ro      s     D!!r   s   escapec                P    [         R                  " U R                  SS5      S5      $ )zxAny text. Replaces the special XML/XHTML characters "&", "<"
and ">" with XML entities, and filters out NUL characters.
    r   T)r   escaper   r   s    r   rr   rr      s     
 ::dll5#.55r   c                z  ^  [         c;  [        R                  " S[        R                  5      q [        R                  " S5      qU 4S jnSR                  U" 5        VVs/ s HI  u  pV[        R                  " [        R                  S[        R                  " XQ5      5      UUU5      U-   PMK     snn5      $ s  snnf )z/fill many paragraphs with optional indentation.s   (

|
\s*[-*]\s*)s     +c               3    >#    Sn  [         R                  TU 5      nU(       d  [        R                  " TU S  5      n[	        U5      nUS:  aA  X#S-
     R                  5       (       a'  US-  nUS:  a  X#S-
     R                  5       (       a  M'  [        R                  " US U 5      [        R                  " X#S  5      4v   g TXR                  S5       UR                  S5      4v   UR                  S5      n M  7f)Nr   r   )
para_researchr   unifromlocalrS   isspace
unitolocalstartgroupend)rz   muctextwr   s       r   	findparasfill.<locals>.findparas   s     tU+A!..tEF|<K!e1u 5 5 7 7FA !e1u 5 5 7 7 ''r
3''r
3  uwwqz*AGGAJ66EE!HE s   B
C<A-C<r       )	ru   recompileMspace_rerN   r   wrapsub)r   width
initindent
hangindentr   pararests   `      r   fillr      s     **5rtt<::g&" 88 (k		
 *
 OOT:??4#?@	  *		
 		
s   AB7
s   fill68c                    [        U S5      $ )z.Any text. Wraps the text to fit in 68 columns.D   r   r   s    r   fill68r          b>r   s   fill76c                    [        U S5      $ )z.Any text. Wraps the text to fit in 76 columns.L   r   r   s    r   fill76r     r   r   s	   firstlinec                .    [         R                  " U 5      $ )z)Any text. Returns the first line of text.)r   	firstliner   s    r   r   r          %%r   s   hexc                    [        U 5      $ )z_Any text. Convert a binary Mercurial node identifier into
its long hexadecimal representation.
r   r   s    r   	hexfilterr     s    
 t9r   s   hgdatec                    SU -  $ )zcDate. Returns the date as a pair of numbers: "1157407993
25200" (Unix timestamp, timezone offset).
s   %d %dr&   r   s    r   hgdater     s    
 d?r   s   isodatec                0    [         R                  " U S5      $ )zEDate. Returns the date in ISO 8601 format: "2009-08-18 13:00
+0200".
s   %Y-%m-%d %H:%M %1%2r   datestrr   s    r   isodater   #  s    
 D"899r   s
   isodatesecc                0    [         R                  " U S5      $ )z|Date. Returns the date in ISO 8601 format, including
seconds: "2009-08-18 13:00:13 +0200". See also the rfc3339date
filter.
s   %Y-%m-%d %H:%M:%S %1%2r   r   s    r   
isodatesecr   +  s     D";<<r   c                   ^^^^^ U R                  5       m[        T5      mU SS S:H  mUUUUU4S jnSR                  U" 5       5      $ )z;indent each non-empty line of text after first with prefix.rZ   Nr   c               3     >#    [        T5       HD  n TU    nUR                  5       (       a  U (       a  TOTv   Uv   U TS-
  :  d	  T(       d  M@  Sv   MF     g 7f)Nr   r   )rT   strip)rV   lendswithnewliner   lines	num_linesprefixs     r   indenterindent.<locals>.indenter:  sM     y!AaAwwyy !fy0G9q= OO "s   AA	Ar   )
splitlinesrS   rN   )r   r   r   r   r   r   r   s    `` @@@r   indentr   4  sE    OOEE
I23i5(O  88HJr   s   jsonc           
        U c  gU SL a  gU SL a  g[        U [        [        45      (       a  [        R                  " U 5      $ [        U [
        5      (       a  S[        R                  " XS9-  $ [        U [        5      (       a  [        R                  " SU -  5      e[        U S	5      (       ad  [        U R                  5       5       VVs/ s H'  u  p#S
[        R                  " X!S9[        X15      4-  PM)     nnnSSR                  U5      -   S-   $ [        U S5      (       a2  U  Vs/ s H  n[        XQ5      PM     nnSSR                  U5      -   S-   $ [        R                  " SU -  5      es  snnf s  snf )z;Any object. Serializes the object to a JSON formatted text.s   nullFs   falseTs   trues   "%s")paranoids)   Mercurial only does output with bytes: %rkeyss   "%s": %s   {s   ,    }__iter__   [   ]s   cannot encode %r)rF   r4   floatr
   bytestrbytesr   
jsonescapestrr	   ProgrammingErrorhasattrsorteditemsjsonrN   )rJ   r   kvoutrV   s         r   r   r   F  sd    {			C#u	&	&$$	C		,,SDDD	C		$$83>
 	
 
f		 syy{+
 , ""18$q:KLM+ 	 

 ejjo%,,	j	!	!*-.#QtA #.ejjo%,,

 
 !4s!:
;;
 /s   	.E-&E3s   lowerc                .    [         R                  " U 5      $ )z)Any text. Converts the text to lowercase.)r   lowerr   s    r   r   r   d       >>$r   s   nonemptyc                    U =(       d    S$ )z2Any text. Returns '(none)' if the string is empty.s   (none)r&   r   s    r   nonemptyr   j  s     9r   s	   obfuscatec           	         [        U [        R                  " [        R                  5      S5      n SR	                  U  Vs/ s H  nS[        U5      -  PM     sn5      $ s  snf )zIAny text. Returns the input text rendered as a sequence of
XML entities.
r   r   s   &#%d;)r   r
   sysstrr   rN   ord)r   r(   s     r   	obfuscater   p  sK    
 tX__X%6%67DD8851XA&5665s   As   permissionsc                     SU ;   a  gSU ;   a  gg)N   ls
   lrwxrwxrwx   xs
   -rwxr-xr-xs
   -rw-r--r--r&   )flagss    r   permissionsr   y  s    u}u}r   s   personc                .    [         R                  " U 5      $ )zUAny text. Returns the name before an email address,
interpreting it as per RFC 5322.
)r   person)rl   s    r   r   r     s    
 V$$r   s   reversec                    [        U [        5      (       a  [        R                  " U SSS2   SS9$ [        R
                  " [        S5      5      e)z'List. Reverses the order of list items.NrZ   s   itemnames   not reversible)rF   rH   r   
hybridlistr	   r_   r   )list_s    r   reverser     sC     %&&uTrT{AA


1./
00r   s	   revescapec                J    [         R                  U SS9R                  SS5      $ )zAny text. Escapes all "special" characters, except @.
Forward slashes are escaped twice to prevent web servers from prematurely
unescaping them. For example, "@foo bar/baz" becomes "@foo%20bar%252Fbaz".
s   /@)saferY   s   %252F)urlreqquoter   r   s    r   	revescaper     s$     <<5<)11$AAr   s   rfc3339datec                0    [         R                  " U S5      $ )zhDate. Returns a date using the Internet date format
specified in RFC 3339: "2009-08-18T13:00:13+02:00".
s   %Y-%m-%dT%H:%M:%S%1:%2r   r   s    r   rfc3339dater     s    
 D";<<r   s
   rfc822datec                0    [         R                  " U S5      $ )zeDate. Returns a date using the same format used in email
headers: "Tue, 18 Aug 2009 13:00:13 +0200".
s   %a, %d %b %Y %H:%M:%S %1%2r   r   s    r   
rfc822dater     s    
 D"?@@r   s   shortc                    U SS $ )z`Changeset hash. Returns the short form of a changeset hash,
i.e. a 12 hexadecimal digit string.
N   r&   r   s    r   shortr     s    
 9r   s   shortbisectc                8    U (       a  U SS R                  5       $ g)zAny text. Treats `label` as a bisection status, and
returns a single-character representing the status (G: good, B: bad,
S: skipped, U: untested, I: ignored). Returns single space if `text`
is not a valid bisection status.
r   r   r   )upper)labels    r   shortbisectr     s     Qqz!!r   s	   shortdatec                .    [         R                  " U 5      $ )z'Date. Returns a date like "2006-09-18".)r   r6   r   s    r   r6   r6          d##r   s	   slashpathc                .    [         R                  " U 5      $ )z8Any text. Replaces the native path separator with slash.)r   pconvertrC   s    r   	slashpathr     s     ==r   s
   splitlinesc                H    [         R                  " U R                  5       SS9$ )z*Any text. Split text into a list of lines.s   liner   )r   r   r   r   s    r   r   r     s     ""4??#47CCr   s   stringescapec                .    [         R                  " U 5      $ rE   )r   	escapestrr   s    r   stringescaper     s    %%r   s	   stringifyc                    U $ )z[Any type. Turns the value into text by converting values into
text and concatenating them.
r&   )things    r   	stringifyr     s	    
 Lr   s   stripdirc                    [         R                  R                  U 5      nUS:X  a  [         R                  R                  U 5      $ U$ )zqTreat the text as path and strip a directory level, if
possible. For example, "foo" and "foo/bar" becomes "foo".
r   )r@   rA   rg   rB   )r   dirs     r   stripdirr     s7    
 ''//$
C
czww%%
r   s	   tabindentc                    [        U S5      $ )zfAny text. Returns the text, with every non-empty line
except the first starting with a tab character.
   	)r   r   s    r   	tabindentr     s    
 $r   s   upperc                .    [         R                  " U 5      $ )z)Any text. Converts the text to uppercase.)r   r   r   s    r   r   r     r   r   s	   urlescapec                ,    [         R                  U 5      $ )zXAny text. Escapes all "special" characters. For example,
"foo bar" becomes "foo%20bar".
)r   r   r   s    r   	urlescaper     s    
 <<r   s   userc                .    [         R                  " U 5      $ )zIAny text. Returns a short representation of a user name or email
address.)r   	shortuserr   s    r   
userfilterr     s     %%r   s	   emailuserc                .    [         R                  " U 5      $ )z7Any text. Returns the user portion of an email address.)r   	emailuserr   s    r   r  r    r   r   s   utf8c                .    [         R                  " U 5      $ )z>Any text. Converts from the local character encoding to UTF-8.)r   	fromlocalr   s    r   utf8r    r   r   s	   xmlescapec                    U R                  SS5      R                  SS5      R                  SS5      R                  SS5      R                  S	S
5      n [        R                  " SSU 5      $ )N   &s   &amp;   <s   &lt;rj   s   &gt;   "s   &quot;   's   &#39;s
   [ --]r   )r   r   r   r   s    r   	xmlescaper    s]     	T8$	w		w		y	!	x	  	 6614>>r   c                L    U(       a  U H  u  p#UR                  X05      n M     U $ )zu:websub: Any text. Only applies to hgweb. Applies the regular
expression replacements defined in the websub section.
)r   )r   websubtableregexpformats       r   websubr    s&     )NF::f+D *Kr   c                \    UR                   R                  5        H  u  p4U[        U'   M     g)z0Load template filter from specified registrarobjN)_tabler   filters)uiextnameregistrarobjr   funcs        r   
loadfilterr  )  s&    "))//1
 2r   )F)r   r   )r   )T)P
__future__r   r@   r   r2   i18nr   noder    r   r	   r
   r   r   r   r   r   utilsr   r   r   urlerrr   r  templatefilterr   r   r5   r7   r>   rB   rK   rP   rc   re   rg   rm   ro   rr   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r6   r   r   r   r   r   r   r   r   r  r  r  r  r  r  valuesi18nfunctionsr&   r   r   <module>r$     s0   # 	 	   	 	 	  
	 ))'2 U++ ,+	 |001!, 2!,H E*" +" 0 0 &E &ER 4 4 
5)! *! 	%( ) '" (" 	%(6 )6 #L 	%( )
 	%( )
 U+& ,&
 u% & 	,"3"34 5 
<#4#45: 6: l&7&78= 9= $ < <: '  ( 
 E* +
 U+7 ,7 u- . 	%(% )% 
1 1 U+B ,B |'8'89= := l&7&78A 9A ' ( u- . \%6%67$ 8$
 U+ ,
 e,D -D
 .& /& U+ , E* + U+ , '  ( 
 U+ , && '& U+& ,&
 &$ '$
 U+? ,?  r   