
    6h                        S r SSKJ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  SSKJr  0 r\R"                  " \5      rSr\R&                  " S5      r " S	 S
5      rS rSSSSSS.rSS jrS r\" SSS9S 5       rg)a'  extend schemes with shortcuts to repository swarms

This extension allows you to specify shortcuts for parent URLs with a
lot of repositories to act like a scheme, for example::

  [schemes]
  py = http://code.python.org/hg/

After that you can use it like::

  hg clone py://trunk/

Additionally there is support for some more complex schemas, for
example used by Google Code::

  [schemes]
  gcode = http://{1}.googlecode.com/hg/

The syntax is taken from Mercurial templates, and you have unlimited
number of variables, starting with ``{1}`` and continuing with
``{2}``, ``{3}`` and so on. This variables will receive parts of URL
supplied, split by ``/``. Anything not specified as ``{part}`` will be
just appended to an URL.

For convenience, the extension adds these schemes by default::

  [schemes]
  py = http://hg.python.org/
  bb = https://bitbucket.org/
  bb+ssh = ssh://hg@bitbucket.org/
  gcode = https://{1}.googlecode.com/hg/
  kiln = https://{1}.kilnhg.com/Repo/

You can override a predefined scheme by defining a new scheme with the
same name.
    )annotationsN)_)error
extensionshgpycompat	registrar	templater)urlutils   ships-with-hg-cores   {(\d+)\}c                  6    \ rS rSrS rS rS rS	S jrS rSr	g)
ShortRepositoryH   c                    X l         X0l        Xl         [        [	        [
        [        R                  U R                  5      5      5      U l        g ! [         a
    SU l         g f = f)Nr   )
schemer
   urlmaxmapint_partrefindallparts
ValueError)selfr   r   r
   s       //usr/lib/python3/dist-packages/hgext/schemes.py__init__ShortRepository.__init__I   sL    "	Sgoodhh&?@ADJ 	DJ	s   ;A A$#A$c                     SU R                   -  $ )Ns   <ShortRepository: %s>)r   )r   s    r   __repr__ShortRepository.__repr__R   s    '$++55    c                    U R                  UR                  5      nUR                  US9n[        R                  R                  UR                  R                  5      nUb  UR                  " X/UQ70 UD6$ g )N)new_raw_location)	resolverawloccopyr   peer_schemesgetr   r   	make_peer)r   uipathargskwargsnew_urlclss          r   r(   ShortRepository.make_peerU   sa    ,,t{{+yy'y2oo!!$((//2?==;D;F;;r    Nc                \   U R                  U5      n[        R                  " U5      nUR                  =(       d    SnU[        R
                  ;   a  [        R
                  U   nO8U[        R                  ;   a  [        R                  U   nO[        R                  nUR                  XX4US9$ )Ns   file)intents
createopts)	r#   r   r   r   r   r&   repo_schemesLocalFactoryinstance)	r   r)   r   creater1   r2   ur   r.   s	            r   r5   ShortRepository.instance]   s    ll3KK$WR__$//&)Cr&//&)C//C||V  
 	
r    c                    UR                  SS5      S   nUR                  SU R
                  5      n[        U5      U R
                  :  a  US   nUS S nOSn[        U5       VVs0 s H  u  pESUS-   -  U_M     nnnSR                  U R                  R                  U R                  U5      5      U-   $ ! [         a#    [        R                  " [	        S5      U-  5      ef = fs  snnf )Ns   ://   s   no '://' in scheme url '%s'   /r    s   %d)split
IndexErrorr   Abortr   r   len	enumeratejoinr
   processr   )r   r   r   tailivcontexts          r   r#   ShortRepository.resolvek   s    	G))FA&q)C 		$

+u:

"9D#2JED2;E2BC2B$!5AE?A%2BCxx..txxABTII  	G++a >?#EFF	G Ds   B7 'C'7-C$)r   r   r
   r   )NN)
__name__
__module____qualname____firstlineno__r   r   r(   r5   r#   __static_attributes__ r    r   r   r   H   s    6
Jr    r   c                p    U(       a(  [          H  nUR                  US-   5      (       d  M    g   U " U5      $ )N   :F)schemes
startswith)origr*   r   s      r   hasdriveletterrT   {   s1    Fv}--  :r    s   http://hg.python.org/s   https://bitbucket.org/s   ssh://hg@bitbucket.org/s   https://{1}.googlecode.com/hg/s   https://{1}.kilnhg.com/Repo/)s   pys   bbs   bb+sshs   gcodes   kilnc                4   [         R                  (       a  [        U 5      S:X  as  U R                  5       (       a]  [        R
                  R                  SU -  5      (       a5  [        S5      nXU R                  5       4-  n[        R                  " U5      egggg)z6check if a scheme conflict with a Windows drive letterr:   s   %s:\s5   custom scheme %s:// conflicts with drive letter %s:\
N)r   	iswindowsr@   isalphaosr*   existsr   upperr   r?   )r   msgs     r   _check_drive_letterr\      s     	K1NNGGNN8f,--JK''kk#	 .   	r    c                   [         R                  [        U R                  S5      5      5        [        R
                  " [        R                  5      n[         R                  5        H  u  p#[        U5        [        R                  " U5      R                  nU[        R                  ;   a  [        X2U5      [        R                  U'   Mc  [        X2U5      [        R                  U'   M     [         R"                  " [        S[$        5        g )Ns   schemesrT   )rQ   updatedictconfigitemsr
   engineparseitemsr\   r   r   r   r   r&   r   r3   r   wrapfunctionrT   )r)   tr   r   
url_schemes        r   extsetuprg      s    NN4z234)A}}F#[[%,,
(&5c1&EBOOF#&5c1&EBOOF# ' G%5~Fr    s   debugexpandschemeT)norepoc                L   [         R                  " U5      R                  nU[        R                  ;   a  [        R                  U   nO[        R
                  R                  U5      nUb&  [        U[        5      (       a  UR                  U5      nU R                  US-   5        g)z3given a repo path, provide the scheme-expanded pathN   
)r   r   r   r   r&   r3   r'   
isinstancer   r#   write)r)   r   optsr   r.   s        r   expandschemern      su     [[$$F oof%oo!!&)
:c?;;kk#HHS5[r    )r   bytesreturnNone)__doc__
__future__r   rX   remercurial.i18nr   	mercurialr   r   r   r   r	   r
   mercurial.utilsr   cmdtablecommand
testedwithcompiler   r   rT   rQ   r\   rg   rn   rN   r    r   <module>r|      s   #J # 	 	   


H
%
 #

**\
"0J 0Jf $$)/,
G 		d+	 ,	r    