3

Q'íc†$ã@sÔddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZmZddl
mZddlmZmZejdƒZejd	ƒZejd
ƒZejdƒZejdƒZejd
ƒZejeƒZGdd„deƒZdd„ZejeƒdS)é)Úabsolute_importN)Úparse)ÚLink)ÚrmtreeÚdisplay_path)Ú
indent_log)ÚvcsÚVersionControlz
url="([^"]+)"zcommitted-rev="(\d+)"z	URL: (.+)zRevision: (.+)z\s*revision="(\d+)"z<url>(.*)</url>cseZdZdZdZdZd"Zdd	„Zd
d„Zdd
„Z	dd„Z
dd„Zdd„Zdd„Z
‡fdd„Zdd„Zdd„Zdd„Zdd„Zed d!„ƒZ‡ZS)#Ú
SubversionÚsvnz.svnÚcheckoutúsvn+sshúsvn+httpú	svn+httpsúsvn+svncCs´|jdƒj|jƒs td|ƒ‚|jd|gdddid}tj|ƒ}|sftjdt	|ƒƒtj
d	|ƒd
S|jdƒjƒ}t
j|ƒ}|s¦tjdt	|ƒƒtj
d	|ƒ|d
fS||jdƒfS)z/Returns (url, revision), where both are stringsú/zBad directory: %sÚinfoFÚLANGÚC)Úshow_stdoutÚ
extra_environz'Cannot determine URL of svn checkout %sz!Output that cannot be parsed: 
%sNéz,Cannot determine revision of svn checkout %s)NN)ÚrstripÚendswithÚdirnameÚAssertionErrorÚrun_commandÚ_svn_url_reÚsearchÚloggerÚwarningrÚdebugÚgroupÚstripÚ_svn_revision_re)ÚselfÚlocationÚoutputÚmatchÚurl©r*ú1/tmp/pip-build-l_bcah40/pip/pip/vcs/subversion.pyÚget_infos,




zSubversion.get_infocCst|jƒ\}}t||ƒ}|j|ƒ}tjd||ƒtƒ6tjj|ƒrJt	|ƒ|j
dg|||gddWdQRXdS)z@Export the svn repository at the url to the destination locationz!Exporting svn repository %s to %sÚexportF)rN)Úget_url_revÚget_rev_optionsÚremove_auth_from_urlrrrÚosÚpathÚexistsrr)r%r&r)ÚrevÚrev_optionsr*r*r+r-;s

zSubversion.exportcCs|jdg|||gƒdS)NÚswitch)r)r%Údestr)r5r*r*r+r6JszSubversion.switchcCs|jdg||gƒdS)NÚupdate)r)r%r7r5r*r*r+r8MszSubversion.updatecCst|jƒ\}}t||ƒ}|j|ƒ}|r.d|}nd}|j||||ƒrptjd||t|ƒƒ|jddg|||gƒdS)Nz (to revision %s)ÚzChecking out %s%s to %srz-q)r.r/r0Úcheck_destinationrrrr)r%r7r)r4r5Úrev_displayr*r*r+ÚobtainPs



zSubversion.obtaincCsfx`|D]X}t|ƒj}|sqd|kr@dj|jdƒdd…ƒjƒ}n|}||jkr|jddƒdSqWdS)Nú-rú#réÿÿÿÿ)rÚegg_fragmentÚjoinÚsplitÚlowerÚkey)r%ÚdistÚdependency_linksr)r@rDr*r*r+Úget_locationas


zSubversion.get_locationc
Cs°d}x¦tj|ƒD]˜\}}}|j|kr2g|dd…<q|j|jƒtjj||jdƒ}tjj|ƒs^q|j|ƒ\}}||kr~|d}	n |s|j|	ƒržg|dd…<qt	||ƒ}qW|S)zR
        Return the maximum revision for all files under a given location
        rNÚentriesr)
r1ÚwalkrÚremover2rAr3Ú_get_svn_url_revÚ
startswithÚmax)
r%r&ÚrevisionÚbaseÚdirsÚfilesÚ
entries_fnÚdirurlÚlocalrevÚbase_urlr*r*r+Úget_revisionos"

zSubversion.get_revisioncs,tt|ƒjƒ\}}|jdƒr$d|}||fS)Nzssh://zsvn+)Úsuperr
r.rL)r%r)r4)Ú	__class__r*r+r.Šs
zSubversion.get_url_revcCsV|}xBtjjtjj|dƒƒsF|}tjj|ƒ}||krtjd|ƒdSqW|j|ƒdS)Nzsetup.pyzGCould not find setup.py for directory %s (tried all parent directories)r)r1r2r3rArrr rK)r%r&Ú
orig_locationÚ
last_locationr*r*r+Úget_url‘szSubversion.get_urlcCspddlm}tjj||jdƒ}tjj|ƒrHt|ƒ}|jƒ}WdQRXnd}|j	dƒsj|j	dƒsj|j	dƒr¬t
ttj
|jdƒƒƒ}|dd=|dd	}d
d„|Dƒdg}n¨|j	dƒrötj|ƒ}|sÐtd
|ƒ‚|jdƒ}dd„tj|ƒDƒdg}n^y<|jdd|gdd}	tj|	ƒjdƒ}dd„tj|	ƒDƒ}Wn |k
rRdg}}YnX|rdt|ƒ}
nd}
||
fS)Nr)ÚInstallationErrorrHr9Ú8Ú9Ú10z

écSs,g|]$}t|ƒdkr|drt|dƒ‘qS)é	)ÚlenÚint)Ú.0Údr*r*r+ú
<listcomp>µsz/Subversion._get_svn_url_rev.<locals>.<listcomp>z<?xmlzBadly formatted data: %rrcSsg|]}t|jdƒƒ‘qS)r)rcr")rdÚmr*r*r+rf»srz--xmlF)rcSsg|]}t|jdƒƒ‘qS)r)rcr")rdrgr*r*r+rfÅs)Úpip.exceptionsr\r1r2rArr3ÚopenÚreadrLÚlistÚmapÚstrÚ
splitlinesrBÚ_svn_xml_url_rerÚ
ValueErrorr"Ú_svn_rev_reÚfinditerrÚ_svn_info_xml_url_reÚ_svn_info_xml_rev_rerM)r%r&r\Úentries_pathÚfÚdatar)Úrevsr(Úxmlr4r*r*r+rK¥s>








zSubversion._get_svn_url_revcCsB|j|ƒ}|dkrdS|jƒjddƒd}|j|ƒ}d|||fS)Nr=rrzsvn+%s@%s#egg=%s)r[Úegg_namerBrV)r%rEr&ÚrepoÚegg_project_namer4r*r*r+Úget_src_requirementÑs

zSubversion.get_src_requirementcCsdS)z&Always assume the versions don't matchFr*)r%r7r5r*r*r+Ú
check_versionÚszSubversion.check_versioncCs>tj|ƒ}|jjdƒd}|j||j|j|jf}tj|ƒ}|S)Nú@rr?)	Úurllib_parseÚurlsplitÚnetlocrBÚschemer2ÚqueryÚfragmentÚ
urlunsplit)r)ÚpurlÚstripped_netlocÚ
url_piecesÚsurlr*r*r+r0Þs


zSubversion.remove_auth_from_url)rr
rrr)Ú__name__Ú
__module__Ú__qualname__ÚnamerÚ	repo_nameÚschemesr,r-r6r8r<rGrVr.r[rKr}r~Ústaticmethodr0Ú
__classcell__r*r*)rXr+r
s",	r
cCs¦|rd|g}ng}tj|ƒ}t|dƒr6|j|j}}nL|d}d|krz|jdƒd}d|krn|jddƒ\}}q‚|d}}nd	\}}|r’|d|g7}|r¢|d|g7}|S)
Nz-rÚusernamerrrú:z
--usernamez
--password)NN)r€rÚhasattrr“ÚpasswordrB)r)r4r5Úrr“r–r‚Úauthr*r*r+r/ñs$


r/)Ú
__future__rÚloggingr1ÚreZpip._vendor.six.moves.urllibrr€Ú	pip.indexrÚ	pip.utilsrrÚpip.utils.loggingrÚpip.vcsrr	Úcompilerorqrr$rtrsÚ	getLoggerr‹rr
r/Úregisterr*r*r*r+Ú<module>s&






Y