o ]Lb\@sdZddlmZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z ddlmZiZe eZdZedZGd d d eZd d Zd dddddZddZedddddZdS)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. )absolute_importN)_)error extensionshgpycompat registrar templater)urlutilsships-with-hg-cores{(\d+)\}c@s.eZdZddZddZd ddZdd ZdS) ShortRepositorycCsL||_||_||_ztttt|j|_WdSt y%d|_YdSw)Nr) schemer urlmaxmapint_partrefindallparts ValueError)selfr r r r//usr/lib/python3/dist-packages/hgext/schemes.py__init__Hs  zShortRepository.__init__cCs d|jS)Ns)r )rrrr__repr__Qs zShortRepository.__repr__NcCs$||}t|j|||||dS)N)intents createopts)resolver _peerlookupinstance)ruir createrrrrrrTs   zShortRepository.instancecCsz |ddd}Wntyttd|w|d|j}t||jkr4|d}|dd}nd}ddt|D}d|j |j ||S) Ns://sno '://' in scheme url '%s'/cSsi|] \}}d|d|qS)s%dr!r).0ivrrr fsz+ShortRepository.resolve..) split IndexErrorrAbortrrlen enumeratejoinr processr )rr rtailcontextrrrrZs zShortRepository.resolve)NN)__name__ __module__ __qualname__rrrrrrrrr Gs   r cCs*|rtD] }||drdSq||S)N:F)schemes startswith)origpathr rrrhasdriveletterjs r:shttp://hg.python.org/shttps://bitbucket.org/sssh://hg@bitbucket.org/shttps://{1}.googlecode.com/hg/shttps://{1}.kilnhg.com/Repo/)spysbbsbb+sshsgcodeskilncCstt|dttj}tD]/\}}tj r:t |dkr:| r:t j d|r:ttd||ft|||tj|<qttdtdS)Nsschemesr!s%s:\s5custom scheme %s:// conflicts with drive letter %s:\ shasdriveletter)r6updatedict configitemsr engineparseitemsr iswindowsr,isalphaosr9existsrr+rupperr rr wrapfunctionr r:)rtr r rrrextsetup{s&   rHsdebugexpandschemeT)norepocKs0t|}t|tr||}||ddS)z3given a repo path, provide the scheme-expanded path N)rr isinstancer rwrite)rr optsreporrr expandschemes   rO)__doc__ __future__rrCremercurial.i18nr mercurialrrrrrr mercurial.utilsr cmdtablecommand testedwithcompilerobjectr r:r6rHrOrrrrs, $     #