
    	^c-                         d Z ddlZddlZddlmZ ddlmZmZmZm	Z	m
Z
mZ ddlmZ i Z e
j        e          ZdZ ej        d          Z G d d	          Zd
 ZddddddZd Z edd          d             ZdS )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.
    N)_)error
extensionshgpycompat	registrar	templater)urlutils   ships-with-hg-cores   {(\d+)\}c                   (    e Zd Zd Zd ZddZd ZdS )ShortRepositoryc                     || _         || _        || _        	 t          t	          t
          t                              | j                                      | _        d S # t          $ r d| _        Y d S w xY w)Nr   )
schemer	   urlmaxmapint_partrefindallparts
ValueError)selfr   r   r	   s       //usr/lib/python3/dist-packages/hgext/schemes.py__init__zShortRepository.__init__G   so    "	Sgoodh&?&?@@AADJJJ 	 	 	DJJJJ	s   AA A21A2c                     d| j         z  S )Ns   <ShortRepository: %s>)r   )r   s    r   __repr__zShortRepository.__repr__P   s    '$+55    Nc                     |                      |          }t          j        |                              |||||          S )N)intents
createopts)resolver   _peerlookupinstance)r   uir   creater   r   s         r   r"   zShortRepository.instanceS   sE    ll3~c""++VW , 
 
 	
r   c                    	 |                     dd          d         }n2# t          $ r% t          j        t	          d          |z            w xY w|                     d| j                  }t          |          | j        k    r|d         }|d d         }nd}d t          |          D             }d                    | j	        
                    | j        |                    |z   S )Ns   ://   s   no '://' in scheme url '%s'   /r   c                 &    i | ]\  }}d |dz   z  |S )s   %dr&    ).0ivs      r   
<dictcomp>z+ShortRepository.resolve.<locals>.<dictcomp>e   s&    CCC$!Q5AE?ACCCr   )split
IndexErrorr   Abortr   r   len	enumeratejoinr	   processr   )r   r   r   tailcontexts        r   r    zShortRepository.resolveY   s    	G))FA&&q)CC 	G 	G 	G+a >??#EFFF	G		$
++u::
""9D#2#JEEDCC)E2B2BCCCxx..txAABBTIIs	    /A)NN)__name__
__module____qualname__r   r   r"   r    r*   r   r   r   r   F   sZ          6 6 6
 
 
 
J J J J Jr   r   c                 f    |r%t           D ]}|                    |dz             r dS  | |          S )N   :F)schemes
startswith)origpathr   s      r   hasdriveletterrA   i   sK      	 	Fv}-- uu4::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                    t                               t          |                     d                               t	          j        t          j                  }t                                           D ]\  }}t          j	        rt          |          dk    rn|                                rZt          j                            d|z            r8t          j        t#          d          ||                                fz            t'          |||          t(          j         |<   t+          j        t.          dt0                     d S )Ns   schemesr&   s   %s:\s5   custom scheme %s:// conflicts with drive letter %s:\
s   hasdriveletter)r=   updatedictconfigitemsr	   engineparseitemsr   	iswindowsr2   isalphaosr@   existsr   r1   r   upperr   r   r   wrapfunctionr
   rA   )r#   tr   r   s       r   extsetuprP   z   s   NN4z2233444))A}} = =	Fq     !x&011 ! +&  6<<>>*	+   -S&!<<
6G%6GGGGGr   s   debugexpandschemeT)norepoc                     t          j        |          }t          |t                    r|                    |          }|                     |dz              dS )z3given a repo path, provide the scheme-expanded path   
N)r   r!   
isinstancer   r    write)r#   r   optsrepos       r   expandschemerX      sR     >#D$((  ll3HHS5[r   )__doc__rK   remercurial.i18nr   	mercurialr   r   r   r   r   r	   mercurial.utilsr
   cmdtablecommand
testedwithcompiler   r   rA   r=   rP   rX   r*   r   r   <module>rb      sz  # #J 
			 				                           
)
H
%
%
 #

"*\
"
" J  J  J  J  J  J  J  JF   $$)/, H H H, 		d+++  ,+  r   