a +b\@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|_Wnt yFd|_Yn0dS)Nr) schemer urlmaxmapint_partrefindallparts ValueError)selfr r r r3/usr/lib64/python3.9/site-packages/hgext/schemes.py__init__Hs zShortRepository.__init__cCs d|jS)Ns)r )rrrr__repr__QszShortRepository.__repr__NcCs$||}t|j|||||dS)N)intents createopts)resolver _peerlookupinstance)ruir ZcreaterrrrrrTs   zShortRepository.instancecCsz|ddd}Wn$ty8ttd|Yn0|d|j}t||jkrl|d}|dd}nd}ddt|D}d|j |j ||S) Ns://sno '://' in scheme url '%s'/cSsi|]\}}d|d|qS)s%dr r).0ivrrr fr#z+ShortRepository.resolve..) split IndexErrorrAbortrrlen enumeratejoinr Zprocessr )rr rtailcontextrrrrZs zShortRepository.resolve)NN)__name__ __module__ __qualname__rrrrrrrrr Gs  r cCs*|r"tD]}||drdSq||S)N:F)schemes startswith)Zorigpathr rrrhasdriveletterjs r7shttp://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 rtt |dkrt| rtt j d|rtttd||ft|||tj|<q(ttdtdS)Nsschemesr s%s:\s5custom scheme %s:// conflicts with drive letter %s:\ shasdriveletter)r4updatedictZ configitemsr ZengineparseitemsrZ iswindowsr+isalphaosr6existsrr*rupperr rrZ wrapfunctionr r7)rtr r rrrextsetup{s(   rAsdebugexpandschemeT)ZnorepocKs0t|}t|tr||}||ddS)z3given a repo path, provide the scheme-expanded path N)rr isinstancer rwrite)rr ZoptsZreporrr expandschemes   rE)__doc__Z __future__rr=reZmercurial.i18nrZ mercurialrrrrrr Zmercurial.utilsr ZcmdtableZcommandZ testedwithcompilerobjectr r7r4rArErrrrs*$      #