3 (\@sddlmZddlZddlZddlZddlmZddlmZm Z m Z ddl m Z ddl mZmZejdZejdZejd Zejd Ze rdd lmZmZejeZGd d d eZejedS))absolute_importN) indent_log) display_pathrmtreesplit_auth_from_netloc)MYPY_CHECK_RUNNING)VersionControlvcsz url="([^"]+)"zcommitted-rev="(\d+)"z\s*revision="(\d+)"z(.*))OptionalTuplecseZdZdZdZdZd$Zedd Ze d d Z d d Z ddZ eddZ ddZddZeddZefddZefddZe ddZeddZed d!Zed"d#ZZS)% Subversionsvnz.svncheckoutsvn+sshsvn+http svn+httpssvn+svncCsdS)NT)clsZ remote_urlrro/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-build-k1a8l1r5/pip/pip/_internal/vcs/subversion.pyshould_add_vcs_url_prefix sz$Subversion.should_add_vcs_url_prefixcCsd|gS)Nz-rr)revrrrget_base_rev_args$szSubversion.get_base_rev_argsc Csxd}|jdgdd}|j|s"dS|t|djd}|jd}yttt|}Wntk rjdSX|stdS|S)aReturn the version of the currently installed Subversion client. :return: A tuple containing the parts of the version information or ``None`` if the version returned from ``svn`` could not be parsed. :raises: BadCommand: If ``svn`` is not installed. z svn, version z --versionF) show_stdoutNr.) run_command startswithlensplittuplemapint ValueError)selfZversion_prefixversionZ version_listparsed_versionrrrget_vcs_version(s   zSubversion.get_vcs_versionc Csl|j|j\}}tjd||t>tjj|r:t|dg|j ||g}|j |ddWdQRXdS)z@Export the svn repository at the url to the destination locationz!Exporting svn repository %s to %sexportF)rN) Zget_url_rev_optionsurlloggerinforospathexistsrto_argsr)r#locationr( rev_optionscmd_argsrrrr'Fs zSubversion.exportcCsB|j}tjd||t|ddg|j||g}|j|dS)NzChecking out %s%s to %srz-q)Z to_displayr)r*rr.r)rdestr(r0 rev_displayr1rrr fetch_newSs zSubversion.fetch_newcCs$dg|j||g}|j|dS)Nswitch)r.r)r#r2r(r0r1rrrr5_szSubversion.switchcCs"dg|j|g}|j|dS)Nupdate)r.r)r#r2r(r0r1rrrr6cszSubversion.updatec 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 rNentries/) r+walkdirnameremover,joinr-_get_svn_url_revrmax) rr/revisionbasedirsfiles entries_fndirurllocalrevrrr get_revisiongs"      zSubversion.get_revisioncs"|dkrtt|j||St|S)z This override allows the auth information to be passed to svn via the --username and --password options instead of via the URL. ssh)superr get_netloc_and_authr)rnetlocscheme) __class__rrrIszSubversion.get_netloc_and_authcs2tt|j|\}}}|jdr(d|}|||fS)Nzssh://zsvn+)rHr get_url_rev_and_authr)rr(r user_pass)rLrrrMs zSubversion.get_url_rev_and_authcCs(g}|r|d|g7}|r$|d|g7}|S)Nz --usernamez --passwordr)usernamepassword extra_argsrrr make_rev_argss   zSubversion.make_rev_argscCsV|}xBtjjtjj|dsF|}tjj|}||krtjd|dSqW|j|dS)Nzsetup.pyzGCould not find setup.py for directory %s (tried all parent directories)r)r+r,r-r<r:r)warningr=)rr/ orig_location last_locationrrrget_remote_urls zSubversion.get_remote_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)InstallationErrorr78910z cSs,g|]$}t|dkr|drt|dqS) )rr!).0drrr sz/Subversion._get_svn_url_rev..z) rr/rW entries_pathfdatar(revsmatchxmlrrrrr=s>             zSubversion._get_svn_url_revcCsdS)z&Always assume the versions don't matchFr)rr2namerrris_commit_id_equalszSubversion.is_commit_id_equal)r rrrr)__name__ __module__ __qualname__rur: repo_nameschemes classmethodr staticmethodrr&r'r4r5r6rFrIrMrRrVr=rv __classcell__rr)rLrr s$       -r ) __future__rloggingr+reZpip._internal.utils.loggingrZpip._internal.utils.miscrrrZpip._internal.utils.typingrZpip._internal.vcsrr compilerirkrnrmZtypingr r getLoggerrwr)r registerrrrrs"        Q