î œ0{Y,"ã@s½dZddlZddlZddlmZmZddlmZddlm Z m Z m Z m Z m Z ddgZGdd „d eƒZeƒZGd d „d eƒZd d„ZdS) z)Handles all VCS (version control) supportéN)ÚurlparseÚurllib)Úlogger)Ú display_pathÚ backup_dirÚ find_commandÚrmtreeÚask_path_existsÚvcsÚget_src_requirementcsÄeZdZiZddddddgZ‡fdd†Zd d „Zed d „ƒZed d„ƒZ edd„ƒZ dd„Z dddd„Z dd„Z dd„Zdd„Z‡S)Ú VcsSupportÚsshÚgitÚhgÚbzrÚsftpÚsvncsRtjj|jƒttddƒr;tjj|jƒntt|ƒjƒdS)NÚ uses_fragment) rÚ uses_netlocÚextendÚschemesÚgetattrrÚsuperr Ú__init__)Úself)Ú __class__©ú+/tmp/pip-ok8sy_ze-build/pip/vcs/__init__.pyrszVcsSupport.__init__cCs |jjƒS)N)Ú _registryÚ__iter__)rrrrrszVcsSupport.__iter__cCst|jjƒƒS)N)ÚlistrÚvalues)rrrrÚbackendsszVcsSupport.backendscCsdd„|jDƒS)NcSsg|]}|j‘qSr)Údirname)Ú.0Úbackendrrrú $s z'VcsSupport.dirnames..)r")rrrrÚdirnames"szVcsSupport.dirnamescCs.g}x!|jD]}|j|jƒqW|S)N)r"rr)rrr%rrrÚ all_schemes&szVcsSupport.all_schemescCsPt|dƒs'tjd|jƒdS|j|jkrL||j|j+://, e.g. svn+http://myrepo/svn/MyApp#egg=MyAppú+éNú@r>)r?ÚAssertionErrorÚsplitrÚurlsplitÚrsplitÚ urlunsplit) rÚ error_messager?ÚschemeÚnetlocr1ÚqueryÚfragÚrevrrrÚ get_url_revss" zVersionControl.get_url_revcCsH|jdƒj|jƒ s,td|ƒ‚|j|ƒ|j|ƒfS)zA Returns (url, revision), where both are strings ú/zBad directory: %s)ÚrstripÚendswithr#rSÚget_urlÚ get_revision)rr4rrrÚget_info…s,zVersionControl.get_infocCstj|ƒjdƒS)za Normalize a URL for comparison by unquoting it and removing any trailing slash. r_)rÚunquoter`)rr?rrrÚ normalize_urlŒszVersionControl.normalize_urlcCs|j|ƒ|j|ƒkS)zV Compare two repo URLs for identity, ignoring incidental differences. )rf)rÚurl1Úurl2rrrÚ compare_urls’szVersionControl.compare_urlscCs t‚dS)zÌ Takes the contents of the bundled text file that explains how to revert the stripped off version control data of the given package and returns the URL and revision of it. N)ÚNotImplementedError)rÚcontentrrrÚparse_vcs_bundle_file˜sz$VersionControl.parse_vcs_bundle_filecCs t‚dS)zx Called when installing or updating an editable package, takes the source path of the checkout. N)rj)rÚdestrrrÚobtain szVersionControl.obtaincCs t‚dS)zB Switch the repo at ``dest`` to point to ``URL``. N)ÚNotImplemented)rrmr?Ú rev_optionsrrrÚswitch§szVersionControl.switchcCs t‚dS)zO Update an already-existing repo to the given ``rev_options``. N)rj)rrmrprrrÚupdate­szVersionControl.updatec Cs@d}d}tjj|ƒr#d}tjjtjj||jƒƒrú|j|ƒ}|j||ƒrÈtjd|j j ƒt |ƒ|fƒtj dt |ƒ|j |fƒ|j ||ƒq tjd|j|j t |ƒ|fƒd}q#tjd ||j|j fƒd}n|r<tjd |j|fƒtd|d|dƒ}|dkr¦tj d|j t |ƒ||fƒ|j|||ƒq<|dkrµq<|d krëtjdt |ƒƒt|ƒd}q<|d kr<t|ƒ} tjdt |ƒ| fƒtj|| ƒd}q<n|S)z­ Prepare a location to receive a checkout/clone. Return True if the location is ready for (and requires) a checkout/clone, False otherwise. TFz)%s in %s exists, and has correct URL (%s)zUpdating %s %s%sz%s %s in %s exists with URL %sú%(s)witch, (i)gnore, (w)ipe, (b)ackup ÚsÚiÚwÚbz0Directory %s already exists, and is not a %s %s.ú(i)gnore, (w)ipe, (b)ackup z+The plan is to install the %s repository %szWhat to do? %srrQzSwitching %s %s to %s%sz Deleting %szBacking up %s to %s©rtrurvrw)rsry©rurvrw)rxrz)r0r1r3r2r#rbrirrMÚ repo_nameÚtitlerÚnotifyrrr+r)r rqrrÚshutilÚmove) rrmr?rpÚ rev_displayÚcheckoutÚpromptÚ existing_urlÚresponseÚdest_dirrrrÚcheck_destination³sZ$                      z VersionControl.check_destinationcCs0tjj|ƒrt|ƒn|j|ƒdS)N)r0r1r3rrn)rr4rrrÚunpackís zVersionControl.unpackFcCs t‚dS)N)rj)rÚdistr4Ú find_tagsrrrr òsz"VersionControl.get_src_requirement)r,r:r;r)r#rrErLr<rOr^rdrfrirlrnrqrrr†r‡r rr)rrr=Vs"            : r=cCsFtj|ƒ}|r+|ƒj|||ƒStjd|ƒ|jƒS)Nztcannot determine version of editable source in %s (is not SVN checkout, Git clone, Mercurial clone or Bazaar branch))r r9r rr+Úas_requirement)rˆr4r‰Úversion_controlrrrr ös )Ú__doc__r0r~Zpip.backwardcompatrrÚpip.logrÚpip.utilrrrrr Ú__all__Úobjectr r r=r rrrrÚs  ( D