
    	^c<                     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 ddlmZmZmZ ej        Zej        Zi Z ej        e          Z ede          d	             Zg d
Z edej                  ded            Z ede          d             Zd Z ed          d             Z ed          d             Z  ed          d             Z! ede          d             Z" ede          d             Z# ede          d             Z$ ede          d             Z%da&da'dfd Z( ed!e          d"             Z) ed#e          d$             Z* ed%e          d&             Z+ ed'e          d(             Z, ed)ej                  d*             Z- ed+ej                  d,             Z. ed-ej                  d.             Z/dgd/Z0 ed0          dhd2            Z1 ed3e          d4             Z2 ed5e          d6             Z3 ed7e          d8             Z4 ed9e          d:             Z5 ed;e          d<             Z6 ed=          d>             Z7 ed?e          d@             Z8 edAej                  dB             Z9 edCej                  dD             Z: edEe          dF             Z; edGe          dH             Z< edIej                  dJ             Z= edKe          dL             Z> edMe          dN             Z? edOe          dP             Z@ edQe          dR             ZA edSe          dT             ZB edUe          dV             ZC edWe          dX             ZD edYe          dZ             ZE ed[e          d\             ZF ed]e          d^             ZG ed_e          d`             ZH edae          db             ZIdc ZJdd ZKeL                                ZMdS )i    N   )_hex)encodingerrorpycompat	registrarsmartsettemplateutilurlutil)cborutildateutil
stringutils	   addbreaks)intypec                 .    |                      dd          S )zZAny 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   ageFc                    d fd}t          j                     }| d         }d}||k    r?d}t          dt          ||z
                      }|t          d         d         dz  k    rdS nNt          dt          ||z
                      }|t          d         d         d	z  k    rt	          j        |           S t          D ]=\  }}}	||z  }
|
d	k    s|dk    r&|rd
 |||
|	          z  c S d |||
|	          z  c S >dS )zsDate. Returns a human-readable date/time difference between the
    given date/time and the current date/time.
    c                     |dk    r| S | dz   S )Nr   r"    )tcs     r   pluralzage.<locals>.pluralD   s    66H4xr   c                 8    rd||fz  S d| | |          fz  S )Ns   %d%ss   %d %sr%   )r&   r'   aabbrevr(   s      r   fmtzage.<locals>.fmtI   s4     	$aV##1ffQll+++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;   >   sZ     
, , , , , ,
 )++C7DFczzAs4#:''9Q<?R'''++ ( As3:''9Q<?Q&&&%d+++ , ,1aQJ66Q!VV 5%Aq!4444ss1a||++++ , ,r   s   basenamec                 @    t           j                            |           S )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r>   s    r   r?   r?   c   s     7D!!!r   c                 X    t          | t          j                  rt          |           S | S N)
isinstancer   abstractsmartsetlistobjs    r   _tocborencodablerH   l   s(    #x011 CyyJr   s   cborc                     t          j        t          |           } d                    t	          j        |                     S )z0Any object. Serializes the object to CBOR bytes.r   )r	   rapplyrH   joinr   streamencoderF   s    r   cborrM   r   s3     /*C
0
0C88H)#..///r   s	   commondirc                 ^   d }	 | sdS d | D             }t          |          dk    rd                    |d                   S t          |          }t          |          }d                     |||                    S # t          $ r" t          j        t          d                    w xY w)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                 n   t          |           t          |          k    r|d t          |                    } n7t          |          t          |           k    r|d t          |                    }| |k    r| S t          t          |                     D ] }| |         ||         k    r| d |         c S !| S rB   )lenrange)r*   bis      r   commonzcommondir.<locals>.common   s    q66CFF??(CFF(AAVVc!ff__(CFF(A66Hs1vv 	 	Atqt||!u r   r   c                 n    g | ]2}|                     d                               d           dd         3S )   /N)lstripsplit).0fs     r   
<listcomp>zcommondir.<locals>.<listcomp>   s9    EEEq188D>>''--crc2EEEr   r   rV   r   s   argument is not a list of text)rP   rK   minr0   	TypeErrorr   
ParseErrorr   )filelistrT   dirlistr*   rR   s        r   	commondirrb   z   s    
 
 
E 	3EEHEEEw<<199WQZ(((LLLL yy1&&& E E Eq!BCCDDDEs   B  9B  <B   ,B,s   countc                     	 t          |           S # t          $ r" t          j        t	          d                    w xY w)z/List or text. Returns the length as an integer.s   not countable)rP   r^   r   r_   r   )rS   s    r   countrd      sG    41vv 4 4 4q!1223334s    ,=s   dirnamec                 @    t           j                            |           S )z~Any text. Treats the text as a path, and strips the last
    component of the path after splitting by the path separator.
    )r=   r>   dirnamer@   s    r   rf   rf      s    
 7??4   r   s   domainc                     |                      d          }|dk    rdS | |dz   d         } |                      d          }|dk    r
| d|         } | S )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``.
       @rW   r   r   N   >r   )find)authorr[   s     r   domainrl      s`     	DABwwsAEGG_FDAAvvMr   s   emailc                 *    t          j        |           S )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   rn   rn      s     D!!!r   s   escapec                 T    t          j        |                     dd          d          S )zAny text. Replaces the special XML/XHTML characters "&", "<"
    and ">" with XML entities, and filters out NUL characters.
        r   T)r   escaper   r   s    r   rq   rq      s$    
 :dll5#..555r   r   c                      t           3t          j        dt          j                  a t          j        d          a fd}d                    fd |            D                       S )z/fill many paragraphs with optional indentation.Ns   (

|
\s*[-*]\s*)s     +c               3   B  K   d} 	 t                               |           }|st          j        | d                    }t	          |          }|dk    rE||dz
                                           r(|dz  }|dk    r||dz
                                           (t          j        |d |                   t          j        ||d                    fV  d S | |                    d                   |                    d          fV  |	                    d          } )Nr   Tr   )
para_researchr   unifromlocalrP   isspace
unitolocalstartgroupend)ry   muctextwr   s       r   	findparaszfill.<locals>.findparas   s(     	tU++A 	!.tEFF|<<KK!eeq1u 5 5 7 7eFA !eeq1u 5 5 7 7e 'rr
33'qrr
33    uqwwqzz)*AGGAJJ6666EE!HHE	r   r   c                     g | ]K\  }}t          j        t                              d t          j        |                              |z   LS )    )r   wrapspace_resub)rZ   pararest
hangindent
initindentwidths      r   r\   zfill.<locals>.<listcomp>   sk     		
 		
 		
 d OT:?4#?#?@@	  		
 		
 		
r   )rt   recompileMr   rK   )r   r   r   r   r   s   ```` r   fillr      s     *5rt<<:g&&    " 88		
 		
 		
 		
 		
 		
 (ikk		
 		
 		
  r   s   fill68c                 "    t          | d          S )z.Any text. Wraps the text to fit in 68 columns.D   r   r   s    r   fill68r           b>>r   s   fill76c                 "    t          | d          S )z.Any text. Wraps the text to fit in 76 columns.L   r   r   s    r   fill76r     r   r   s	   firstlinec                 *    t          j        |           S )z)Any text. Returns the first line of text.)r   	firstliner   s    r   r   r          %%%r   s   hexc                      t          |           S )zgAny text. Convert a binary Mercurial node identifier into
    its long hexadecimal representation.
    r   r   s    r   	hexfilterr     s    
 t99r   s   hgdatec                     d| z  S )zkDate. 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                 ,    t          j        | d          S )zMDate. 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99r   s
   isodatesecc                 ,    t          j        | d          S )zDate. 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                     |                                  t                    | dd         dk    fd}d                     |                      S )z;indent each non-empty line of text after first with prefix.rW   Nr   c               3      K   t                    D ]9} |          }|                                r| rnV  |V  | dz
  k     srdV  :d S )Nr   r   )rQ   strip)rS   lendswithnewliner   lines	num_linesprefixs     r   indenterzindent.<locals>.indenter9  s}      y!! 	 	AaAwwyy 1 !0ffy000GGG9q=  O 	 	r   r   )
splitlinesrP   rK   )r   r   r   r   r   r   r   s    `` @@@r   indentr   3  sz    OOEE

I233i5(O         88HHJJr   s   jsonTc                    | dS | du rdS | du rdS t          | t          t          t          f          rt          j        |           S t          | t
                    rdt          j        |           z  S t          | t          d	                    rt          j
        d
| z            t          j        | d          rHfdt          |                                           D             }dd                    |          z   dz   S t          j        | d          r)fd| D             }dd                    |          z   dz   S t          j
        d| z            )z;Any object. Serializes the object to a JSON formatted text.Ns   nullFs   falseTs   trues   "%s"paranoid s)   Mercurial only does output with bytes: %rs   keysc                 h    g | ].\  }}d t          j        |          t          |          fz  /S )s   "%s": %sr   )r   
jsonescapejson)rZ   kvr   s      r   r\   zjson.<locals>.<listcomp>W  sW     
 
 
 1 "1x888$q(:K:KLM
 
 
r      {s   ,    }s   __iter__c                 0    g | ]}t          |          S r%   )r   )rZ   rS   r   s     r   r\   zjson.<locals>.<listcomp>^  s#    ...QtAx  ...r      [   ]s   cannot encode %r)rC   r1   floatr	   bytestrbytesr   r   typer   ProgrammingErrorr   safehasattrsorteditemsrK   )rG   r   outs    ` r   r   r   E  s    {w	x	w	C#sE*	+	+ -$$$	C		 -,S8DDDDD	Cc	#	# -$83>
 
 	
 
	#w	'	' 	-
 
 
 
 syy{{++
 
 

 ejjoo%,,		#{	+	+ -....#...ejjoo%,,

 !4s!:
;
;;r   s   lowerc                 *    t          j        |           S )z)Any text. Converts the text to lowercase.)r   lowerr   s    r   r   r   c       >$r   s   nonemptyc                 
    | pdS )z2Any text. Returns '(none)' if the string is empty.s   (none)r%   r   s    r   nonemptyr   i  s     9r   s	   obfuscatec                     t          | t          j        t          j                  d          } d                    d | D                       S )zQAny text. Returns the input text rendered as a sequence of
    XML entities.
    r   r   c                 2    g | ]}d t          |          z  S )s   &#%d;)ord)rZ   r'   s     r   r\   zobfuscate.<locals>.<listcomp>u  s#    5551XA&555r   )strr	   sysstrr   rK   r   s    r   	obfuscater   o  sC    
 tX_X%677DDD8855555666r   s   permissionsc                     d| v rdS d| v rdS dS )N   ls
   lrwxrwxrwx   xs
   -rwxr-xr-xs
   -rw-r--r--r%   )flagss    r   permissionsr   x  s#    u}}}u}}}=r   s   personc                 *    t          j        |           S )z]Any text. Returns the name before an email address,
    interpreting it as per RFC 5322.
    )r   person)rk   s    r   r   r     s    
 V$$$r   s   reversec                     t          | t                    rt          j        | ddd         d          S t	          j        t          d                    )z'List. Reverses the order of list items.NrW   s   itemnames   not reversible)rC   rE   r   
hybridlistr   r_   r   )list_s    r   reverser     sQ     % B&uTTrT{AAAA

1.//
0
00r   s	   revescapec                 b    t                               | d                              dd          S )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   /@)saferV   s   %252F)urlreqquoter   r   s    r   	revescaper     s*     <<5<))11$AAAr   s   rfc3339datec                 ,    t          j        | d          S )zpDate. 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                 ,    t          j        | d          S )zmDate. 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                     | dd         S )zhChangeset 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                 B    | r| dd                                          S dS )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+      "QqSz!!!4r   s	   shortdatec                 *    t          j        |           S )z'Date. Returns a date like "2006-09-18".)r   r3   r   s    r   r3   r3          d###r   s	   slashpathc                 *    t          j        |           S )z8Any text. Replaces the native path separator with slash.)r   pconvertr@   s    r   	slashpathr     s     =r   s
   splitlinesc                 R    t          j        |                                 d          S )z*Any text. Split text into a list of lines.s   liner   )r   r   r   r   s    r   r   r     s$     "4??#4#47CCCCr   s   stringescapec                 *    t          j        |           S rB   )r   	escapestrr   s    r   stringescaper     s    %%%r   s	   stringifyc                     | S )zcAny type. Turns the value into text by converting values into
    text and concatenating them.
    r%   )things    r   	stringifyr     s	    
 Lr   s   stripdirc                     t           j                            |           }|dk    rt           j                            |           S |S )zyTreat the text as path and strip a directory level, if
    possible. For example, "foo" and "foo/bar" becomes "foo".
    r   )r=   r>   rf   r?   )r   dirs     r   stripdirr     s;    
 '//$

C
czzw%%%
r   s	   tabindentc                 "    t          | d          S )znAny 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                 *    t          j        |           S )z)Any text. Converts the text to uppercase.)r   r   r   s    r   r   r     r   r   s	   urlescapec                 6    t                               |           S )z`Any text. Escapes all "special" characters. For example,
    "foo bar" becomes "foo%20bar".
    )r   r   r   s    r   	urlescaper    s    
 <<r   s   userc                 *    t          j        |           S )zMAny text. Returns a short representation of a user name or email
    address.)r   	shortuserr   s    r   
userfilterr    s     %%%r   s	   emailuserc                 *    t          j        |           S )z7Any text. Returns the user portion of an email address.)r   	emailuserr   s    r   r  r    r   r   s   utf8c                 *    t          j        |           S )z>Any text. Converts from the local character encoding to UTF-8.)r   	fromlocalr   s    r   utf8r	    r   r   s	   xmlescapec                     |                      dd                               dd                               dd                               dd                               d	d
          } t          j        dd|           S )N   &s   &amp;   <s   &lt;ri   s   &gt;   "s   &quot;   's   &#39;s
   [ --]r   )r   r   r   r   s    r   	xmlescaper    sm     	T8$$	w			w			y	!	!	x	 	  	 614>>>r   c                 F    |r|D ]\  }}|                     ||           } | S )z}:websub: Any text. Only applies to hgweb. Applies the regular
    expression replacements defined in the websub section.
    )r   )r   websubtableregexpformats       r   websubr    s9      ,) 	, 	,NFF::fd++DDKr   c                 X    |j                                         D ]\  }}|t          |<   dS )z0Load template filter from specified registrarobjN)_tabler   filters)uiextnameregistrarobjr   funcs        r   
loadfilterr  (  s9    ")//11  
d r   )F)r   r   )r   )T)Nr=   r   r/   i18nr   noder   r   r   r   r	   r
   r   r   r   r   utilsr   r   r   urlerrr   r  templatefilterr   r   r2   r4   r;   r?   rH   rM   rb   rd   rf   rl   rn   rq   rt   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r3   r   r   r   r   r   r   r   r  r  r  r	  r  r  r  valuesi18nfunctionsr%   r   r   <module>r$     s   
			 				             	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	          
	 ))'22 U++++ + ,++  	 |0111!, !, !, 21!,H E***" " +*"   0 0 0 &E &E &ER 4 4 4 
5)))! ! *)! 	%(((  )( '''" " ('" 	%(((6 6 )(6 # # # #L 	%(((  )(
 	%(((  )(
 U+++& & ,+&
 u%%%  &% 	,"3444  54 
<#4555: : 65: l&7888= = 98=       $ < < < <: '''    (' 
 E***  +*
 U+++7 7 ,+7 u---  .- 	%(((% % )(% 
1 1 1 U+++B B ,+B |'8999= = :9= l&7888A A 98A '''  (' u---  .- \%6777$ $ 87$
 U+++  ,+
 e,,,D D -,D
 ...& & /.& U+++  ,+ E***  +* U+++  ,+ '''    (' 
 U+++  ,+ &&&& & '&& U+++& & ,+&
 &&&$ $ '&$
 U+++? ? ,+?       r   