
    6h<                    L
   % S r SSKJr  SSKrSSKrSSKJr  SSKrSSKJ	r
  SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r  SSKJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+  \RX                  S   S:  r-S\R\                  ;   r/Sr0\1" 5       (       d  SSKr\R`                  r0\'\"\'\2\24      \"\2   4   r3\)" S5      r4\)" S	5      r5\)" S
5      r6\)" SSS9r7S r8\Rr                  r9SQS jr:S r;S r<\Rz                  S:X  a  \R|                  " 5         \R~                  r?\R                  r@\R                  R                  S5      rCS\DS'   \R                  R                  S5      rFS\DS'   \Rz                  R                  S5      rGS\DS'   \R                  R                  S5      rIS\DS'   \R                  R                  S5      rKS\DS'   \R                  R                  S5      rMS\DS'   \R                  (       a  \R                  R                  S5      OSrOS\DS'   \R                  R                  S5      rQS\DS'   \R                  R                  S5      rSS\DS'   \R                  (       a  \R~                  " \R                  5      OSrUS\DS '   \0(       a  \+SRS! j5       rV\+        SSS" j5       rVS# rVSTS$ jrWS% rX\YrZ\R                  r\\]r^\R                  " \S&S5      bg  / r`S'\DS('   \Rz                  S:X  a-  \R                   V s/ s H  o R                  S)S*5      PM     sn r`O#\R                   V s/ s H  n \?" U 5      PM     sn r`\R                  " S+5      R                  rdS,R                  rf " S- S\25      rgSUS. jrh\0(       a  \+SVS/ j5       ri\+SWS0 j5       riS1 riSXS2 jrjSYS3 jrkSZS4 jrlS[S5 jrmS\S6 jrnS7 roS]S8 jrp\R                  rq\R                  r_\R                  rr\R                  rs\R                  ru\vrw   S^       S_S9 jjrx\R                  ry        S`S: jrzSaS; jr{SbS< jr| Sc       SdS> jjr}S? r~S@ r\GR                   r\SGR                  SA5      rS=\DSB'   \SGR                  SC5      rS=\DSD'   \SGR                  SE5      rS=\DSF'   \GSG:H  rS=\DSH'   \GSI:H  rS=\DSJ'           S`SK jr        S`SL jr Se       SfSM jjr Se       SgSN jjrShSiSO jjr      Sj           SkSP jjrgs  sn f s  sn f )lzwMercurial portability shim for python 3.

This contains aliases to hide python version-specific details from the core.
    )annotationsN)AnyAnyStrBinaryIOCallableDictIterableIteratorListMappingNoReturnOptionalSequenceTupleTypeTypeVarcastoverload   __pypy__F_T0_T1_S	_Tbytestrbytestr)boundc                ,    U R                  US   5        g )Nr   )set_exception)fexc_infos     4/usr/lib/python3/dist-packages/mercurial/pycompat.pyfuture_set_exception_infor"   C   s    OOHQK     c                    U $ N as    r!   identityr)   J   s    Hr#   c                  ^  Uc  U$ [        U[        [        [        45      (       a  [	        U5      " U 4S jU 5       5      $ [        U[
        5      (       a)  [	        U5      " U 4S jUR                  5        5       5      $ T " U5      $ )Nc              3  <   >#    U  H  n[        TU5      v   M     g 7fr%   _rapply).0xr   s     r!   	<genexpr>_rapply.<locals>.<genexpr>S   s     2r!1rs   c              3  X   >#    U  H  u  p[        TU5      [        TU5      4v   M!     g 7fr%   r,   )r.   kvr   s      r!   r0   r1   U   s$     N:41A16:s   '*)
isinstancelistsettupletypedictitemsr   xss   ` r!   r-   r-   N   sg    	z	"tS%())Bx2r222"dBxN288:NNNR5Lr#   c                .    U [         L a  U$ [        X5      $ )ah  Apply function recursively to every item preserving the data structure

>>> def f(x):
...     return 'f(%s)' % x
>>> rapply(f, None) is None
True
>>> rapply(f, 'a')
'f(a)'
>>> rapply(f, {'a'}) == {'f(a)'}
True
>>> rapply(f, ['a', 'b', None, {'c': 'd'}, []])
['f(a)', 'f(b)', None, {'f(c)': 'f(d)'}, []]

>>> xs = [object()]
>>> rapply(identity, xs) is xs
True
)r)   r-   r<   s     r!   rapplyr?   Y   s    $ 	H}	1>r#   ntasciibytesoscurdir	oslineseposname	ospathsepospardirossepOptional[bytes]osaltsep	osdevnullsysplatformr#   sysexecutablec                    g r%   r&   )r   args     r!   maplistrP          r#   c                    g r%   r&   )r   arg1arg2s      r!   rP   rP      s     	r#   c                ,    [        [        U /UQ76 5      $ r%   )r6   map)r   argss     r!   rP   rP      s    Ar#   c                 $    [        [        U 6 5      $ r%   )r6   rangerW   s    r!   	rangelistr[      s    tr#   c                 $    [        [        U 6 5      $ r%   )r6   ziprZ   s    r!   ziplistr^      s    T
r#   argvList[bytes]sysargvmbcsignorez>Bs   %rc                  `    \ rS rSrSr\(       a  S
SS jjrS
SS jjrSS jrSS jr	SS jr
Srg	)r      a{  A bytes which mostly acts as a Python 2 str

>>> bytestr(), bytestr(bytearray(b'foo')), bytestr(u'ascii'), bytestr(1)
('', 'foo', 'ascii', '1')
>>> s = bytestr(b'foo')
>>> assert s is bytestr(s)

__bytes__() should be called if provided:

>>> class bytesable:
...     def __bytes__(self):
...         return b'bytes'
>>> bytestr(bytesable())
'bytes'

...unless the argument is the bytes *type* itself: it gets a
__bytes__() method in Python 3.11, which cannot be used as in an instance
of bytes:

>>> bytestr(bytes)
"<class 'bytes'>"

There's no implicit conversion from non-ascii str as its encoding is
unknown:

>>> bytestr(chr(0x80)) # doctest: +ELLIPSIS
Traceback (most recent call last):
  ...
UnicodeEncodeError: ...

Comparison between bytestr and bytes should work:

>>> assert bytestr(b'foo') == b'foo'
>>> assert b'foo' == bytestr(b'foo')
>>> assert b'f' in bytestr(b'foo')
>>> assert bytestr(b'f') in b'foo'

Sliced elements should be bytes, not integer:

>>> s[1], s[:2]
(b'o', b'fo')
>>> list(s), list(reversed(s))
([b'f', b'o', b'o'], [b'o', b'o', b'f'])

As bytestr type isn't propagated across operations, you need to cast
bytes to bytestr explicitly:

>>> s = bytestr(b'foo').upper()
>>> t = bytestr(s)
>>> s[0], t[0]
(70, b'F')

Be careful to not pass a bytestr object to a function which expects
bytearray-like behavior.

>>> t = bytes(t)  # cast to bytes
>>> assert type(t) is bytes
c                    g r%   r&   )selfss     r!   __init__bytestr.__init__   s    r#   c                &   [        U[        5      (       a  U$ [        U[        [        45      (       dK  [        U[        5      (       d  [
        R                  " US5      (       d  [        U5      R                  S5      n[        R                  X5      $ )N	__bytes__rA   )
r5   r   rB   	bytearrayr9   builtinshasattrstrencode__new__)clsrh   s     r!   rr   bytestr.__new__  sg    a!!H!eY/00q$##A{33Ag&A}}S$$r#   c                p    [         R                  X5      n[        U[         5      (       d  [        U5      nU$ r%   )rB   __getitem__r5   bytechr)rg   keyrh   s      r!   rv   bytestr.__getitem__  s-    d(!U##
Ar#   c                >    [        [        R                  U 5      5      $ r%   )iterbytestrrB   __iter__rg   s    r!   r|   bytestr.__iter__  s    5>>$/00r#   c                2    [         R                  U 5      SS  $ )N   )rB   __repr__r}   s    r!   r   bytestr.__repr__  s    ~~d#AB''r#   r&   N)r#   )rh   objectreturnNone)rs   zType[_Tbytestr]rh   r   r   r   )r   rB   )r   Iterator[bytes])r   rp   )__name__
__module____qualname____firstlineno____doc__TYPE_CHECKINGri   rr   rv   r|   r   __static_attributes__r&   r#   r!   r   r      s&    9~ 	%1(r#   c                "    [        [        U 5      $ )z4Iterate bytes as if it were a str object of Python 2)rV   rw   rh   s    r!   r{   r{     s    w?r#   c                    g r%   r&   r   s    r!   maybebytestrr   %  rQ   r#   c                    g r%   r&   r   s    r!   r   r   )  rQ   r#   c                F    [        U [        5      (       a  [        U 5      $ U $ )zPromote bytes to bytestr)r5   rB   r   r   s    r!   r   r   .  s    !UqzHr#   c                R    [        U [        5      (       a  U $ U R                  S5      $ )zConvert an internal str (e.g. keyword, __doc__) back to bytes

This never raises UnicodeEncodeError, but only ASCII characters
can be round-trip by sysstr(sysbytes(s)).
zutf-8)r5   rB   rq   r   s    r!   sysbytesr   5  s%     !U88Gr#   c                f    [        U [        R                  5      (       a  U $ U R                  S5      $ )a  Return a keyword str to be passed to Python functions such as
getattr() and str.encode()

This never raises UnicodeDecodeError. Non-ascii characters are
considered invalid and mapped to arbitrary but unique code points
such that 'sysstr(a) != sysstr(b)' for all 'a != b'.
latin-1)r5   rn   rp   decoder   s    r!   sysstrr   @  s)     !X\\""88Ir#   c                R    [        U [        5      (       a  U R                  S5      $ U $ )z Converts a bytes url back to strrA   )r5   rB   r   urls    r!   strurlr   M  s#    #uzz'""Jr#   c                R    [        U [        5      (       a  U R                  S5      $ U $ )z0Converts a str url to bytes by encoding in asciirA   )r5   rp   rq   r   s    r!   bytesurlr   T  s#    #szz'""Jr#   c                $    U R                  U5      e)z(Raise exception with the given traceback)with_traceback)exctbs     r!   raisewithtbr   [  s    


R
  r#   c                   U R                  5       R                  S5      n[        R                  nUSS  H?  n[	        UR                  S5      5      nU(       d  M&  [	        U5      U-
  n[        X%5      nMA     U(       a  US   R                  S5      US'   U[        R                  :  a%  [        S[	        U5      5       H  nX   US X'   M     SR                  U5      $ )z|Clean up indentation from docstrings.

Any whitespace that can be uniformly removed from the second line
onwards is removed.
r   N r   )	
expandtabssplitsysmaxsizelenlstripminrY   join)doclinesmarginlinecontentindentis          r!   cleandocr   d  s    
 NN""4(E [[Fab	dkk#&'7Y(F(F	  8??3'aq#e*%Ax(EH &
 99Ur#   c                    [         R                  " U SS5      nUc  U$ [        R                  S:  a  [	        U5      n[        U5      $ )zLGet docstring as bytes; may be None so gettext() won't confuse it
with _('')r   N)r      )rn   getattrr   version_infor   r   )objr   s     r!   getdocr   ~  sE     

3	4
0C
{

'! smC=r#   c                D    [         R                  " U [        U5      X#5      $ r%   )rn   openr   )namemode	bufferingencodings       r!   r   r     s     ==vd|YAAr#   c                   U Vs/ s H  oDR                  S5      PM     nnUR                  S5      nU Vs/ s H  oDR                  S5      PM     nnU " XU5      u  pQU Vs/ s H*  oDS   R                  S5      US   R                  S5      4PM,     nnU Vs/ s H  oDR                  S5      PM     nnXQ4$ s  snf s  snf s  snf s  snf )z
Takes bytes arguments, converts them to unicode, pass them to
getopt.getopt(), convert the returned values back to bytes and then
return them for Python 3 compatibility as getopt.getopt() don't accepts
bytes on Python 3.
r   r   r   )r   rq   )origrW   	shortlistnamelistr(   optss         r!   _getoptbwrapperr     s     *..AHHYD.  +I-56X#XH6dx0JDFJKdqT[[#QqT[[%;<dDK)-.AHHYD.: /6K.s   B7B<!1CCc                z    U R                  5        VVs0 s H  u  pUR                  S5      U_M     n nnU $ s  snnf )z
Converts the keys of a python dictonary to str i.e. unicodes so that
they can be passed as keyword arguments as dictionaries with bytes keys
can't be passed as keyword arguments to functions on Python 3.
r   )r;   r   dicr3   r4   s      r!   	strkwargsr     s8     /2iik
:kda188I!kC
:J ;   7c                z    U R                  5        VVs0 s H  u  pUR                  S5      U_M     n nnU $ s  snnf )z
Converts keys of python dictionaries to bytes as they were converted to
str to pass that dictonary as a keyword argument on Python 3.
r   )r;   rq   r   s      r!   byteskwargsr     s8    
 /2iik
:kda188I!kC
:J ;r   boolc                    [         R                  " U R                  S5      X5      nU Vs/ s H  oDR                  S5      PM     sn$ s  snf )z
Takes bytes argument, convert it to str i.e. unicodes, pass that into
shlex.split(), convert the returned value to bytes and return that for
Python 3 compatibility as shelx.split() don't accept bytes on Python 3.
r   )shlexr   r   rq   )rh   commentsposixretr(   s        r!   
shlexsplitr     s<     ++ahhy)8
;C),-AHHY---s   Ac                "    U R                  5       $ r%   )r;   r/   s    r!   <lambda>r     s
    aggir#   c                "    U R                  5       $ r%   )valuesr   s    r!   r   r     s
    qxxzr#   s   javaisjythons   darwinisdarwins   linuxislinuxs   posixisposixs   nt	iswindowsc                8    [        [        R                  XU5      $ r%   )r   getoptrW   r   r   s      r!   getoptbr     s     6==$8DDr#   c                8    [        [        R                  XU5      $ r%   )r   r   
gnu_getoptr   s      r!   
gnugetoptbr     s     6,,dxHHr#   c                0    [         R                  " XU5      $ r%   )tempfilemkdtempsuffixprefixdirs      r!   r   r          FC00r#   c                0    [         R                  " XU5      $ r%   )r   mkstempr   s      r!   r   r     r   r#   c                    U c  Sn O[        U 5      n SU ;   d   e[        [        [        R                  " U /UQ70 UD65      $ )Nzw+bb)r   r   r   r   TemporaryFile)r   rW   kwargss      r!   unnamedtempfiler     sC    |d|$;;(00GGGHHr#   c           	     T    [        U 5      n SU ;   d   e[        R                  " XX#XES9$ )Nr   )r   r   r   delete)r   r   NamedTemporaryFile)r   bufsizer   r   r   r   s         r!   namedtempfiler     s3     $<D$;;&&f r#   )r(   r   r   r   )r   zCallable[[_T0], _S]rO   Iterable[_T0]r   List[_S])r   zCallable[[_T0, _T1], _S]rS   r   rT   zIterable[_T1]r   r   )r   z	List[int])rh   zIterable[int]r   r   )rh   rB   r   r   )rh   r   r   r   )rh   r   r   rB   )rh   r   r   rp   )r   r   r   rp   )r   r   r   rB   )r   BaseExceptionr   r   )r   r   r   rI   )   rN)r   r   r   intr   zOptional[str]r   r   )rW   Sequence[bytes]r   rB   r   r  r   _GetOptResult)r   zMapping[bytes, _T0]r   zDict[str, _T0])r   zMapping[str, _T0]r   zDict[bytes, _T0])FT)rh   rB   r   r   r   r   r   r`   )r#      tmpN)r   rB   r   rB   r   rI   r   rB   )r   rB   r   rB   r   rI   r   zTuple[int, bytes]r%   )r   rI   r   r   )s   w+br  r#   r  NT)r   rB   r   r  r   rB   r   rB   r   rI   r   r   )r   
__future__r   rn   codecsconcurrent.futuresfuturesr   http.clientclienthttplibhttp.cookiejar	cookiejar	cookielibinspectiojsonosqueuer   socketserverstructr   r   xmlrpc.client	xmlrpclibtypingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   ispy3builtin_module_namesispypyr   globalsrB   r  r   r   r   r   r"   FileNotFoundErrorr)   r-   r?   r   _enablelegacywindowsfsencodingfsencodefsdecodecurdirrq   rC   __annotations__lineseprD   rE   pathseprF   pardirrG   seprH   altseprJ   devnullrK   platformrL   
executablerM   rP   r[   r^   inputrawinputgetfullargspec
getargspecr  longr   ra   r_   Structpackrw   __mod__bytereprr   r{   r   r   r   r   r   r   r   r   delattrro   setattrrY   xrangerp   unicoder   safehasattrr   r   r   r   	iteritems
itervaluesloads
json_loads
startswithr   r   r   r   r   r   r   r   r   r   r   r'   s   0r!   <module>r?     s  
 #   $   "  	  	     
  !    ( 	q 	s//	/yy((Md5./e<=enenT]Ky1	! .. 0 77e
 &&(;;;;))""7+% +::$$W-	5 -w' '::$$W-	5 -))""7+% +vv}}W%u %9;BII,,W5/ L::$$W-	5 -\\((1U 169nnr{{3>>2#u M   #+8@M	  ##

C&2 G[	ww%7:xx@x!88FH-x@(+118A;1
--

"
"==](e ](@
    
!4
 










	

 "	B
B B 	B
 	B ,1=L$ 59	.	.	.-1	.	.  	!
ZZ
''0$ 0''	2$ 2&&x0 0(" "E/	4 !E
E&+E7FEEI
I&+I7FII IM11!&16E1
1 IM11!&16E11I 
  	
 
 a
 A1s   TT!