^c-dZddlZddlZddlmZddlmZmZmZm Z m Z m Z ddl m Z iZe jeZdZejdZGdd Zd Zd d d dddZdZedddZdS)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 extensionshgpycompat registrar templater)urlutilsships-with-hg-cores{(\d+)\}c(eZdZdZdZddZdZdS)ShortRepositoryc||_||_||_ tt t t |j|_dS#t$r d|_YdSwxYw)Nr) schemer urlmaxmapint_partrefindallparts ValueError)selfrrr s //usr/lib/python3/dist-packages/hgext/schemes.py__init__zShortRepository.__init__Gso " Sgoodh&?&?@@AADJJJ   DJJJJ sAAA21A2cd|jzS)Ns)r)rs r__repr__zShortRepository.__repr__Ps'$+55Nc||}tj||||||S)N)intents createopts)resolver _peerlookupinstance)ruircreaterrs rr"zShortRepository.instanceSsEll3~c""++ VW,   rc |ddd}n2#t$r%tjt d|zwxYw|d|j}t ||jkr|d}|dd}nd}dt|D}d|j |j ||zS)Ns://sno '://' in scheme url '%s'/rc&i|]\}}d|dzz|S)s%dr&).0ivs r z+ShortRepository.resolve..es&CCC$!Q5AE?ACCCr) split IndexErrorrAbortrrlen enumeratejoinr processr)rrrtailcontexts rr zShortRepository.resolveYs G))FA&&q)CC G G G+a >??#EFF F G $ ++ u:: " "9D#2#JEEDCC)E2B2BCCCxx..txAABBTIIs /A)NN)__name__ __module__ __qualname__rrr"r r*rrr r FsZ666    J J J J Jrr cf|r%tD]}||dzrdS||S)N:F)schemes startswith)origpathrs rhasdriveletterrAisK   Fv}-- uu  4::rshttp://hg.python.org/shttps://bitbucket.org/sssh://hg@bitbucket.org/shttps://{1}.googlecode.com/hg/shttps://{1}.kilnhg.com/Repo/)spysbbsbb+sshsgcodeskilnctt|dt jtj}tD]\}}tj rt|dkrn| rZtj d|zr8tjt#d||fzt'|||t(j|<t+jt.dt0dS)Nsschemesr&s%s:\s5custom scheme %s:// conflicts with drive letter %s:\ shasdriveletter)r=updatedict configitemsr engineparseitemsr iswindowsr2isalphaosr@existsrr1rupperr rr wrapfunctionr rA)r#trrs rextsetuprPzs NN4z2233444))A}}==    F q    !x&011!+&6<<>>* + -S&!<< 6G%6GGGGGrsdebugexpandschemeT)norepoc tj|}t|tr||}||dzdS)z3given a repo path, provide the scheme-expanded path N)rr! isinstancer r write)r#roptsrepos r expandschemerXsR >#  D$(( ll3HHS5[r)__doc__rKremercurial.i18nr mercurialrrrrrr mercurial.utilsr cmdtablecommand testedwithcompilerr rAr=rPrXr*rrrbsz ##J   ) H % % # "*\ " " J J J J J J J JF $ $)/ ,   HHH,  d+++,+r