3 Pf$@sddlmZddlZddlZddlZddlmZddlm Z ddl m Z m Z ddl mZddlmZmZejdZejd Zejd Zejd Zejd Zejd ZejeZGdddeZddZejedS))absolute_importN)parse)Link)rmtree display_path) indent_log)vcsVersionControlz url="([^"]+)"zcommitted-rev="(\d+)"z URL: (.+)zRevision: (.+)z\s*revision="(\d+)"z(.*)cseZdZdZdZdZd"Zdd Zd d Zd d Z ddZ ddZ ddZ ddZ fddZddZddZddZddZed d!ZZS)# Subversionsvnz.svncheckoutsvn+sshsvn+http svn+httpssvn+svncCs|jdj|j s td||jd|gdddid}tj|}|sftjdt |tj d |d S|j d j }t j|}|stjd t |tj d ||d fS||j d fS)z/Returns (url, revision), where both are strings/zBad directory: %sinfoFZLANGC) show_stdoutZ extra_environz'Cannot determine URL of svn checkout %sz!Output that cannot be parsed: %sNz,Cannot determine revision of svn checkout %s)NN)rstripendswithdirnameAssertionError run_command _svn_url_researchloggerwarningrdebuggroupstrip_svn_revision_re)selflocationoutputmatchurlr( /usr/lib/python3.6/subversion.pyget_infos,        zSubversion.get_infoc Cst|j\}}t||}|j|}tjd||t6tjj|rJt ||j dg|||gddWdQRXdS)z@Export the svn repository at the url to the destination locationz!Exporting svn repository %s to %sexportF)rN) get_url_revget_rev_optionsremove_auth_from_urlrrrospathexistsrr)r#r$r'rev rev_optionsr(r(r)r+;s    zSubversion.exportcCs|jdg|||gdS)Nswitch)r)r#destr'r3r(r(r)r4JszSubversion.switchcCs|jdg||gdS)Nupdate)r)r#r5r3r(r(r)r6MszSubversion.updatecCst|j\}}t||}|j|}|r.d|}nd}|j||||rptjd||t||jddg|||gdS)Nz (to revision %s)zChecking out %s%s to %sr z-q)r,r-r.Zcheck_destinationrrrr)r#r5r'r2r3Z rev_displayr(r(r)obtainPs     zSubversion.obtaincCsfx`|D]X}t|j}|sqd|kr@dj|jdddj}n|}||jkr|jdddSqWdS)N-r#r)r egg_fragmentjoinsplitlowerkey)r#distZdependency_linksr'r<r@r(r(r) get_locationas   zSubversion.get_locationc Csd}xtj|D]\}}}|j|kr2g|dd<q|j|jtjj||jd}tjj|s^q|j|\}}||kr~|d} n | s|j|  rg|dd<qt ||}qW|S)zR Return the maximum revision for all files under a given location rNentriesr) r/walkrremover0r=r1_get_svn_url_rev startswithmax) r#r$ZrevisionbasedirsfilesZ entries_fnZdirurlZlocalrevZbase_urlr(r(r) get_revisionos"      zSubversion.get_revisioncs,tt|j\}}|jdr$d|}||fS)Nzssh://zsvn+)superr r,rG)r#r'r2) __class__r(r)r,s zSubversion.get_url_revcCsV|}xBtjjtjj|dsF|}tjj|}||krtjd|dSqW|j|dS)Nzsetup.pyzGCould not find setup.py for directory %s (tried all parent directories)r)r/r0r1r=rrrrF)r#r$Z orig_locationZ last_locationr(r(r)get_urls zSubversion.get_urlc Cspddlm}tjj||jd}tjj|rHt|}|j}WdQRXnd}|j dsj|j dsj|j drt t t j |jd}|dd=|dd }d d |Ddg}n|j d rtj|}|std ||jd}dd tj|Ddg}n^y<|jdd|gdd} tj| jd}dd tj| D}Wn |k rRdg}}YnX|rdt|} nd} || fS)Nr)InstallationErrorrCr789Z10z cSs,g|]$}t|dkr|drt|dqS) )lenint).0dr(r(r) sz/Subversion._get_svn_url_rev..z_svn_xml_url_rer ValueErrorr _svn_rev_refinditerr_svn_info_xml_url_re_svn_info_xml_rev_rerH) r#r$rPZ entries_pathfdatar'Zrevsr&Zxmlr2r(r(r)rFs>             zSubversion._get_svn_url_revcCsB|j|}|dkrdS|jjddd}|j|}d|||fS)Nr9rrzsvn+%s@%s#egg=%s)rOZegg_namer>rL)r#rAr$ZrepoZegg_project_namer2r(r(r)get_src_requirements   zSubversion.get_src_requirementcCsdS)z&Always assume the versions don't matchFr()r#r5r3r(r(r) check_versionszSubversion.check_versioncCs>tj|}|jjdd}|j||j|j|jf}tj|}|S)N@rr;) urllib_parseurlsplitnetlocr>schemer0ZqueryZfragmentZ urlunsplit)r'ZpurlZstripped_netlocZ url_piecesZsurlr(r(r)r.s   zSubversion.remove_auth_from_url)r r rrr)__name__ __module__ __qualname__namerZ repo_nameZschemesr*r+r4r6r8rBrLr,rOrFrirj staticmethodr. __classcell__r(r()rNr)r s" , r cCs|rd|g}ng}tj|}t|dr6|j|j}}nL|d}d|krz|jdd}d|krn|jdd\}}q|d}}nd \}}|r|d|g7}|r|d|g7}|S) Nz-rusernamerrkr:z --usernamez --password)NN)rlrmhasattrrvpasswordr>)r'r2r3rrvryrnZauthr(r(r)r-s$      r-)Z __future__rZloggingr/reZpip._vendor.six.moves.urllibrrlZ pip.indexrZ pip.utilsrrZpip.utils.loggingrZpip.vcsrr compilerarcrr"rfreZ getLoggerrprr r-registerr(r(r(r)s&           Y