ï»¿Ã¿Ã˜Ã¿Ã  JFIF      Ã¿Ã› â€ž 	 ( %!1"%)+...383-7(-.+



-%%--------+------------/----------------------------Ã¿Ã€  Â¶" Ã¿Ã„               Ã¿Ã„ @       !1AQaqÂ�â€˜Â¡"Â±Ã�Ã‘Ã°2â€™BRrÃ¡Sâ€šÃ±3bÂ¢CTÂ²Ã’ #cÃ¿Ã„             Ã¿Ã„ '        1!AQ2a"â€˜Â±#Ã¿Ãš   ? Ã²(/pâ€˜â€”â€“Â¢Â·,M|Â¯GÂ»RÂ£Ã¼eÅ¡T. Ã´Å¸EoCFÃ±â€¡ 4Ã”kÃ¥Ã³xR|Â�Â�ÂµÃ�Â¨Ã“DÃ !Ã‡Â´ÂµËœâ€¡p Ã�Qâ€¹Â§!Ã¾Å¾^ÃµWsÅ’y Â Ã¥Ã�Â§$Ã¡Â«%ÂºqËœâ„¢JyyÃ‹0yÂ�Â«^Ã�Â�
-3ÃƒÃ�Ã‹ÃˆÂ£Ã†\Pâ€™Ã¤â€žs&â€¢â€¹Ãœs Ã¼Ã´'Ã WtÂ¹pÃ±Cp$bÃšF`Â·7.^)Â¾!)Ã’Ã™Ëœâ€“Ã…Ã�Å¡^hÂ¾Ã¸Â³Â·Ã¬eÂ±Å’aeÃ–â€”Ã�,e=B}JÃ©ÃŸÂ¦$$Â½â€”Å¡Ã™ÃœCCÂ¯Â¶Ã¨8ÃŽÂ²â€“Ã…kÃ¨wx
LÃ‰ngTÂ±Ã¦Â¹Â£Ã“cÅ“Â¿Ã�/Â©Ã‰Ã¿ â€°ÃšCÃ’Â­mq;TtÂ¶â€“}0"zÃ–Pcd1Å¡Â­Â¤tË†â€žÃ�Ã“Ã¢qÃº[â„¢Ã¶UCÅ 2ÃžÂ¿Ã˜Â¯Â­Ã‰(Â¸ÃŸÃºÃ§Å¡mW,Ã’ Âºfâ€¹Ã…nâ„¢Ã„LÃªÃƒÂ�8Ã¼Ã�kÃ�â‚¬LÂ¥Ã�uJ1Å“Ã´rÃ‚SÅ’Ã“Ã¶tÂ�!7EUÃ­Ã¯b)Â�AÃ‹iÂ¬Ã¢-Ã™Hk8Ã²Ã�iXYwÃ…)OÂ�^"Ã‡Ã˜riÃ›Ã´{Â»wRUKÃ™Ã�ÃšlÃ“Â¬â‚¬â€šâ€™Ã—Â©T]
Âªbâ€”ÃŠÃ®KC^Ã—Mâ€œxÃ¹Ã¤Ã±zÂ¬zJÃ—{4[Â¹M'IÃ†eH1LCWÃ•]Å“Ã»ÂºÂ WDÃ¦Ã Â°OÃ…â€šÂ¹cÂ²ÃžuAâ€“rL`HÅ¡pCezâ€¡Vâ€™â€”Â Å½â€šÃ‹â€žâ€“Ã±Â­'ÂµR0Ã•Ã–=Ã€:Â±GÂ»C\nÃ†Ã‰5*Â¢Â â€ Â�3Å¡hQ4Ã½Ã’i$Ã•1"Ãœ]Â¢p-q3zcQ$ÂªÃ¶Â¨Â¥Ã¦fâ€ºâ€˜Â»Â´Ã�ÃšHÃ¡â€žeÂ²JÃ‡â€“iÃŠ:Â·Ã Â¬Ã˜c5Ã…kÂ»LaÂª*wiÂ�
[0Ã“wk Â¦aÂ¦0Ã•Â²Ã…Ã…â€šTÂ¸â€™Â³q:Ã†<Â¹Ãº	Ã’ËœÃ†}2VEâ€¢Ã�â‚¬pÂ¡Ã”3ÃšÂº â€¦hÂ³^Ã‡â€¡ÂºÃ§Ã¬Â¥Ã�nÃ³|ËœÃ–Ë†ÃŽË†+Â«Â¦dÃ¸â€˜MÂºâ€“d\ÂªDÃ°Ã›â€žÃŒÃ—LÃ�â€”â€”Ã�9Ã‡|â€¢FÃ¨Ã§Vmâ„¢Â¨â‚¬â„¢3ÃµSâ€“9Ã„Ã¥Â¢<ÃŒâ€°ÃŒmÂ¢Â±`Â·ÂºËœ&ZÂ²Å¾ Ã‹Â®DÂ«Â¶Â»6â„¢â€°Â©Â­HÃˆÃ€Ã¡Â«hÂ­iÂ³04Ã¦â€™hxÅ“i3Ã¯Â¨(Ã“LÂ·â€ â€¹Â¶Ã‹pÅ’
Æ’ÃœÃ’?	:ÃµdsÃ€â€“3Ã¦Ã“Â·ÃœjÃ¢Â¬9â€”]8nÂ¼&]I FÂ£Â¼â€¦Ã¬â€“â€”Å’0vÂ°LÃ‡Â�Ã…fÃ›2TÃ–â€™aÂµËœN@Ã–BSÃ�^Ã Â´4-Â±Â°bÃ—nÃˆÃˆÅ“Ã†D=KdÅ’Ã¸â€¦Ã„ÃˆK,â€ºÃ–RÂ§fjÃ¼$^Ã”ÃŽ!â€ž6^ s:Ãœun\Ã´kCÃžÃ²Ã·<â€”LÃºl
Ã�â€ºGÂ¹Ã€PÃ¡Â¼NcÂ¡Å¡Ã’â€¦Ã™WÃ�Â³Å“Â±vÃŠÃ¡Ã�â€žÃ—9â€¹Pâ€°cEÃ˜â€˜â„¢â€ºÂµÅ¸P<Ã—g1
ÂºÂ©Ã˜Â¬wiÂ�Ã�^l5Ã—I/';Ã‹+Â´Zâ€¡Ã“Ã„FÃ•p[ÃˆÃ°â€™
HÃ„	Ã³
9Â¬Dl4â€œÃ©Â±Ã�â€�V=^HÃ°;Å¾LÃ¤dÃ‰aâ€šÂ°Ã‹,#/Å½~Â²BÃ”Ã›
QÃ£Ã±QtIeÃ³rVB,Ã�Ã‚fâ€¹4#ÃŽÅ“câ€¹Ã‰3ZIÃ–Â Å’Â¢Â¥Â·Ã¼xaâ€¡ÃƒÃ§Ã¨â€žjÅ [5 Ã„!U?,3Å¾ÃŽÃ—â€¦Ã°dÃ“Ã·hÃ¡Å Aâ€°Ã¬Â�Ã„4Ã·ÃƒÃœZÃƒE{â€°Â®+W\ZÃ�E[â€°Â»ÂµkÂ»MÃ�Â­`Â¢Â©â€ ËœÃƒVâ€¹-fÂ¢Â¡â€ Â¢aÂ«eÅ %Â«YÂ¨Â©q%jÃ¢d,Ã”q`) Â¤Â¦â€¦Å¡Ë† Â¦E>0Ã™bÂ²tâ€“Å¸Â�
Ã·jsÃ�â€šÃ’â€™KÃˆcÃ¸(Ã©â€º;k(â€™#Ã´Å’Q
â„¢Â�C>
ÃµÂ³M9Ã³ÂºÃ†ÂµÂ¤Ã§Ã¢;uÃ€Â�)5>RÃ”Â¸fÃ“~ÃˆÂ¦â€”â€™-$feÂ«"FÃ¢UË†ÃŠwÂµPÃ�u
w+"Ã¥Ã‰oÃŒÂ�Â¨6sâ„¢Ã›9Â�Â�(Ã€Â¨Ã¹Â©hEÂ°Â½â€ n`m~â€œ@Â©Â�â€ºp!VkhÂµÂ Ã�1Å¡bEqqÃŠ@ÂºÃ¨lâ€º2 â€“YÃ£%â€˜â€šhÃ›{aÂ¶â€¡Ã…ÃžMÂ²Â¬Ã§L34Â®Ã‡l]Â®â€¹Å½Ã˜Å’m'RÃœe35Ã¦Ã¶Ë†Â­Ã�Â­ cP9Å¡eÃ�kÃ¶oÂ´LÂ³ÃŒ=Â�p8]â€�â€¡BÂ¶,Å¡Âº|Ã‰Â�dzXË†Ã˜k*Ã‡Ãš{#Ã±â€°pÃ£(â‚¬Â¶â€¡9Ã½'Å¡ÃœÂ³Â½Â¯kÆ’â€ Ã‚â€™Ã«SOÆ’â€¢Ã…Â®H6+aÂ¢ÂµË†Â�â€¹YÂ¨bËœb+XË†Ã–!Â°u!Â¢"ÂµË†Â�Ë†n2Ë† Ã…0Ã„`Ã… Ã”Â®c(Â�Ã“ÃœGÂºâ€¢Ã„Â»Å’Â Ã¢WÃ®%q.Ã¡Ã�Ã„Ã·Ã®%umÃ�Â£+ÃœQ,VnÂ¦-GphUÂ¸Â¢XÂ­&,Gt
Â·KÂ¢Ã…Ã…Â·Â¥RÃ„ÃŠÃ‰bKn
NÂ­R2g$VÂµÃ•Ã³
Qr#â€“Ã“ZUÃ�Ã°0ÃŽtÃ™Ã€Å“z
Ã«Ã¶oâ€œÃŽkÂ¯nâ€žTÂ°"SÃž+Â³/â€¦â‚¬Â½"iÂ�Å¾Ã£O%Ã�%&ÃŽâ€�Ã¢â€˜Ã‹Ã˜Â´IË†Ã“Â°Ã‹â€°ÃžM<Jâ€¢â€ºC=Ã¬u*ÃœÂ§â€žÃƒÂ¤GÃ‹Å Ã´;5Â�Å’Ã�Â£Ã±Ã¹Ã¤Â¬6ÃŒ2Â¦â€˜Å¾hÂ¸RÂ�Âº<Ã•Å¡%Ã·Â â€¦Ã‡	â€šgâ€¡.
>3.â„¢yÃ§Ã�zitâ€º`4C`kÂ¢Â¼Ã¡!Ã¡lÃ„Ã¯ sÃ‚[Ã—!Â¤lÂ¾Ã¦o"Æ’Â�IÃ”'@Âªu)3â€ºÃ´Â®â€œ@Z
Ã Â¾]
Ã¼Å“'â€¡4Â¸PÃžkÃ�-qÃ„Hâ€°Ã“Ã�BdÂ´Ã¿ â€”Â¹Â°Ã„A&ÃŠUÂ�Câ€žÃ¶zâ€šâ€šRÃ¦Å tfÂ¬>ËœÃ‘idÅ¡EÃ§Ã‘LÃ·Ã¡Ã½Â¡VÂ±hÂ§Â­cÂ¿Â¥Â¨Æ’@gÂ¼â€¦Ã�Ã¶^ÃžÃ‹c.Ã…Â¾â€žÃ¦â€œIÂ�[Âª+Â·zÃ�Ã’Ãš,Â½Ã�Â»Â¶â‚¬Câ€º7jk$Ã Â¹â€“â‚¬Å½Â¾Ã…Ã™ppÂ¶Ã�Ã¾Ã©ÃŽÂ¤Â Â½Ã˜ÃŽÅ’q Ã±pÃ¦Å¾Ã…Â¥#Ã˜Ã¢4Â�9ÃƒÃ‚K^MYVâ€œ,Â¶Ã‰z_Ã²Ã¦:â€¦;Ã•Â«Â¦I3Ã¢JÂ£Â¤Ã»5$7ÃˆxÃ¼n\Ã¢]ÃŠeÂ¯(Å¸&Å½â€¹Â¶2<6Ã„â€ fÃ— Ã¦Â¢Ã†Â±qWÃ„Â±[(Ã™Ã‚Å½Ã§â€šT7Â¨@ÃˆÃ‰Ã�ÃŸâ€šÃ¯Ã™"&3TYlGÅ½Â�â€ )â€ #5Å AÂ©^T2Ã†Ã�â€ )Â©â€ Â©â€ Â¤yGXÃ�â€ Â©"â€ )Â©Â¼Ã…V WSâ€ #Â©]Râ€“râ€¹q5Ã•bÃ¢WÃ¾BhÂ¯u+ÂªÃ…Ã„Ã—Ã¼â€žnÃ‘^ÃªkÂªÃ�jâ€°jeÅ“WË†Ã•Ã•`ÂµDÂµ2ÃŒ+Ã„ ÂµDÂµÂµ5Ã”{Â¤Ãž0RFâ€™HÃ·AÃ›<ÃŠÃ�Â§ Ã†Ë†Ã¦0Ã‘Â£Ãª4 Ã¶ÃšÂµ[Â¬/1Â²â‚¬Ã¢<-Â¬Å¡Ã¶Â²rÃ—0oÃ—wÂ Â´Â�xÃ�Ã’Ã‹â€ž
g01Â¬â€žÃ¥EMÃ¨â€ºâ€¡Ãƒ\6ÂµEâ€ºâ€˜fÃ™O	kÃ·CÂºnÃ“1`iÃ®Ã’Â²Ã¡Ã‚!Ã‘LÃ„Ã¿ 
Â³Â¬Â�\Ãµ*:M=Ã‡Â»câ€¹2[â€°Ã˜sÃ•LÃ²\Å’KÂ L^â„¢Ã¼Ã„N\Â¶#Â»
Ã‡\â€¦â€¦ÃŸÃ¯IÅ“Ã‰$Â¸ÃŽÃ±Ã�Â®Ã”HÃƒâ€¡	Ã›Ã­/Â´>Liâ€�â€žâ€ g^$ 7NÃ�Ã‘Ã‘2M2ÂªNg=kÂ½Ã�}Å¸l6â€¡	â€”JWË†â€�ÃžÃ©TÂ·+ÂµÂ¦Ã¼Ã‚FÃ¨Â¢Vs6Ã½Ã†4Â»2+2IÃ�9Ã´9Â®Ã‡GÃ™Ã‡1+Ã„8;*Ã•Â§Å¾Â½D*Ã®Ã‘WÃšÃ§Ã¡3MaÂ¤Â·Ë†Â¥t}Å¡Â²Ãœâ€¦Q+Ã†Ã¼Âµ8HÃ­Sâ€�Ã¼xGÃ©Ã�Ë†Â¦Ã‹lâ€žÃ©Ãˆ	5 ÂµÃ„Æ’6Ã¤Ãœ(kIÅ¡Â¯Sâ€ fÃ–&Â¸Â®Ã—v|Ã„yË†*Ã§Â¦Å’Ã‰Ã¹@7-Â®Ã„[]ÃŽÃ–Â¿Ãª`Âºâ€¦=:â€¦Å¾JVnÃ�Â³vÃ°Ã–KEÂ¼â€š Â»mÃ  Ã·fÂ®:Ã‹â„¢â€“4Â�rÃ°Â¡4` ÃœÂ¹Ã§Å¾~â€¹C=Å“â€¦Â¾Ã�j|VDtK.Æ’"9	Ã�
Â­â€“Ã©XÃ¡Â³6WÃ’Ã¯IL-Ã�â€¡
Ã‡
PK     (\Y]n4•A†$  †$    subversion.pynu „[µü¤        from __future__ import absolute_import

import logging
import os
import re

from pip._vendor.six.moves.urllib import parse as urllib_parse

from pip.index import Link
from pip.utils import rmtree, display_path
from pip.utils.logging import indent_log
from pip.vcs import vcs, VersionControl

_svn_xml_url_re = re.compile('url="([^"]+)"')
_svn_rev_re = re.compile('committed-rev="(\d+)"')
_svn_url_re = re.compile(r'URL: (.+)')
_svn_revision_re = re.compile(r'Revision: (.+)')
_svn_info_xml_rev_re = re.compile(r'\s*revision="(\d+)"')
_svn_info_xml_url_re = re.compile(r'<url>(.*)</url>')


logger = logging.getLogger(__name__)


class Subversion(VersionControl):
    name = 'svn'
    dirname = '.svn'
    repo_name = 'checkout'
    schemes = ('svn', 'svn+ssh', 'svn+http', 'svn+https', 'svn+svn')

    def get_info(self, location):
        """Returns (url, revision), where both are strings"""
        assert not location.rstrip('/').endswith(self.dirname), \
            'Bad directory: %s' % location
        output = self.run_command(
            ['info', location],
            show_stdout=False,
            extra_environ={'LANG': 'C'},
        )
        match = _svn_url_re.search(output)
        if not match:
            logger.warning(
                'Cannot determine URL of svn checkout %s',
                display_path(location),
            )
            logger.debug('Output that cannot be parsed: \n%s', output)
            return None, None
        url = match.group(1).strip()
        match = _svn_revision_re.search(output)
        if not match:
            logger.warning(
                'Cannot determine revision of svn checkout %s',
                display_path(location),
            )
            logger.debug('Output that cannot be parsed: \n%s', output)
            return url, None
        return url, match.group(1)

    def export(self, location):
        """Export the svn repository at the url to the destination location"""
        url, rev = self.get_url_rev()
        rev_options = get_rev_options(url, rev)
        url = self.remove_auth_from_url(url)
        logger.info('Exporting svn repository %s to %s', url, location)
        with indent_log():
            if os.path.exists(location):
                # Subversion doesn't like to check out over an existing
                # directory --force fixes this, but was only added in svn 1.5
                rmtree(location)
            self.run_command(
                ['export'] + rev_options + [url, location],
                show_stdout=False)

    def switch(self, dest, url, rev_options):
        self.run_command(['switch'] + rev_options + [url, dest])

    def update(self, dest, rev_options):
        self.run_command(['update'] + rev_options + [dest])

    def obtain(self, dest):
        url, rev = self.get_url_rev()
        rev_options = get_rev_options(url, rev)
        url = self.remove_auth_from_url(url)
        if rev:
            rev_display = ' (to revision %s)' % rev
        else:
            rev_display = ''
        if self.check_destination(dest, url, rev_options, rev_display):
            logger.info(
                'Checking out %s%s to %s',
                url,
                rev_display,
                display_path(dest),
            )
            self.run_command(['checkout', '-q'] + rev_options + [url, dest])

    def get_location(self, dist, dependency_links):
        for url in dependency_links:
            egg_fragment = Link(url).egg_fragment
            if not egg_fragment:
                continue
            if '-' in egg_fragment:
                # FIXME: will this work when a package has - in the name?
                key = '-'.join(egg_fragment.split('-')[:-1]).lower()
            else:
                key = egg_fragment
            if key == dist.key:
                return url.split('#', 1)[0]
        return None

    def get_revision(self, location):
        """
        Return the maximum revision for all files under a given location
        """
        # Note: taken from setuptools.command.egg_info
        revision = 0

        for base, dirs, files in os.walk(location):
            if self.dirname not in dirs:
                dirs[:] = []
                continue    # no sense walking uncontrolled subdirs
            dirs.remove(self.dirname)
            entries_fn = os.path.join(base, self.dirname, 'entries')
            if not os.path.exists(entries_fn):
                # FIXME: should we warn?
                continue

            dirurl, localrev = self._get_svn_url_rev(base)

            if base == location:
                base_url = dirurl + '/'   # save the root url
            elif not dirurl or not dirurl.startswith(base_url):
                dirs[:] = []
                continue    # not part of the same svn tree, skip it
            revision = max(revision, localrev)
        return revision

    def get_url_rev(self):
        # hotfix the URL scheme after removing svn+ from svn+ssh:// readd it
        url, rev = super(Subversion, self).get_url_rev()
        if url.startswith('ssh://'):
            url = 'svn+' + url
        return url, rev

    def get_url(self, location):
        # In cases where the source is in a subdirectory, not alongside
        # setup.py we have to look up in the location until we find a real
        # setup.py
        orig_location = location
        while not os.path.exists(os.path.join(location, 'setup.py')):
            last_location = location
            location = os.path.dirname(location)
            if location == last_location:
                # We've traversed up to the root of the filesystem without
                # finding setup.py
                logger.warning(
                    "Could not find setup.py for directory %s (tried all "
                    "parent directories)",
                    orig_location,
                )
                return None

        return self._get_svn_url_rev(location)[0]

    def _get_svn_url_rev(self, location):
        from pip.exceptions import InstallationError

        entries_path = os.path.join(location, self.dirname, 'entries')
        if os.path.exists(entries_path):
            with open(entries_path) as f:
                data = f.read()
        else:  # subversion >= 1.7 does not have the 'entries' file
            data = ''

        if (data.startswith('8') or
                data.startswith('9') or
                data.startswith('10')):
            data = list(map(str.splitlines, data.split('\n\x0c\n')))
            del data[0][0]  # get rid of the '8'
            url = data[0][3]
            revs = [int(d[9]) for d in data if len(d) > 9 and d[9]] + [0]
        elif data.startswith('<?xml'):
            match = _svn_xml_url_re.search(data)
            if not match:
                raise ValueError('Badly formatted data: %r' % data)
            url = match.group(1)    # get repository URL
            revs = [int(m.group(1)) for m in _svn_rev_re.finditer(data)] + [0]
        else:
            try:
                # subversion >= 1.7
                xml = self.run_command(
                    ['info', '--xml', location],
                    show_stdout=False,
                )
                url = _svn_info_xml_url_re.search(xml).group(1)
                revs = [
                    int(m.group(1)) for m in _svn_info_xml_rev_re.finditer(xml)
                ]
            except InstallationError:
                url, revs = None, []

        if revs:
            rev = max(revs)
        else:
            rev = 0

        return url, rev

    def get_src_requirement(self, dist, location):
        repo = self.get_url(location)
        if repo is None:
            return None
        # FIXME: why not project name?
        egg_project_name = dist.egg_name().split('-', 1)[0]
        rev = self.get_revision(location)
        return 'svn+%s@%s#egg=%s' % (repo, rev, egg_project_name)

    def check_version(self, dest, rev_options):
        """Always assume the versions don't match"""
        return False

    @staticmethod
    def remove_auth_from_url(url):
        # Return a copy of url with 'username:password@' removed.
        # username/pass params are passed to subversion through flags
        # and are not recognized in the url.

        # parsed url
        purl = urllib_parse.urlsplit(url)
        stripped_netloc = \
            purl.netloc.split('@')[-1]

        # stripped url
        url_pieces = (
            purl.scheme, stripped_netloc, purl.path, purl.query, purl.fragment
        )
        surl = urllib_parse.urlunsplit(url_pieces)
        return surl


def get_rev_options(url, rev):
    if rev:
        rev_options = ['-r', rev]
    else:
        rev_options = []

    r = urllib_parse.urlsplit(url)
    if hasattr(r, 'username'):
        # >= Python-2.5
        username, password = r.username, r.password
    else:
        netloc = r[1]
        if '@' in netloc:
            auth = netloc.split('@')[0]
            if ':' in auth:
                username, password = auth.split(':', 1)
            else:
                username, password = auth, None
        else:
            username, password = None, None

    if username:
        rev_options += ['--username', username]
    if password:
        rev_options += ['--password', password]
    return rev_options


vcs.register(Subversion)
PK     (\Y]f·ê«3  «3    __init__.pycnu „[µü¤        ó
•�abc           @@  s÷   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m	 Z
 d d l m Z d d l m Z m Z m Z m Z m Z d d g Z e j e ƒ Z d	 e f d
 „  ƒ  YZ e ƒ  Z d e f d „  ƒ  YZ d „  Z d S(   s)   Handles all VCS (version control) supporti    (   t   absolute_importN(   t   parse(   t
   BadCommand(   t   display_patht
   backup_dirt   call_subprocesst   rmtreet   ask_path_existst   vcst   get_src_requirementt
   VcsSupportc           B@  s˜   e  Z i  Z d  d d d d d g Z d „  Z d „  Z e d „  ƒ Z e d	 „  ƒ Z e d
 „  ƒ Z	 d „  Z
 d d d „ Z d „  Z d „  Z d „  Z RS(   t   ssht   gitt   hgt   bzrt   sftpt   svnc         C@  sR   t  j j |  j ƒ t t  d d  ƒ r; t  j j |  j ƒ n  t t |  ƒ j	 ƒ  d  S(   Nt   uses_fragment(
   t   urllib_parset   uses_netloct   extendt   schemest   getattrt   NoneR   t   superR
   t   __init__(   t   self(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR      s    c         C@  s   |  j  j ƒ  S(   N(   t	   _registryt   __iter__(   R   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR   $   s    c         C@  s   t  |  j j ƒ  ƒ S(   N(   t   listR   t   values(   R   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   backends'   s    c         C@  s   g  |  j  D] } | j ^ q
 S(   N(   R   t   dirname(   R   t   backend(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   dirnames+   s    c         C@  s.   g  } x! |  j  D] } | j | j ƒ q W| S(   N(   R   R   R   (   R   R   R!   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   all_schemes/   s    c         C@  sb   t  | d ƒ s& t j d | j ƒ d  S| j |  j k r^ | |  j | j <t j d | j ƒ n  d  S(   Nt   names   Cannot register VCS %ss   Registered VCS backend: %s(   t   hasattrt   loggert   warningt   __name__R$   R   t   debug(   R   t   cls(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   register6   s    c         C@  sR   | |  j  k r |  j  | =n2 | |  j  j ƒ  k rA |  j  | j =n t j d ƒ d  S(   Ns0   Cannot unregister because no class or name given(   R   R   R$   R&   R'   (   R   R*   R$   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt
   unregister>   s
    c         C@  sJ   xC |  j  j ƒ  D]2 } | j | ƒ r t j d | | j ƒ | j Sq Wd S(   s—   
        Return the name of the version control backend if found at given
        location, e.g. vcs.get_backend_name('/path/to/vcs/checkout')
        s   Determine that %s uses VCS: %sN(   R   R   t   controls_locationR&   R)   R$   R   (   R   t   locationt   vc_type(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   get_backend_nameF   s    	c         C@  s*   | j  ƒ  } | |  j k r& |  j | Sd  S(   N(   t   lowerR   (   R   R$   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   get_backendR   s    c         C@  s&   |  j  | ƒ } | r" |  j | ƒ Sd  S(   N(   R0   R2   R   (   R   R.   R/   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   get_backend_from_locationW   s    N(   R(   t
   __module__R   R   R   R   t   propertyR   R"   R#   R+   R   R,   R0   R2   R3   (    (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR
      s   						t   VersionControlc           B@  sà   e  Z d  Z d  Z d Z d d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d d d d d d „ Z e d „  ƒ Z RS(   t    c         O@  s&   | |  _  t t |  ƒ j | | Ž  d  S(   N(   t   urlR   R6   R   (   R   R8   t   argst   kwargs(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR   g   s    	c         C@  s1   t  j j | ƒ \ } } | j t  j j ƒ p0 | S(   sy   
           posix absolute paths start with os.path.sep,
           win32 ones start with drive (like c:\folder)
        (   t   ost   patht
   splitdrivet
   startswitht   sep(   R   t   repot   drivet   tail(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   _is_local_repositoryk   s    c         C@  s   | j  d d ƒ S(   Nt   /t   _(   t   replace(   R   t   surname(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   translate_egg_surnameu   s    c         C@  s
   t  ‚ d S(   s�   
        Export the repository at the url to the destination location
        i.e. only download the files, without vcs informations
        N(   t   NotImplementedError(   R   R.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   exporty   s    c   	      C@  s´   d } d |  j  k s( t | |  j  ƒ ‚ |  j  j d d ƒ d } t j | ƒ \ } } } } } d } d | k rŒ | j d d ƒ \ } } n  t j | | | | d f ƒ } | | f S(   sm   
        Returns the correct repository URL and revision by parsing the given
        repository URL
        sv   Sorry, '%s' is a malformed VCS url. The format is <vcs>+<protocol>://<url>, e.g. svn+http://myrepo/svn/MyApp#egg=MyAppt   +i   t   @R7   N(   R8   t   AssertionErrort   splitR   t   urlsplitR   t   rsplitt
   urlunsplit(	   R   t   error_messageR8   t   schemet   netlocR<   t   queryt   fragt   rev(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   get_url_rev€   s    "c         C@  sH   | j  d ƒ j |  j ƒ s, t d | ƒ ‚ |  j | ƒ |  j | ƒ f S(   sA   
        Returns (url, revision), where both are strings
        RD   s   Bad directory: %s(   t   rstript   endswithR    RM   t   get_urlt   get_revision(   R   R.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   get_info“   s    c         C@  s   t  j | ƒ j d ƒ S(   si   
        Normalize a URL for comparison by unquoting it and removing any
        trailing slash.
        RD   (   R   t   unquoteRY   (   R   R8   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   normalize_url›   s    c         C@  s   |  j  | ƒ |  j  | ƒ k S(   sV   
        Compare two repo URLs for identity, ignoring incidental differences.
        (   R_   (   R   t   url1t   url2(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   compare_urls¢   s    c         C@  s
   t  ‚ d S(   sx   
        Called when installing or updating an editable package, takes the
        source path of the checkout.
        N(   RI   (   R   t   dest(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   obtain¨   s    c         C@  s
   t  ‚ d S(   sB   
        Switch the repo at ``dest`` to point to ``URL``.
        N(   RI   (   R   Rc   R8   t   rev_options(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   switch¯   s    c         C@  s
   t  ‚ d S(   sO   
        Update an already-existing repo to the given ``rev_options``.
        N(   RI   (   R   Rc   Re   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   updateµ   s    c         C@  s
   t  ‚ d S(   sp   
        Return True if the version is identical to what exists and
        doesn't need to be updated.
        N(   RI   (   R   Rc   Re   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   check_version»   s    c   
      C@  sm  t  } t } t j j | ƒ rAt } t j j t j j | |  j ƒ ƒ r|  j | ƒ } |  j | | ƒ râ t	 j
 d |  j j ƒ  t | ƒ | ƒ |  j | | ƒ sÒ t	 j d t | ƒ |  j | ƒ |  j | | ƒ qt	 j d ƒ q>t	 j d |  j |  j t | ƒ | ƒ d d f } qAt	 j d
 | |  j |  j ƒ d d f } n  | rit	 j d |  j | ƒ t d | d | d ƒ } | d k r¼t	 j d |  j t | ƒ | | ƒ |  j | | | ƒ qi| d k rËqi| d k r t	 j d t | ƒ ƒ t | ƒ t  } qi| d	 k rJt | ƒ }	 t	 j d t | ƒ |	 ƒ t j | |	 ƒ t  } qi| d k rit j d ƒ qin  | S(   s­   
        Prepare a location to receive a checkout/clone.

        Return True if the location is ready for (and requires) a
        checkout/clone, False otherwise.
        s)   %s in %s exists, and has correct URL (%s)s   Updating %s %s%ss$   Skipping because already up-to-date.s   %s %s in %s exists with URL %ss%   (s)witch, (i)gnore, (w)ipe, (b)ackup t   st   it   wt   bs0   Directory %s already exists, and is not a %s %s.s   (i)gnore, (w)ipe, (b)ackup s+   The plan is to install the %s repository %ss   What to do?  %si    i   s   Switching %s %s to %s%ss   Deleting %ss   Backing up %s to %st   aiÿÿÿÿ(   Ri   Rj   Rk   Rl   (   Rj   Rk   Rl   (   t   Truet   FalseR;   R<   t   existst   joinR    R[   Rb   R&   R)   t	   repo_namet   titleR   Rh   t   infoRg   R'   R$   R   Rf   R   R   t   shutilt   movet   syst   exit(
   R   Rc   R8   Re   t   rev_displayt   checkoutt   promptt   existing_urlt   responset   dest_dir(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   check_destinationÂ   s‚    $		
	
	
		c         C@  s0   t  j j | ƒ r t | ƒ n  |  j | ƒ d S(   sq   
        Clean up current location and download the url repository
        (and vcs infos) into location
        N(   R;   R<   Rp   R   Rd   (   R   R.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   unpack  s    c         C@  s
   t  ‚ d S(   sê   
        Return a string representing the requirement needed to
        redownload the files currently present in location, something
        like:
          {repository_url}@{revision}#egg={project_name}-{version_identifier}
        N(   RI   (   R   t   distR.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR	      s    c         C@  s
   t  ‚ d S(   s_   
        Return the url used at location
        Used in get_info or check_destination
        N(   RI   (   R   R.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR[   )  s    c         C@  s
   t  ‚ d S(   s_   
        Return the current revision of the files at location
        Used in get_info
        N(   RI   (   R   R.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR\   0  s    t   raisec   	      C@  su   |  j  g | } y  t | | | | | | | ƒ SWn> t k
 rp } | j t j k rj t d |  j  ƒ ‚ qq ‚  n Xd S(   s«   
        Run a VCS subcommand
        This is simply a wrapper around call_subprocess that adds the VCS
        command name, and checks that the VCS is available
        s   Cannot find command %rN(   R$   R   t   OSErrort   errnot   ENOENTR   (	   R   t   cmdt   show_stdoutt   cwdt   on_returncodet   command_desct   extra_environt   spinnert   e(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   run_command7  s    	c         C@  sD   t  j d | |  j |  j ƒ t j j | |  j ƒ } t j j | ƒ S(   s¨   
        Check if a location is controlled by the vcs.
        It is meant to be overridden to implement smarter detection
        mechanisms for specific vcs.
        s   Checking in %s for %s (%s)...(   R&   R)   R    R$   R;   R<   Rq   Rp   (   R*   R.   R<   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR-   N  s    	(    N(   R(   R4   R$   R    R   R   R   RC   RH   RJ   RX   R]   R_   Rb   Rd   Rf   Rg   Rh   R   R€   R	   R[   R\   Rn   RŽ   t   classmethodR-   (    (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR6   a   s2   	
											U						c         C@  sz   t  j | ƒ } | r` y | ƒ  j |  | ƒ SWq` t k
 r\ t j d | | j ƒ |  j ƒ  SXn  t j d | ƒ |  j ƒ  S(   NsP   cannot determine version of editable source in %s (%s command not found in path)st   cannot determine version of editable source in %s (is not SVN checkout, Git clone, Mercurial clone or Bazaar branch)(   R   R3   R	   R   R&   R'   R$   t   as_requirement(   R�   R.   t   version_control(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR	   [  s    
(   t   __doc__t
   __future__R    R„   t   loggingR;   Ru   Rw   t   pip._vendor.six.moves.urllibR   R   t   pip.exceptionsR   t	   pip.utilsR   R   R   R   R   t   __all__t	   getLoggerR(   R&   t   objectR
   R   R6   R	   (    (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   <module>   s   (G	úPK     (\Y]y©¦6ž  ž  
  bazaar.pyonu „[µü¤        ó
•�abc           @@  sÚ   d  d l  m Z d  d l Z d  d l Z d  d l Z y d  d l m Z Wn e k
 rg d  d l	 Z n Xd  d l
 m Z m Z d  d l m Z m Z d  d l m Z e j e ƒ Z d e f d „  ƒ  YZ e j e ƒ d S(	   i    (   t   absolute_importN(   t   parse(   t   rmtreet   display_path(   t   vcst   VersionControl(   t   path_to_urlt   Bazaarc           B@  s}   e  Z d  Z d Z d Z d Z d d	 „ Z d
 „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   t   bzrs   .bzrt   branchs   bzr+https	   bzr+httpss   bzr+sshs   bzr+sftps   bzr+ftps   bzr+lpc         O@  s[   t  t |  ƒ j | | | Ž t t d d  ƒ rW t j j d g ƒ t j j d g ƒ n  d  S(   Nt   uses_fragmentt   lp(	   t   superR   t   __init__t   getattrt   urllib_parset   NoneR
   t   extendt   non_hierarchical(   t   selft   urlt   argst   kwargs(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR      s    c         C@  ss   t  j d d ƒ } |  j | ƒ t j j | ƒ r> t | ƒ n  z# |  j d | g d | d t ƒWd t | ƒ Xd S(   sU   
        Export the Bazaar repository at the url to the destination location
        s   -exports   pip-t   exportt   cwdt   show_stdoutN(	   t   tempfilet   mkdtempt   unpackt   ost   patht   existsR   t   run_commandt   False(   R   t   locationt   temp_dir(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR   &   s    c         C@  s   |  j  d | g d | ƒd  S(   Nt   switchR   (   R    (   R   t   destR   t   rev_options(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR$   5   s    c         C@  s!   |  j  d d g | d | ƒd  S(   Nt   pulls   -qR   (   R    (   R   R%   R&   (    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   update8   s    c         C@  s™   |  j  ƒ  \ } } | r1 d | g } d | } n g  } d } |  j | | | | ƒ r• t j d | | t | ƒ ƒ |  j d d g | | | g ƒ n  d  S(   Ns   -rs    (to revision %s)t    s   Checking out %s%s to %sR	   s   -q(   t   get_url_revt   check_destinationt   loggert   infoR   R    (   R   R%   R   t   revR&   t   rev_display(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   obtain;   s    c         C@  sA   t  t |  ƒ j ƒ  \ } } | j d ƒ r7 d | } n  | | f S(   Ns   ssh://s   bzr+(   R   R   R*   t
   startswith(   R   R   R.   (    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR*   L   s    c         C@  s•   |  j  d g d t d | ƒ} xp | j ƒ  D]b } | j ƒ  } xM d D]E } | j | ƒ rD | j | ƒ d } |  j | ƒ r… t | ƒ S| SqD Wq+ Wd  S(   NR-   R   R   s   checkout of branch: s   parent branch: i   (   s   checkout of branch: s   parent branch: (	   R    R!   t
   splitlinest   stripR1   t   splitt   _is_local_repositoryR   R   (   R   R"   t   urlst   linet   xt   repo(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   get_urlS   s    

c         C@  s,   |  j  d g d t d | ƒ} | j ƒ  d S(   Nt   revnoR   R   iÿÿÿÿ(   R    R!   R2   (   R   R"   t   revision(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   get_revision`   s    c         C@  sw   |  j  | ƒ } | s d  S| j ƒ  j d ƒ s; d | } n  | j ƒ  j d d ƒ d } |  j | ƒ } d | | | f S(   Ns   bzr:s   bzr+t   -i   i    s   %s@%s#egg=%s(   R:   R   t   lowerR1   t   egg_nameR4   R=   (   R   t   distR"   R9   t   egg_project_namet   current_rev(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   get_src_requiremente   s    c         C@  s   t  S(   s&   Always assume the versions don't match(   R!   (   R   R%   R&   (    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   check_versiono   s    (   R   s   bzr+https	   bzr+httpss   bzr+sshs   bzr+sftps   bzr+ftps   bzr+lpN(   t   __name__t
   __module__t   namet   dirnamet	   repo_namet   schemesR   R   R   R$   R(   R0   R*   R:   R=   RD   RE   (    (    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR      s    								
(   t
   __future__R    t   loggingR   R   t   urllibR   R   t   ImportErrort   urlparset	   pip.utilsR   R   t   pip.vcsR   R   t   pip.downloadR   t	   getLoggerRF   R,   R   t   register(    (    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   <module>   s   _PK     (\Y]ybj�  �    mercurial.pynu „[µü¤        from __future__ import absolute_import

import logging
import os
import tempfile

from pip.utils import display_path, rmtree
from pip.vcs import vcs, VersionControl
from pip.download import path_to_url
from pip._vendor.six.moves import configparser


logger = logging.getLogger(__name__)


class Mercurial(VersionControl):
    name = 'hg'
    dirname = '.hg'
    repo_name = 'clone'
    schemes = ('hg', 'hg+http', 'hg+https', 'hg+ssh', 'hg+static-http')

    def export(self, location):
        """Export the Hg repository at the url to the destination location"""
        temp_dir = tempfile.mkdtemp('-export', 'pip-')
        self.unpack(temp_dir)
        try:
            self.run_command(
                ['archive', location], show_stdout=False, cwd=temp_dir)
        finally:
            rmtree(temp_dir)

    def switch(self, dest, url, rev_options):
        repo_config = os.path.join(dest, self.dirname, 'hgrc')
        config = configparser.SafeConfigParser()
        try:
            config.read(repo_config)
            config.set('paths', 'default', url)
            with open(repo_config, 'w') as config_file:
                config.write(config_file)
        except (OSError, configparser.NoSectionError) as exc:
            logger.warning(
                'Could not switch Mercurial repository to %s: %s', url, exc,
            )
        else:
            self.run_command(['update', '-q'] + rev_options, cwd=dest)

    def update(self, dest, rev_options):
        self.run_command(['pull', '-q'], cwd=dest)
        self.run_command(['update', '-q'] + rev_options, cwd=dest)

    def obtain(self, dest):
        url, rev = self.get_url_rev()
        if rev:
            rev_options = [rev]
            rev_display = ' (to revision %s)' % rev
        else:
            rev_options = []
            rev_display = ''
        if self.check_destination(dest, url, rev_options, rev_display):
            logger.info(
                'Cloning hg %s%s to %s',
                url,
                rev_display,
                display_path(dest),
            )
            self.run_command(['clone', '--noupdate', '-q', url, dest])
            self.run_command(['update', '-q'] + rev_options, cwd=dest)

    def get_url(self, location):
        url = self.run_command(
            ['showconfig', 'paths.default'],
            show_stdout=False, cwd=location).strip()
        if self._is_local_repository(url):
            url = path_to_url(url)
        return url.strip()

    def get_revision(self, location):
        current_revision = self.run_command(
            ['parents', '--template={rev}'],
            show_stdout=False, cwd=location).strip()
        return current_revision

    def get_revision_hash(self, location):
        current_rev_hash = self.run_command(
            ['parents', '--template={node}'],
            show_stdout=False, cwd=location).strip()
        return current_rev_hash

    def get_src_requirement(self, dist, location):
        repo = self.get_url(location)
        if not repo.lower().startswith('hg:'):
            repo = 'hg+' + repo
        egg_project_name = dist.egg_name().split('-', 1)[0]
        if not repo:
            return None
        current_rev_hash = self.get_revision_hash(location)
        return '%s@%s#egg=%s' % (repo, current_rev_hash, egg_project_name)

    def check_version(self, dest, rev_options):
        """Always assume the versions don't match"""
        return False

vcs.register(Mercurial)
PK     (\Y]°{^TZ!  Z!    subversion.pyonu „[µü¤        ó
•�abc           @@  s)  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 d  d l
 m Z m Z d  d l m Z d  d l m Z m Z e j d ƒ Z e j d	 ƒ Z e j d
 ƒ Z e j d ƒ Z e j d ƒ Z e j d ƒ Z e j e ƒ Z d e f d „  ƒ  YZ d „  Z e j e ƒ d S(   i    (   t   absolute_importN(   t   parse(   t   Link(   t   rmtreet   display_path(   t
   indent_log(   t   vcst   VersionControls   url="([^"]+)"s   committed-rev="(\d+)"s	   URL: (.+)s   Revision: (.+)s   \s*revision="(\d+)"s   <url>(.*)</url>t
   Subversionc           B@  s›   e  Z d  Z d Z d Z d Z d „  Z d „  Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z RS(   t   svns   .svnt   checkouts   svn+sshs   svn+https	   svn+httpss   svn+svnc         C@  sÔ   |  j  d | g d t d i d d 6ƒ} t j | ƒ } | sg t j d t | ƒ ƒ t j d | ƒ d S| j	 d ƒ j
 ƒ  } t j | ƒ } | sÁ t j d	 t | ƒ ƒ t j d | ƒ | d
 f S| | j	 d ƒ f S(   s/   Returns (url, revision), where both are stringst   infot   show_stdoutt   extra_environt   Ct   LANGs'   Cannot determine URL of svn checkout %ss!   Output that cannot be parsed: 
%si   s,   Cannot determine revision of svn checkout %sN(   NN(   t   run_commandt   Falset   _svn_url_ret   searcht   loggert   warningR   t   debugt   Nonet   groupt   stript   _svn_revision_re(   t   selft   locationt   outputt   matcht   url(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   get_info   s(    
c         C@  sš   |  j  ƒ  \ } } t | | ƒ } |  j | ƒ } t j d | | ƒ t ƒ  �H t j j | ƒ rl t	 | ƒ n  |  j
 d g | | | g d t ƒWd QXd S(   s@   Export the svn repository at the url to the destination locations!   Exporting svn repository %s to %st   exportR   N(   t   get_url_revt   get_rev_optionst   remove_auth_from_urlR   R   R   t   ost   patht   existsR   R   R   (   R   R   R   t   revt   rev_options(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR!   ;   s    
c         C@  s"   |  j  d g | | | g ƒ d  S(   Nt   switch(   R   (   R   t   destR   R)   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR*   J   s    c         C@  s   |  j  d g | | g ƒ d  S(   Nt   update(   R   (   R   R+   R)   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR,   M   s    c         C@  s¥   |  j  ƒ  \ } } t | | ƒ } |  j | ƒ } | rC d | } n d } |  j | | | | ƒ r¡ t j d | | t | ƒ ƒ |  j d d g | | | g ƒ n  d  S(   Ns    (to revision %s)t    s   Checking out %s%s to %sR
   s   -q(   R"   R#   R$   t   check_destinationR   R   R   R   (   R   R+   R   R(   R)   t   rev_display(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   obtainP   s    c         C@  sŠ   xƒ | D]{ } t  | ƒ j } | s( q n  d | k rY d j | j d ƒ d  ƒ j ƒ  } n | } | | j k r | j d d ƒ d Sq Wd  S(   Nt   -iÿÿÿÿt   #i   i    (   R   t   egg_fragmentt   joint   splitt   lowert   keyR   (   R   t   distt   dependency_linksR   R3   R7   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   get_locationa   s    %c   
      C@  sí   d } xà t  j | ƒ D]Ï \ } } } |  j | k rA g  | (q n  | j |  j ƒ t  j j | |  j d ƒ } t  j j | ƒ s„ q n  |  j | ƒ \ } } | | k r² | d }	 n$ | sÉ | j |	 ƒ rÖ g  | (q n  t	 | | ƒ } q W| S(   sR   
        Return the maximum revision for all files under a given location
        i    t   entriest   /(
   R%   t   walkt   dirnamet   removeR&   R4   R'   t   _get_svn_url_revt
   startswitht   max(
   R   R   t   revisiont   baset   dirst   filest
   entries_fnt   dirurlt   localrevt   base_url(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   get_revisiono   s"    c         C@  sA   t  t |  ƒ j ƒ  \ } } | j d ƒ r7 d | } n  | | f S(   Ns   ssh://s   svn+(   t   superR   R"   RA   (   R   R   R(   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR"   Š   s    c         C@  sw   | } x] t  j j t  j j | d ƒ ƒ se | } t  j j | ƒ } | | k r	 t j d | ƒ d  Sq	 W|  j | ƒ d S(   Ns   setup.pysG   Could not find setup.py for directory %s (tried all parent directories)i    (	   R%   R&   R'   R4   R>   R   R   R   R@   (   R   R   t   orig_locationt   last_location(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   get_url‘   s    $c         C@  sI  d d l  m } t j j | |  j d ƒ } t j j | ƒ ra t | ƒ � } | j ƒ  } Wd  QXn d } | j	 d ƒ s” | j	 d ƒ s” | j	 d ƒ rt
 t t j | j d ƒ ƒ ƒ } | d d =| d d	 } g  | D]2 } t | ƒ d
 k rÕ | d
 rÕ t | d
 ƒ ^ qÕ d g } n| j	 d ƒ r˜t j | ƒ }	 |	 sNt d | ƒ ‚ n  |	 j d ƒ } g  t j | ƒ D] }
 t |
 j d ƒ ƒ ^ qmd g } nŒ yk |  j d d | g d t ƒ} t j | ƒ j d ƒ } g  t j | ƒ D] }
 t |
 j d ƒ ƒ ^ qá} Wn | k
 r#d  g  } } n X| r9t | ƒ } n d } | | f S(   Ni    (   t   InstallationErrorR;   R-   t   8t   9t   10s   

i   i	   s   <?xmls   Badly formatted data: %ri   R   s   --xmlR   (   t   pip.exceptionsRP   R%   R&   R4   R>   R'   t   opent   readRA   t   listt   mapt   strt
   splitlinesR5   t   lent   intt   _svn_xml_url_reR   t
   ValueErrorR   t   _svn_rev_ret   finditerR   R   t   _svn_info_xml_url_ret   _svn_info_xml_rev_reR   RB   (   R   R   RP   t   entries_patht   ft   dataR   t   dt   revsR   t   mt   xmlR(   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR@   ¥   s>    !I;	5c         C@  s[   |  j  | ƒ } | d  k r d  S| j ƒ  j d d ƒ d } |  j | ƒ } d | | | f S(   NR1   i   i    s   svn+%s@%s#egg=%s(   RO   R   t   egg_nameR5   RK   (   R   R8   R   t   repot   egg_project_nameR(   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   get_src_requirementÑ   s    c         C@  s   t  S(   s&   Always assume the versions don't match(   R   (   R   R+   R)   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   check_versionÚ   s    c         C@  sY   t  j |  ƒ } | j j d ƒ d } | j | | j | j | j f } t  j | ƒ } | S(   Nt   @iÿÿÿÿ(	   t   urllib_parset   urlsplitt   netlocR5   t   schemeR&   t   queryt   fragmentt
   urlunsplit(   R   t   purlt   stripped_netloct
   url_piecest   surl(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR$   Þ   s
    !(   R	   s   svn+sshs   svn+https	   svn+httpss   svn+svn(   t   __name__t
   __module__t   nameR>   t	   repo_namet   schemesR    R!   R*   R,   R0   R:   RK   R"   RO   R@   Rm   Rn   t   staticmethodR$   (    (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR      s"   										,			c         C@  sñ   | r d | g } n g  } t  j |  ƒ } t | d ƒ rO | j | j } } nl | d } d | k r¯ | j d ƒ d } d | k rŸ | j d d ƒ \ } } q» | d  } } n d	 \ } } | rÔ | d | g 7} n  | rí | d | g 7} n  | S(
   Ns   -rt   usernamei   Ro   i    t   :s
   --usernames
   --password(   NN(   Rp   Rq   t   hasattrR�   t   passwordR5   R   (   R   R(   R)   t   rR�   R„   Rr   t   auth(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR#   ñ   s$    
(   t
   __future__R    t   loggingR%   t   ret   pip._vendor.six.moves.urllibR   Rp   t	   pip.indexR   t	   pip.utilsR   R   t   pip.utils.loggingR   t   pip.vcsR   R   t   compileR]   R_   R   R   Rb   Ra   t	   getLoggerR{   R   R   R#   t   register(    (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   <module>   s$   Ø	PK     (\Y]y©¦6ž  ž  
  bazaar.pycnu „[µü¤        ó
•�abc           @@  sÚ   d  d l  m Z d  d l Z d  d l Z d  d l Z y d  d l m Z Wn e k
 rg d  d l	 Z n Xd  d l
 m Z m Z d  d l m Z m Z d  d l m Z e j e ƒ Z d e f d „  ƒ  YZ e j e ƒ d S(	   i    (   t   absolute_importN(   t   parse(   t   rmtreet   display_path(   t   vcst   VersionControl(   t   path_to_urlt   Bazaarc           B@  s}   e  Z d  Z d Z d Z d Z d d	 „ Z d
 „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   t   bzrs   .bzrt   branchs   bzr+https	   bzr+httpss   bzr+sshs   bzr+sftps   bzr+ftps   bzr+lpc         O@  s[   t  t |  ƒ j | | | Ž t t d d  ƒ rW t j j d g ƒ t j j d g ƒ n  d  S(   Nt   uses_fragmentt   lp(	   t   superR   t   __init__t   getattrt   urllib_parset   NoneR
   t   extendt   non_hierarchical(   t   selft   urlt   argst   kwargs(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR      s    c         C@  ss   t  j d d ƒ } |  j | ƒ t j j | ƒ r> t | ƒ n  z# |  j d | g d | d t ƒWd t | ƒ Xd S(   sU   
        Export the Bazaar repository at the url to the destination location
        s   -exports   pip-t   exportt   cwdt   show_stdoutN(	   t   tempfilet   mkdtempt   unpackt   ost   patht   existsR   t   run_commandt   False(   R   t   locationt   temp_dir(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR   &   s    c         C@  s   |  j  d | g d | ƒd  S(   Nt   switchR   (   R    (   R   t   destR   t   rev_options(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR$   5   s    c         C@  s!   |  j  d d g | d | ƒd  S(   Nt   pulls   -qR   (   R    (   R   R%   R&   (    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   update8   s    c         C@  s™   |  j  ƒ  \ } } | r1 d | g } d | } n g  } d } |  j | | | | ƒ r• t j d | | t | ƒ ƒ |  j d d g | | | g ƒ n  d  S(   Ns   -rs    (to revision %s)t    s   Checking out %s%s to %sR	   s   -q(   t   get_url_revt   check_destinationt   loggert   infoR   R    (   R   R%   R   t   revR&   t   rev_display(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   obtain;   s    c         C@  sA   t  t |  ƒ j ƒ  \ } } | j d ƒ r7 d | } n  | | f S(   Ns   ssh://s   bzr+(   R   R   R*   t
   startswith(   R   R   R.   (    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR*   L   s    c         C@  s•   |  j  d g d t d | ƒ} xp | j ƒ  D]b } | j ƒ  } xM d D]E } | j | ƒ rD | j | ƒ d } |  j | ƒ r… t | ƒ S| SqD Wq+ Wd  S(   NR-   R   R   s   checkout of branch: s   parent branch: i   (   s   checkout of branch: s   parent branch: (	   R    R!   t
   splitlinest   stripR1   t   splitt   _is_local_repositoryR   R   (   R   R"   t   urlst   linet   xt   repo(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   get_urlS   s    

c         C@  s,   |  j  d g d t d | ƒ} | j ƒ  d S(   Nt   revnoR   R   iÿÿÿÿ(   R    R!   R2   (   R   R"   t   revision(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   get_revision`   s    c         C@  sw   |  j  | ƒ } | s d  S| j ƒ  j d ƒ s; d | } n  | j ƒ  j d d ƒ d } |  j | ƒ } d | | | f S(   Ns   bzr:s   bzr+t   -i   i    s   %s@%s#egg=%s(   R:   R   t   lowerR1   t   egg_nameR4   R=   (   R   t   distR"   R9   t   egg_project_namet   current_rev(    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   get_src_requiremente   s    c         C@  s   t  S(   s&   Always assume the versions don't match(   R!   (   R   R%   R&   (    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   check_versiono   s    (   R   s   bzr+https	   bzr+httpss   bzr+sshs   bzr+sftps   bzr+ftps   bzr+lpN(   t   __name__t
   __module__t   namet   dirnamet	   repo_namet   schemesR   R   R   R$   R(   R0   R*   R:   R=   RD   RE   (    (    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR      s    								
(   t
   __future__R    t   loggingR   R   t   urllibR   R   t   ImportErrort   urlparset	   pip.utilsR   R   t   pip.vcsR   R   t   pip.downloadR   t	   getLoggerRF   R,   R   t   register(    (    (    s2   /usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt   <module>   s   _PK     (\Y]	@‘þ  þ    mercurial.pycnu „[µü¤        ó
•�abc           @@  s¶   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z d  d l m	 Z	 m
 Z
 d  d l m Z d  d l m Z e j e ƒ Z d e
 f d „  ƒ  YZ e	 j e ƒ d S(	   i    (   t   absolute_importN(   t   display_patht   rmtree(   t   vcst   VersionControl(   t   path_to_url(   t   configparsert	   Mercurialc           B@  sq   e  Z d  Z d Z d Z d Z d „  Z d „  Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z RS(   t   hgs   .hgt   clones   hg+https   hg+httpss   hg+sshs   hg+static-httpc         C@  sT   t  j d d ƒ } |  j | ƒ z# |  j d | g d t d | ƒWd t | ƒ Xd S(   s?   Export the Hg repository at the url to the destination locations   -exports   pip-t   archivet   show_stdoutt   cwdN(   t   tempfilet   mkdtempt   unpackt   run_commandt   FalseR   (   t   selft   locationt   temp_dir(    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   export   s    c         C@  sÃ   t  j j | |  j d ƒ } t j ƒ  } yI | j | ƒ | j d d | ƒ t | d ƒ � } | j	 | ƒ Wd  QXWn/ t
 t j f k
 r¡ } t j d | | ƒ n X|  j d d g | d | ƒd  S(	   Nt   hgrct   pathst   defaultt   ws/   Could not switch Mercurial repository to %s: %st   updates   -qR   (   t   ost   patht   joint   dirnameR   t   SafeConfigParsert   readt   sett   opent   writet   OSErrort   NoSectionErrort   loggert   warningR   (   R   t   destt   urlt   rev_optionst   repo_configt   configt   config_filet   exc(    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   switch    s    c         C@  s:   |  j  d d g d | ƒ|  j  d d g | d | ƒd  S(   Nt   pulls   -qR   R   (   R   (   R   R(   R*   (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyR   /   s    c         C@  s®   |  j  ƒ  \ } } | r. | g } d | } n g  } d } |  j | | | | ƒ rª t j d | | t | ƒ ƒ |  j d d d | | g ƒ |  j d d g | d | ƒn  d  S(	   Ns    (to revision %s)t    s   Cloning hg %s%s to %sR	   s
   --noupdates   -qR   R   (   t   get_url_revt   check_destinationR&   t   infoR   R   (   R   R(   R)   t   revR*   t   rev_display(    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   obtain3   s    	c         C@  sO   |  j  d d g d t d | ƒj ƒ  } |  j | ƒ rE t | ƒ } n  | j ƒ  S(   Nt
   showconfigs   paths.defaultR   R   (   R   R   t   stript   _is_local_repositoryR   (   R   R   R)   (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   get_urlE   s    c         C@  s+   |  j  d d g d t d | ƒj ƒ  } | S(   Nt   parentss   --template={rev}R   R   (   R   R   R9   (   R   R   t   current_revision(    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   get_revisionM   s    c         C@  s+   |  j  d d g d t d | ƒj ƒ  } | S(   NR<   s   --template={node}R   R   (   R   R   R9   (   R   R   t   current_rev_hash(    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   get_revision_hashS   s    c         C@  sw   |  j  | ƒ } | j ƒ  j d ƒ s1 d | } n  | j ƒ  j d d ƒ d } | sW d  S|  j | ƒ } d | | | f S(   Ns   hg:s   hg+t   -i   i    s   %s@%s#egg=%s(   R;   t   lowert
   startswitht   egg_namet   splitt   NoneR@   (   R   t   distR   t   repot   egg_project_nameR?   (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   get_src_requirementY   s    c         C@  s   t  S(   s&   Always assume the versions don't match(   R   (   R   R(   R*   (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   check_versionc   s    (   R   s   hg+https   hg+httpss   hg+sshs   hg+static-http(   t   __name__t
   __module__t   nameR   t	   repo_namet   schemesR   R/   R   R7   R;   R>   R@   RJ   RK   (    (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyR      s   	
							
(   t
   __future__R    t   loggingR   R   t	   pip.utilsR   R   t   pip.vcsR   R   t   pip.downloadR   t   pip._vendor.six.movesR   t	   getLoggerRL   R&   R   t   register(    (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   <module>   s   WPK     (\Y]ÈVÅKV0  V0    __init__.pynu „[µü¤        """Handles all VCS (version control) support"""
from __future__ import absolute_import

import errno
import logging
import os
import shutil
import sys

from pip._vendor.six.moves.urllib import parse as urllib_parse

from pip.exceptions import BadCommand
from pip.utils import (display_path, backup_dir, call_subprocess,
                       rmtree, ask_path_exists)


__all__ = ['vcs', 'get_src_requirement']


logger = logging.getLogger(__name__)


class VcsSupport(object):
    _registry = {}
    schemes = ['ssh', 'git', 'hg', 'bzr', 'sftp', 'svn']

    def __init__(self):
        # Register more schemes with urlparse for various version control
        # systems
        urllib_parse.uses_netloc.extend(self.schemes)
        # Python >= 2.7.4, 3.3 doesn't have uses_fragment
        if getattr(urllib_parse, 'uses_fragment', None):
            urllib_parse.uses_fragment.extend(self.schemes)
        super(VcsSupport, self).__init__()

    def __iter__(self):
        return self._registry.__iter__()

    @property
    def backends(self):
        return list(self._registry.values())

    @property
    def dirnames(self):
        return [backend.dirname for backend in self.backends]

    @property
    def all_schemes(self):
        schemes = []
        for backend in self.backends:
            schemes.extend(backend.schemes)
        return schemes

    def register(self, cls):
        if not hasattr(cls, 'name'):
            logger.warning('Cannot register VCS %s', cls.__name__)
            return
        if cls.name not in self._registry:
            self._registry[cls.name] = cls
            logger.debug('Registered VCS backend: %s', cls.name)

    def unregister(self, cls=None, name=None):
        if name in self._registry:
            del self._registry[name]
        elif cls in self._registry.values():
            del self._registry[cls.name]
        else:
            logger.warning('Cannot unregister because no class or name given')

    def get_backend_name(self, location):
        """
        Return the name of the version control backend if found at given
        location, e.g. vcs.get_backend_name('/path/to/vcs/checkout')
        """
        for vc_type in self._registry.values():
            if vc_type.controls_location(location):
                logger.debug('Determine that %s uses VCS: %s',
                             location, vc_type.name)
                return vc_type.name
        return None

    def get_backend(self, name):
        name = name.lower()
        if name in self._registry:
            return self._registry[name]

    def get_backend_from_location(self, location):
        vc_type = self.get_backend_name(location)
        if vc_type:
            return self.get_backend(vc_type)
        return None


vcs = VcsSupport()


class VersionControl(object):
    name = ''
    dirname = ''
    # List of supported schemes for this Version Control
    schemes = ()

    def __init__(self, url=None, *args, **kwargs):
        self.url = url
        super(VersionControl, self).__init__(*args, **kwargs)

    def _is_local_repository(self, repo):
        """
           posix absolute paths start with os.path.sep,
           win32 ones start with drive (like c:\\folder)
        """
        drive, tail = os.path.splitdrive(repo)
        return repo.startswith(os.path.sep) or drive

    # See issue #1083 for why this method was introduced:
    # https://github.com/pypa/pip/issues/1083
    def translate_egg_surname(self, surname):
        # For example, Django has branches of the form "stable/1.7.x".
        return surname.replace('/', '_')

    def export(self, location):
        """
        Export the repository at the url to the destination location
        i.e. only download the files, without vcs informations
        """
        raise NotImplementedError

    def get_url_rev(self):
        """
        Returns the correct repository URL and revision by parsing the given
        repository URL
        """
        error_message = (
            "Sorry, '%s' is a malformed VCS url. "
            "The format is <vcs>+<protocol>://<url>, "
            "e.g. svn+http://myrepo/svn/MyApp#egg=MyApp"
        )
        assert '+' in self.url, error_message % self.url
        url = self.url.split('+', 1)[1]
        scheme, netloc, path, query, frag = urllib_parse.urlsplit(url)
        rev = None
        if '@' in path:
            path, rev = path.rsplit('@', 1)
        url = urllib_parse.urlunsplit((scheme, netloc, path, query, ''))
        return url, rev

    def get_info(self, location):
        """
        Returns (url, revision), where both are strings
        """
        assert not location.rstrip('/').endswith(self.dirname), \
            'Bad directory: %s' % location
        return self.get_url(location), self.get_revision(location)

    def normalize_url(self, url):
        """
        Normalize a URL for comparison by unquoting it and removing any
        trailing slash.
        """
        return urllib_parse.unquote(url).rstrip('/')

    def compare_urls(self, url1, url2):
        """
        Compare two repo URLs for identity, ignoring incidental differences.
        """
        return (self.normalize_url(url1) == self.normalize_url(url2))

    def obtain(self, dest):
        """
        Called when installing or updating an editable package, takes the
        source path of the checkout.
        """
        raise NotImplementedError

    def switch(self, dest, url, rev_options):
        """
        Switch the repo at ``dest`` to point to ``URL``.
        """
        raise NotImplementedError

    def update(self, dest, rev_options):
        """
        Update an already-existing repo to the given ``rev_options``.
        """
        raise NotImplementedError

    def check_version(self, dest, rev_options):
        """
        Return True if the version is identical to what exists and
        doesn't need to be updated.
        """
        raise NotImplementedError

    def check_destination(self, dest, url, rev_options, rev_display):
        """
        Prepare a location to receive a checkout/clone.

        Return True if the location is ready for (and requires) a
        checkout/clone, False otherwise.
        """
        checkout = True
        prompt = False
        if os.path.exists(dest):
            checkout = False
            if os.path.exists(os.path.join(dest, self.dirname)):
                existing_url = self.get_url(dest)
                if self.compare_urls(existing_url, url):
                    logger.debug(
                        '%s in %s exists, and has correct URL (%s)',
                        self.repo_name.title(),
                        display_path(dest),
                        url,
                    )
                    if not self.check_version(dest, rev_options):
                        logger.info(
                            'Updating %s %s%s',
                            display_path(dest),
                            self.repo_name,
                            rev_display,
                        )
                        self.update(dest, rev_options)
                    else:
                        logger.info(
                            'Skipping because already up-to-date.')
                else:
                    logger.warning(
                        '%s %s in %s exists with URL %s',
                        self.name,
                        self.repo_name,
                        display_path(dest),
                        existing_url,
                    )
                    prompt = ('(s)witch, (i)gnore, (w)ipe, (b)ackup ',
                              ('s', 'i', 'w', 'b'))
            else:
                logger.warning(
                    'Directory %s already exists, and is not a %s %s.',
                    dest,
                    self.name,
                    self.repo_name,
                )
                prompt = ('(i)gnore, (w)ipe, (b)ackup ', ('i', 'w', 'b'))
        if prompt:
            logger.warning(
                'The plan is to install the %s repository %s',
                self.name,
                url,
            )
            response = ask_path_exists('What to do?  %s' % prompt[0],
                                       prompt[1])

            if response == 's':
                logger.info(
                    'Switching %s %s to %s%s',
                    self.repo_name,
                    display_path(dest),
                    url,
                    rev_display,
                )
                self.switch(dest, url, rev_options)
            elif response == 'i':
                # do nothing
                pass
            elif response == 'w':
                logger.warning('Deleting %s', display_path(dest))
                rmtree(dest)
                checkout = True
            elif response == 'b':
                dest_dir = backup_dir(dest)
                logger.warning(
                    'Backing up %s to %s', display_path(dest), dest_dir,
                )
                shutil.move(dest, dest_dir)
                checkout = True
            elif response == 'a':
                sys.exit(-1)
        return checkout

    def unpack(self, location):
        """
        Clean up current location and download the url repository
        (and vcs infos) into location
        """
        if os.path.exists(location):
            rmtree(location)
        self.obtain(location)

    def get_src_requirement(self, dist, location):
        """
        Return a string representing the requirement needed to
        redownload the files currently present in location, something
        like:
          {repository_url}@{revision}#egg={project_name}-{version_identifier}
        """
        raise NotImplementedError

    def get_url(self, location):
        """
        Return the url used at location
        Used in get_info or check_destination
        """
        raise NotImplementedError

    def get_revision(self, location):
        """
        Return the current revision of the files at location
        Used in get_info
        """
        raise NotImplementedError

    def run_command(self, cmd, show_stdout=True, cwd=None,
                    on_returncode='raise',
                    command_desc=None,
                    extra_environ=None, spinner=None):
        """
        Run a VCS subcommand
        This is simply a wrapper around call_subprocess that adds the VCS
        command name, and checks that the VCS is available
        """
        cmd = [self.name] + cmd
        try:
            return call_subprocess(cmd, show_stdout, cwd,
                                   on_returncode,
                                   command_desc, extra_environ,
                                   spinner)
        except OSError as e:
            # errno.ENOENT = no such file or directory
            # In other words, the VCS executable isn't available
            if e.errno == errno.ENOENT:
                raise BadCommand('Cannot find command %r' % self.name)
            else:
                raise  # re-raise exception if a different error occurred

    @classmethod
    def controls_location(cls, location):
        """
        Check if a location is controlled by the vcs.
        It is meant to be overridden to implement smarter detection
        mechanisms for specific vcs.
        """
        logger.debug('Checking in %s for %s (%s)...',
                     location, cls.dirname, cls.name)
        path = os.path.join(location, cls.dirname)
        return os.path.exists(path)


def get_src_requirement(dist, location):
    version_control = vcs.get_backend_from_location(location)
    if version_control:
        try:
            return version_control().get_src_requirement(dist,
                                                         location)
        except BadCommand:
            logger.warning(
                'cannot determine version of editable source in %s '
                '(%s command not found in path)',
                location,
                version_control.name,
            )
            return dist.as_requirement()
    logger.warning(
        'cannot determine version of editable source in %s (is not SVN '
        'checkout, Git clone, Mercurial clone or Bazaar branch)',
        location,
    )
    return dist.as_requirement()
PK     (\Y]H`½¤Õ!  Õ!    subversion.pycnu „[µü¤        ó
•�abc           @@  s)  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 d  d l
 m Z m Z d  d l m Z d  d l m Z m Z e j d ƒ Z e j d	 ƒ Z e j d
 ƒ Z e j d ƒ Z e j d ƒ Z e j d ƒ Z e j e ƒ Z d e f d „  ƒ  YZ d „  Z e j e ƒ d S(   i    (   t   absolute_importN(   t   parse(   t   Link(   t   rmtreet   display_path(   t
   indent_log(   t   vcst   VersionControls   url="([^"]+)"s   committed-rev="(\d+)"s	   URL: (.+)s   Revision: (.+)s   \s*revision="(\d+)"s   <url>(.*)</url>t
   Subversionc           B@  s›   e  Z d  Z d Z d Z d Z d „  Z d „  Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z RS(   t   svns   .svnt   checkouts   svn+sshs   svn+https	   svn+httpss   svn+svnc         C@  s   | j  d ƒ j |  j ƒ s, t d | ƒ ‚ |  j d | g d t d i d d 6ƒ} t j | ƒ } | s“ t j	 d t
 | ƒ ƒ t j d	 | ƒ d S| j d
 ƒ j ƒ  } t j | ƒ } | sí t j	 d t
 | ƒ ƒ t j d	 | ƒ | d f S| | j d
 ƒ f S(   s/   Returns (url, revision), where both are stringst   /s   Bad directory: %st   infot   show_stdoutt   extra_environt   Ct   LANGs'   Cannot determine URL of svn checkout %ss!   Output that cannot be parsed: 
%si   s,   Cannot determine revision of svn checkout %sN(   NN(   t   rstript   endswitht   dirnamet   AssertionErrort   run_commandt   Falset   _svn_url_ret   searcht   loggert   warningR   t   debugt   Nonet   groupt   stript   _svn_revision_re(   t   selft   locationt   outputt   matcht   url(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   get_info   s,    
c         C@  sš   |  j  ƒ  \ } } t | | ƒ } |  j | ƒ } t j d | | ƒ t ƒ  �H t j j | ƒ rl t	 | ƒ n  |  j
 d g | | | g d t ƒWd QXd S(   s@   Export the svn repository at the url to the destination locations!   Exporting svn repository %s to %st   exportR   N(   t   get_url_revt   get_rev_optionst   remove_auth_from_urlR   R   R   t   ost   patht   existsR   R   R   (   R    R!   R$   t   revt   rev_options(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR&   ;   s    
c         C@  s"   |  j  d g | | | g ƒ d  S(   Nt   switch(   R   (   R    t   destR$   R.   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR/   J   s    c         C@  s   |  j  d g | | g ƒ d  S(   Nt   update(   R   (   R    R0   R.   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR1   M   s    c         C@  s¥   |  j  ƒ  \ } } t | | ƒ } |  j | ƒ } | rC d | } n d } |  j | | | | ƒ r¡ t j d | | t | ƒ ƒ |  j d d g | | | g ƒ n  d  S(   Ns    (to revision %s)t    s   Checking out %s%s to %sR
   s   -q(   R'   R(   R)   t   check_destinationR   R   R   R   (   R    R0   R$   R-   R.   t   rev_display(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   obtainP   s    c         C@  sŠ   xƒ | D]{ } t  | ƒ j } | s( q n  d | k rY d j | j d ƒ d  ƒ j ƒ  } n | } | | j k r | j d d ƒ d Sq Wd  S(   Nt   -iÿÿÿÿt   #i   i    (   R   t   egg_fragmentt   joint   splitt   lowert   keyR   (   R    t   distt   dependency_linksR$   R8   R<   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   get_locationa   s    %c   
      C@  sí   d } xà t  j | ƒ D]Ï \ } } } |  j | k rA g  | (q n  | j |  j ƒ t  j j | |  j d ƒ } t  j j | ƒ s„ q n  |  j | ƒ \ } } | | k r² | d }	 n$ | sÉ | j |	 ƒ rÖ g  | (q n  t	 | | ƒ } q W| S(   sR   
        Return the maximum revision for all files under a given location
        i    t   entriesR   (
   R*   t   walkR   t   removeR+   R9   R,   t   _get_svn_url_revt
   startswitht   max(
   R    R!   t   revisiont   baset   dirst   filest
   entries_fnt   dirurlt   localrevt   base_url(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   get_revisiono   s"    c         C@  sA   t  t |  ƒ j ƒ  \ } } | j d ƒ r7 d | } n  | | f S(   Ns   ssh://s   svn+(   t   superR   R'   RD   (   R    R$   R-   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR'   Š   s    c         C@  sw   | } x] t  j j t  j j | d ƒ ƒ se | } t  j j | ƒ } | | k r	 t j d | ƒ d  Sq	 W|  j | ƒ d S(   Ns   setup.pysG   Could not find setup.py for directory %s (tried all parent directories)i    (	   R*   R+   R,   R9   R   R   R   R   RC   (   R    R!   t   orig_locationt   last_location(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   get_url‘   s    $c         C@  sI  d d l  m } t j j | |  j d ƒ } t j j | ƒ ra t | ƒ � } | j ƒ  } Wd  QXn d } | j	 d ƒ s” | j	 d ƒ s” | j	 d ƒ rt
 t t j | j d ƒ ƒ ƒ } | d d =| d d	 } g  | D]2 } t | ƒ d
 k rÕ | d
 rÕ t | d
 ƒ ^ qÕ d g } n| j	 d ƒ r˜t j | ƒ }	 |	 sNt d | ƒ ‚ n  |	 j d ƒ } g  t j | ƒ D] }
 t |
 j d ƒ ƒ ^ qmd g } nŒ yk |  j d d | g d t ƒ} t j | ƒ j d ƒ } g  t j | ƒ D] }
 t |
 j d ƒ ƒ ^ qá} Wn | k
 r#d  g  } } n X| r9t | ƒ } n d } | | f S(   Ni    (   t   InstallationErrorR@   R2   t   8t   9t   10s   

i   i	   s   <?xmls   Badly formatted data: %ri   R   s   --xmlR   (   t   pip.exceptionsRS   R*   R+   R9   R   R,   t   opent   readRD   t   listt   mapt   strt
   splitlinesR:   t   lent   intt   _svn_xml_url_reR   t
   ValueErrorR   t   _svn_rev_ret   finditerR   R   t   _svn_info_xml_url_ret   _svn_info_xml_rev_reR   RE   (   R    R!   RS   t   entries_patht   ft   dataR$   t   dt   revsR#   t   mt   xmlR-   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyRC   ¥   s>    !I;	5c         C@  s[   |  j  | ƒ } | d  k r d  S| j ƒ  j d d ƒ d } |  j | ƒ } d | | | f S(   NR6   i   i    s   svn+%s@%s#egg=%s(   RR   R   t   egg_nameR:   RN   (   R    R=   R!   t   repot   egg_project_nameR-   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   get_src_requirementÑ   s    c         C@  s   t  S(   s&   Always assume the versions don't match(   R   (   R    R0   R.   (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   check_versionÚ   s    c         C@  sY   t  j |  ƒ } | j j d ƒ d } | j | | j | j | j f } t  j | ƒ } | S(   Nt   @iÿÿÿÿ(	   t   urllib_parset   urlsplitt   netlocR:   t   schemeR+   t   queryt   fragmentt
   urlunsplit(   R$   t   purlt   stripped_netloct
   url_piecest   surl(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR)   Þ   s
    !(   R	   s   svn+sshs   svn+https	   svn+httpss   svn+svn(   t   __name__t
   __module__t   nameR   t	   repo_namet   schemesR%   R&   R/   R1   R5   R?   RN   R'   RR   RC   Rp   Rq   t   staticmethodR)   (    (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR      s"   										,			c         C@  sñ   | r d | g } n g  } t  j |  ƒ } t | d ƒ rO | j | j } } nl | d } d | k r¯ | j d ƒ d } d | k rŸ | j d d ƒ \ } } q» | d  } } n d	 \ } } | rÔ | d | g 7} n  | rí | d | g 7} n  | S(
   Ns   -rt   usernamei   Rr   i    t   :s
   --usernames
   --password(   NN(   Rs   Rt   t   hasattrR„   t   passwordR:   R   (   R$   R-   R.   t   rR„   R‡   Ru   t   auth(    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR(   ñ   s$    
(   t
   __future__R    t   loggingR*   t   ret   pip._vendor.six.moves.urllibR   Rs   t	   pip.indexR   t	   pip.utilsR   R   t   pip.utils.loggingR   t   pip.vcsR   R   t   compileR`   Rb   R   R   Re   Rd   t	   getLoggerR~   R   R   R(   t   register(    (    (    s6   /usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt   <module>   s$   Ø	PK     (\Y]ûÀÌÅÛ  Û  	  bazaar.pynu „[µü¤        from __future__ import absolute_import

import logging
import os
import tempfile

# TODO: Get this into six.moves.urllib.parse
try:
    from urllib import parse as urllib_parse
except ImportError:
    import urlparse as urllib_parse

from pip.utils import rmtree, display_path
from pip.vcs import vcs, VersionControl
from pip.download import path_to_url


logger = logging.getLogger(__name__)


class Bazaar(VersionControl):
    name = 'bzr'
    dirname = '.bzr'
    repo_name = 'branch'
    schemes = (
        'bzr', 'bzr+http', 'bzr+https', 'bzr+ssh', 'bzr+sftp', 'bzr+ftp',
        'bzr+lp',
    )

    def __init__(self, url=None, *args, **kwargs):
        super(Bazaar, self).__init__(url, *args, **kwargs)
        # Python >= 2.7.4, 3.3 doesn't have uses_fragment or non_hierarchical
        # Register lp but do not expose as a scheme to support bzr+lp.
        if getattr(urllib_parse, 'uses_fragment', None):
            urllib_parse.uses_fragment.extend(['lp'])
            urllib_parse.non_hierarchical.extend(['lp'])

    def export(self, location):
        """
        Export the Bazaar repository at the url to the destination location
        """
        temp_dir = tempfile.mkdtemp('-export', 'pip-')
        self.unpack(temp_dir)
        if os.path.exists(location):
            # Remove the location to make sure Bazaar can export it correctly
            rmtree(location)
        try:
            self.run_command(['export', location], cwd=temp_dir,
                             show_stdout=False)
        finally:
            rmtree(temp_dir)

    def switch(self, dest, url, rev_options):
        self.run_command(['switch', url], cwd=dest)

    def update(self, dest, rev_options):
        self.run_command(['pull', '-q'] + rev_options, cwd=dest)

    def obtain(self, dest):
        url, rev = self.get_url_rev()
        if rev:
            rev_options = ['-r', rev]
            rev_display = ' (to revision %s)' % rev
        else:
            rev_options = []
            rev_display = ''
        if self.check_destination(dest, url, rev_options, rev_display):
            logger.info(
                'Checking out %s%s to %s',
                url,
                rev_display,
                display_path(dest),
            )
            self.run_command(['branch', '-q'] + rev_options + [url, dest])

    def get_url_rev(self):
        # hotfix the URL scheme after removing bzr+ from bzr+ssh:// readd it
        url, rev = super(Bazaar, self).get_url_rev()
        if url.startswith('ssh://'):
            url = 'bzr+' + url
        return url, rev

    def get_url(self, location):
        urls = self.run_command(['info'], show_stdout=False, cwd=location)
        for line in urls.splitlines():
            line = line.strip()
            for x in ('checkout of branch: ',
                      'parent branch: '):
                if line.startswith(x):
                    repo = line.split(x)[1]
                    if self._is_local_repository(repo):
                        return path_to_url(repo)
                    return repo
        return None

    def get_revision(self, location):
        revision = self.run_command(
            ['revno'], show_stdout=False, cwd=location)
        return revision.splitlines()[-1]

    def get_src_requirement(self, dist, location):
        repo = self.get_url(location)
        if not repo:
            return None
        if not repo.lower().startswith('bzr:'):
            repo = 'bzr+' + repo
        egg_project_name = dist.egg_name().split('-', 1)[0]
        current_rev = self.get_revision(location)
        return '%s@%s#egg=%s' % (repo, current_rev, egg_project_name)

    def check_version(self, dest, rev_options):
        """Always assume the versions don't match"""
        return False


vcs.register(Bazaar)
PK     (\Y]	@‘þ  þ    mercurial.pyonu „[µü¤        ó
•�abc           @@  s¶   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z d  d l m	 Z	 m
 Z
 d  d l m Z d  d l m Z e j e ƒ Z d e
 f d „  ƒ  YZ e	 j e ƒ d S(	   i    (   t   absolute_importN(   t   display_patht   rmtree(   t   vcst   VersionControl(   t   path_to_url(   t   configparsert	   Mercurialc           B@  sq   e  Z d  Z d Z d Z d Z d „  Z d „  Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z RS(   t   hgs   .hgt   clones   hg+https   hg+httpss   hg+sshs   hg+static-httpc         C@  sT   t  j d d ƒ } |  j | ƒ z# |  j d | g d t d | ƒWd t | ƒ Xd S(   s?   Export the Hg repository at the url to the destination locations   -exports   pip-t   archivet   show_stdoutt   cwdN(   t   tempfilet   mkdtempt   unpackt   run_commandt   FalseR   (   t   selft   locationt   temp_dir(    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   export   s    c         C@  sÃ   t  j j | |  j d ƒ } t j ƒ  } yI | j | ƒ | j d d | ƒ t | d ƒ � } | j	 | ƒ Wd  QXWn/ t
 t j f k
 r¡ } t j d | | ƒ n X|  j d d g | d | ƒd  S(	   Nt   hgrct   pathst   defaultt   ws/   Could not switch Mercurial repository to %s: %st   updates   -qR   (   t   ost   patht   joint   dirnameR   t   SafeConfigParsert   readt   sett   opent   writet   OSErrort   NoSectionErrort   loggert   warningR   (   R   t   destt   urlt   rev_optionst   repo_configt   configt   config_filet   exc(    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   switch    s    c         C@  s:   |  j  d d g d | ƒ|  j  d d g | d | ƒd  S(   Nt   pulls   -qR   R   (   R   (   R   R(   R*   (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyR   /   s    c         C@  s®   |  j  ƒ  \ } } | r. | g } d | } n g  } d } |  j | | | | ƒ rª t j d | | t | ƒ ƒ |  j d d d | | g ƒ |  j d d g | d | ƒn  d  S(	   Ns    (to revision %s)t    s   Cloning hg %s%s to %sR	   s
   --noupdates   -qR   R   (   t   get_url_revt   check_destinationR&   t   infoR   R   (   R   R(   R)   t   revR*   t   rev_display(    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   obtain3   s    	c         C@  sO   |  j  d d g d t d | ƒj ƒ  } |  j | ƒ rE t | ƒ } n  | j ƒ  S(   Nt
   showconfigs   paths.defaultR   R   (   R   R   t   stript   _is_local_repositoryR   (   R   R   R)   (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   get_urlE   s    c         C@  s+   |  j  d d g d t d | ƒj ƒ  } | S(   Nt   parentss   --template={rev}R   R   (   R   R   R9   (   R   R   t   current_revision(    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   get_revisionM   s    c         C@  s+   |  j  d d g d t d | ƒj ƒ  } | S(   NR<   s   --template={node}R   R   (   R   R   R9   (   R   R   t   current_rev_hash(    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   get_revision_hashS   s    c         C@  sw   |  j  | ƒ } | j ƒ  j d ƒ s1 d | } n  | j ƒ  j d d ƒ d } | sW d  S|  j | ƒ } d | | | f S(   Ns   hg:s   hg+t   -i   i    s   %s@%s#egg=%s(   R;   t   lowert
   startswitht   egg_namet   splitt   NoneR@   (   R   t   distR   t   repot   egg_project_nameR?   (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   get_src_requirementY   s    c         C@  s   t  S(   s&   Always assume the versions don't match(   R   (   R   R(   R*   (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   check_versionc   s    (   R   s   hg+https   hg+httpss   hg+sshs   hg+static-http(   t   __name__t
   __module__t   nameR   t	   repo_namet   schemesR   R/   R   R7   R;   R>   R@   RJ   RK   (    (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyR      s   	
							
(   t
   __future__R    t   loggingR   R   t	   pip.utilsR   R   t   pip.vcsR   R   t   pip.downloadR   t   pip._vendor.six.movesR   t	   getLoggerRL   R&   R   t   register(    (    (    s5   /usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt   <module>   s   WPK     (\Y]ì¢Šû+  +    git.pycnu „[µü¤        ó
•�abc           @@  sø   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 d  d l
 m Z d  d l
 m Z d  d l m Z d  d l m Z m Z d  d l m Z m Z e j Z e j Z e j e ƒ Z d	 e f d
 „  ƒ  YZ e j e ƒ d S(   i    (   t   absolute_importN(   t   samefile(   t
   BadCommand(   t   parse(   t   request(   t   display_patht   rmtree(   t   vcst   VersionControlt   Gitc           B@  sï   e  Z d  Z d Z d Z d Z d d „ Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z RS(    t   gits   .gitt   clones   git+https	   git+httpss   git+sshs   git+gits   git+filec         O@  sí   | rÍ t  | ƒ \ } } } } } | j d ƒ rÍ | t | j d ƒ ƒ  }	 |	 t j | ƒ j d d ƒ j d ƒ }
 t | | |
 | | f ƒ } | j d ƒ d } | |  t | | | |
 | | f ƒ } qÍ n  t	 t
 |  ƒ j | | | Ž d  S(   Nt   filet   /s   \t   +i   (   t   urlsplitt   endswitht   lent   lstript   urllib_requestt   url2pathnamet   replacet
   urlunsplitt   findt   superR	   t   __init__(   t   selft   urlt   argst   kwargst   schemet   netloct   patht   queryt   fragmentt   initial_slashest   newpatht
   after_plus(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyR       s    
#c         C@  sl   d } |  j  d g d t ƒ} | j | ƒ r@ | t | ƒ } n d } d j | j d ƒ d  ƒ } t | ƒ S(   Ns   git version t   versiont   show_stdoutt    t   .i   (   t   run_commandt   Falset
   startswithR   t   joint   splitt   parse_version(   R   t   VERSION_PFXR&   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   get_git_version5   s    c         C@  sy   t  j d d ƒ } |  j | ƒ zH | j d ƒ s> | d } n  |  j d d d d | g d t d	 | ƒWd
 t | ƒ Xd
 S(   s@   Export the Git repository at the url to the destination locations   -exports   pip-R   s   checkout-indexs   -as   -fs   --prefixR'   t   cwdN(   t   tempfilet   mkdtempt   unpackR   R*   R+   R   (   R   t   locationt   temp_dir(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   exportB   s    c         C@  s_   |  j  | ƒ } d | } | | k r0 | | g S| | k rG | | g St j d | ƒ | Sd S(   s¶   Check the revision options before checkout to compensate that tags
        and branches may need origin/ as a prefix.
        Returns the SHA1 of the branch or tag if found.
        s	   origin/%ss5   Could not find a tag or branch '%s', assuming commit.N(   t   get_short_refst   loggert   warning(   R   t   revt   destt   rev_optionst	   revisionst
   origin_rev(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   check_rev_optionsO   s    

c         C@  s   |  j  | ƒ j | d ƒ S(   s
  
        Compare the current sha to the ref. ref may be a branch or tag name,
        but current rev will always point to a sha. This means that a branch
        or tag will never compare as True. So this ultimately only matches
        against exact shas.
        i    (   t   get_revisionR,   (   R   R=   R>   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   check_versionc   s    c         C@  sJ   |  j  d d | g d | ƒ|  j  d d g | d | ƒ|  j | ƒ d  S(   Nt   configs   remote.origin.urlR2   t   checkouts   -q(   R*   t   update_submodules(   R   R=   R   R>   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   switchl   s    c         C@  s£   |  j  ƒ  t d ƒ k r7 |  j d d d g d | ƒn |  j d d g d | ƒ| rr |  j | d | | ƒ } n  |  j d d d g | d | ƒ|  j | ƒ d  S(	   Ns   1.9.0t   fetchs   -qs   --tagsR2   i    t   resets   --hard(   R1   R/   R*   RA   RF   (   R   R=   R>   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   updater   s     c         C@  sî   |  j  ƒ  \ } } | r. | g } d | } n d g } d } |  j | | | | ƒ rê t j d | | t | ƒ ƒ |  j d d | | g ƒ | rÚ |  j | | | ƒ } |  j | | ƒ sÚ |  j d d g | d | ƒqÚ n  |  j | ƒ n  d  S(	   Ns    (to %s)s   origin/masterR(   s   Cloning %s%s to %sR   s   -qRE   R2   (	   t   get_url_revt   check_destinationR:   t   infoR   R*   RA   RC   RF   (   R   R=   R   R<   R>   t   rev_display(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   obtain‚   s"    		c         C@  s�   |  j  d d d g d t d | ƒ} | j ƒ  } | d } x' | D] } | j d ƒ rA | } PqA qA W| j d ƒ d	 } | j ƒ  S(
   s+   Return URL of the first remote encountered.RD   s   --get-regexps   remote\..*\.urlR'   R2   i    s   remote.origin.url t    i   (   R*   R+   t
   splitlinesR,   R.   t   strip(   R   R6   t   remotest   found_remotet   remoteR   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   get_url›   s    
c         C@  s+   |  j  d d g d t d | ƒ} | j ƒ  S(   Ns	   rev-parset   HEADR'   R2   (   R*   R+   RR   (   R   R6   t   current_rev(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyRB   ©   s    c         c@  sn   |  j  d g d t d | ƒ} xI | j ƒ  j ƒ  D]5 } | j d d ƒ \ } } | j ƒ  | j ƒ  f Vq1 Wd S(   s4   Yields tuples of (commit, ref) for branches and tagss   show-refR'   R2   RP   i   N(   R*   R+   RR   RQ   R.   (   R   R6   t   outputt   linet   committ   ref(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   get_full_refs®   s
    c         C@  s   | j  d ƒ S(   Ns   refs/remotes/(   R,   (   R   R\   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   is_ref_remote¶   s    c         C@  s   | j  d ƒ S(   Ns   refs/heads/(   R,   (   R   R\   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   is_ref_branch¹   s    c         C@  s   | j  d ƒ S(   Ns
   refs/tags/(   R,   (   R   R\   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt
   is_ref_tag¼   s    c         C@  s/   t  |  j | ƒ |  j | ƒ |  j | ƒ f ƒ S(   s0   A ref is a commit sha if it is not anything else(   t   anyR^   R_   R`   (   R   R\   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   is_ref_commit¿   s    c         C@  s   |  j  | ƒ S(   N(   R9   (   R   R6   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   get_refsÈ   s    c         C@  s¯   i  } x¢ |  j  | ƒ D]‘ \ } } d } |  j | ƒ rJ | t d ƒ } nD |  j | ƒ rl | t d ƒ } n" |  j | ƒ rŽ | t d ƒ } n  | d k	 r | | | <q q W| S(   s=   Return map of named refs (branches or tags) to commit hashes.s   refs/remotes/s   refs/heads/s
   refs/tags/N(   R]   t   NoneR^   R   R_   R`   (   R   R6   t   rvR[   R\   t   ref_name(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyR9   Ë   s    c         C@  sò   |  j  d d g d t d | ƒj ƒ  } t j j | ƒ sQ t j j | | ƒ } n  t j j | d ƒ } | } x] t j j t j j | d ƒ ƒ sË | } t j j | ƒ } | | k ro t	 j
 d | ƒ d Sqo Wt | | ƒ rß d St j j | | ƒ S(	   s:   Return the relative path of setup.py to the git repo root.s	   rev-parses	   --git-dirR'   R2   s   ..s   setup.pysG   Could not find setup.py for directory %s (tried all parent directories)N(   R*   R+   RR   t   osR    t   isabsR-   t   existst   dirnameR:   R;   Rd   R   t   relpath(   R   R6   t   git_dirt   root_dirt   orig_locationt   last_location(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   _get_subdirectoryÚ   s"    $c         C@  s£   |  j  | ƒ } | j ƒ  j d ƒ s1 d | } n  | j ƒ  j d d ƒ d } | sW d  S|  j | ƒ } d | | | f } |  j | ƒ } | rŸ | d | 7} n  | S(   Ns   git:s   git+t   -i   i    s   %s@%s#egg=%ss   &subdirectory=(   RV   t   lowerR,   t   egg_nameR.   Rd   RB   Rp   (   R   t   distR6   t   repot   egg_project_nameRX   t   reqt   subdirectory(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   get_src_requirementõ   s    c         C@  s‘   d |  j  k rl d |  j  k s$ t ‚ |  j  j d d ƒ |  _  t t |  ƒ j ƒ  \ } } | j d d ƒ } n t t |  ƒ j ƒ  \ } } | | f S(   s;  
        Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'.
        That's required because although they use SSH they sometimes doesn't
        work with a ssh:// scheme (e.g. Github). But we need a scheme for
        parsing. Hence we remove it again afterwards and return it as a stub.
        s   ://s   file:s   git+s
   git+ssh://s   ssh://R(   (   R   t   AssertionErrorR   R   R	   RK   (   R   R   R<   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyRK     s    c         C@  sK   t  j j t  j j | d ƒ ƒ s% d  S|  j d d d d d g d | ƒd  S(   Ns   .gitmodulest	   submoduleRJ   s   --inits   --recursives   -qR2   (   Rg   R    Ri   R-   R*   (   R   R6   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyRF     s
    !c         C@  su   t  t |  ƒ j | ƒ r t Sy0 |  ƒ  j d g d | d t d d ƒ} | SWn" t k
 rp t j d | ƒ t SXd  S(   Ns	   rev-parseR2   R'   t   on_returncodet   ignoresK   could not determine if %s is under git control because git is not available(	   R   R	   t   controls_locationt   TrueR*   R+   R   R:   t   debug(   t   clsR6   t   r(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyR~     s    			(   R
   s   git+https	   git+httpss   git+sshs   git+gits   git+fileN(   t   __name__t
   __module__t   nameRj   t	   repo_namet   schemesRd   R   R1   R8   RA   RC   RG   RJ   RO   RV   RB   R]   R^   R_   R`   Rb   Rc   R9   Rp   Ry   RK   RF   t   classmethodR~   (    (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyR	      s4   																						(   t
   __future__R    t   loggingR3   t   os.pathRg   t
   pip.compatR   t   pip.exceptionsR   t   pip._vendor.six.moves.urllibR   t   urllib_parseR   R   t   pip._vendor.packaging.versionR/   t	   pip.utilsR   R   t   pip.vcsR   R   R   R   t	   getLoggerRƒ   R:   R	   t   register(    (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   <module>   s    		ÿ PK     (\Y]3Á3E3  3    __init__.pyonu „[µü¤        ó
•�abc           @@  s÷   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m	 Z
 d d l m Z d d l m Z m Z m Z m Z m Z d d g Z e j e ƒ Z d	 e f d
 „  ƒ  YZ e ƒ  Z d e f d „  ƒ  YZ d „  Z d S(   s)   Handles all VCS (version control) supporti    (   t   absolute_importN(   t   parse(   t
   BadCommand(   t   display_patht
   backup_dirt   call_subprocesst   rmtreet   ask_path_existst   vcst   get_src_requirementt
   VcsSupportc           B@  s˜   e  Z i  Z d  d d d d d g Z d „  Z d „  Z e d „  ƒ Z e d	 „  ƒ Z e d
 „  ƒ Z	 d „  Z
 d d d „ Z d „  Z d „  Z d „  Z RS(   t   ssht   gitt   hgt   bzrt   sftpt   svnc         C@  sR   t  j j |  j ƒ t t  d d  ƒ r; t  j j |  j ƒ n  t t |  ƒ j	 ƒ  d  S(   Nt   uses_fragment(
   t   urllib_parset   uses_netloct   extendt   schemest   getattrt   NoneR   t   superR
   t   __init__(   t   self(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR      s    c         C@  s   |  j  j ƒ  S(   N(   t	   _registryt   __iter__(   R   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR   $   s    c         C@  s   t  |  j j ƒ  ƒ S(   N(   t   listR   t   values(   R   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   backends'   s    c         C@  s   g  |  j  D] } | j ^ q
 S(   N(   R   t   dirname(   R   t   backend(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   dirnames+   s    c         C@  s.   g  } x! |  j  D] } | j | j ƒ q W| S(   N(   R   R   R   (   R   R   R!   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   all_schemes/   s    c         C@  sb   t  | d ƒ s& t j d | j ƒ d  S| j |  j k r^ | |  j | j <t j d | j ƒ n  d  S(   Nt   names   Cannot register VCS %ss   Registered VCS backend: %s(   t   hasattrt   loggert   warningt   __name__R$   R   t   debug(   R   t   cls(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   register6   s    c         C@  sR   | |  j  k r |  j  | =n2 | |  j  j ƒ  k rA |  j  | j =n t j d ƒ d  S(   Ns0   Cannot unregister because no class or name given(   R   R   R$   R&   R'   (   R   R*   R$   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt
   unregister>   s
    c         C@  sJ   xC |  j  j ƒ  D]2 } | j | ƒ r t j d | | j ƒ | j Sq Wd S(   s—   
        Return the name of the version control backend if found at given
        location, e.g. vcs.get_backend_name('/path/to/vcs/checkout')
        s   Determine that %s uses VCS: %sN(   R   R   t   controls_locationR&   R)   R$   R   (   R   t   locationt   vc_type(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   get_backend_nameF   s    	c         C@  s*   | j  ƒ  } | |  j k r& |  j | Sd  S(   N(   t   lowerR   (   R   R$   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   get_backendR   s    c         C@  s&   |  j  | ƒ } | r" |  j | ƒ Sd  S(   N(   R0   R2   R   (   R   R.   R/   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   get_backend_from_locationW   s    N(   R(   t
   __module__R   R   R   R   t   propertyR   R"   R#   R+   R   R,   R0   R2   R3   (    (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR
      s   						t   VersionControlc           B@  sà   e  Z d  Z d  Z d Z d d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d d d d d d „ Z e d „  ƒ Z RS(   t    c         O@  s&   | |  _  t t |  ƒ j | | Ž  d  S(   N(   t   urlR   R6   R   (   R   R8   t   argst   kwargs(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR   g   s    	c         C@  s1   t  j j | ƒ \ } } | j t  j j ƒ p0 | S(   sy   
           posix absolute paths start with os.path.sep,
           win32 ones start with drive (like c:\folder)
        (   t   ost   patht
   splitdrivet
   startswitht   sep(   R   t   repot   drivet   tail(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   _is_local_repositoryk   s    c         C@  s   | j  d d ƒ S(   Nt   /t   _(   t   replace(   R   t   surname(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   translate_egg_surnameu   s    c         C@  s
   t  ‚ d S(   s�   
        Export the repository at the url to the destination location
        i.e. only download the files, without vcs informations
        N(   t   NotImplementedError(   R   R.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   exporty   s    c   	      C@  s’   d } |  j  j d d ƒ d } t j | ƒ \ } } } } } d } d | k rj | j d d ƒ \ } } n  t j | | | | d f ƒ } | | f S(   sm   
        Returns the correct repository URL and revision by parsing the given
        repository URL
        sv   Sorry, '%s' is a malformed VCS url. The format is <vcs>+<protocol>://<url>, e.g. svn+http://myrepo/svn/MyApp#egg=MyAppt   +i   t   @R7   N(   R8   t   splitR   t   urlsplitR   t   rsplitt
   urlunsplit(	   R   t   error_messageR8   t   schemet   netlocR<   t   queryt   fragt   rev(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   get_url_rev€   s    c         C@  s   |  j  | ƒ |  j | ƒ f S(   sA   
        Returns (url, revision), where both are strings
        (   t   get_urlt   get_revision(   R   R.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   get_info“   s    c         C@  s   t  j | ƒ j d ƒ S(   si   
        Normalize a URL for comparison by unquoting it and removing any
        trailing slash.
        RD   (   R   t   unquotet   rstrip(   R   R8   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   normalize_url›   s    c         C@  s   |  j  | ƒ |  j  | ƒ k S(   sV   
        Compare two repo URLs for identity, ignoring incidental differences.
        (   R]   (   R   t   url1t   url2(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   compare_urls¢   s    c         C@  s
   t  ‚ d S(   sx   
        Called when installing or updating an editable package, takes the
        source path of the checkout.
        N(   RI   (   R   t   dest(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   obtain¨   s    c         C@  s
   t  ‚ d S(   sB   
        Switch the repo at ``dest`` to point to ``URL``.
        N(   RI   (   R   Ra   R8   t   rev_options(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   switch¯   s    c         C@  s
   t  ‚ d S(   sO   
        Update an already-existing repo to the given ``rev_options``.
        N(   RI   (   R   Ra   Rc   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   updateµ   s    c         C@  s
   t  ‚ d S(   sp   
        Return True if the version is identical to what exists and
        doesn't need to be updated.
        N(   RI   (   R   Ra   Rc   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   check_version»   s    c   
      C@  sm  t  } t } t j j | ƒ rAt } t j j t j j | |  j ƒ ƒ r|  j | ƒ } |  j | | ƒ râ t	 j
 d |  j j ƒ  t | ƒ | ƒ |  j | | ƒ sÒ t	 j d t | ƒ |  j | ƒ |  j | | ƒ qt	 j d ƒ q>t	 j d |  j |  j t | ƒ | ƒ d d f } qAt	 j d
 | |  j |  j ƒ d d f } n  | rit	 j d |  j | ƒ t d | d | d ƒ } | d k r¼t	 j d |  j t | ƒ | | ƒ |  j | | | ƒ qi| d k rËqi| d k r t	 j d t | ƒ ƒ t | ƒ t  } qi| d	 k rJt | ƒ }	 t	 j d t | ƒ |	 ƒ t j | |	 ƒ t  } qi| d k rit j d ƒ qin  | S(   s­   
        Prepare a location to receive a checkout/clone.

        Return True if the location is ready for (and requires) a
        checkout/clone, False otherwise.
        s)   %s in %s exists, and has correct URL (%s)s   Updating %s %s%ss$   Skipping because already up-to-date.s   %s %s in %s exists with URL %ss%   (s)witch, (i)gnore, (w)ipe, (b)ackup t   st   it   wt   bs0   Directory %s already exists, and is not a %s %s.s   (i)gnore, (w)ipe, (b)ackup s+   The plan is to install the %s repository %ss   What to do?  %si    i   s   Switching %s %s to %s%ss   Deleting %ss   Backing up %s to %st   aiÿÿÿÿ(   Rg   Rh   Ri   Rj   (   Rh   Ri   Rj   (   t   Truet   FalseR;   R<   t   existst   joinR    RX   R`   R&   R)   t	   repo_namet   titleR   Rf   t   infoRe   R'   R$   R   Rd   R   R   t   shutilt   movet   syst   exit(
   R   Ra   R8   Rc   t   rev_displayt   checkoutt   promptt   existing_urlt   responset   dest_dir(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   check_destinationÂ   s‚    $		
	
	
		c         C@  s0   t  j j | ƒ r t | ƒ n  |  j | ƒ d S(   sq   
        Clean up current location and download the url repository
        (and vcs infos) into location
        N(   R;   R<   Rn   R   Rb   (   R   R.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   unpack  s    c         C@  s
   t  ‚ d S(   sê   
        Return a string representing the requirement needed to
        redownload the files currently present in location, something
        like:
          {repository_url}@{revision}#egg={project_name}-{version_identifier}
        N(   RI   (   R   t   distR.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR	      s    c         C@  s
   t  ‚ d S(   s_   
        Return the url used at location
        Used in get_info or check_destination
        N(   RI   (   R   R.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyRX   )  s    c         C@  s
   t  ‚ d S(   s_   
        Return the current revision of the files at location
        Used in get_info
        N(   RI   (   R   R.   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyRY   0  s    t   raisec   	      C@  su   |  j  g | } y  t | | | | | | | ƒ SWn> t k
 rp } | j t j k rj t d |  j  ƒ ‚ qq ‚  n Xd S(   s«   
        Run a VCS subcommand
        This is simply a wrapper around call_subprocess that adds the VCS
        command name, and checks that the VCS is available
        s   Cannot find command %rN(   R$   R   t   OSErrort   errnot   ENOENTR   (	   R   t   cmdt   show_stdoutt   cwdt   on_returncodet   command_desct   extra_environt   spinnert   e(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   run_command7  s    	c         C@  sD   t  j d | |  j |  j ƒ t j j | |  j ƒ } t j j | ƒ S(   s¨   
        Check if a location is controlled by the vcs.
        It is meant to be overridden to implement smarter detection
        mechanisms for specific vcs.
        s   Checking in %s for %s (%s)...(   R&   R)   R    R$   R;   R<   Ro   Rn   (   R*   R.   R<   (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR-   N  s    	(    N(   R(   R4   R$   R    R   R   R   RC   RH   RJ   RW   RZ   R]   R`   Rb   Rd   Re   Rf   R}   R~   R	   RX   RY   Rl   RŒ   t   classmethodR-   (    (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR6   a   s2   	
											U						c         C@  sz   t  j | ƒ } | r` y | ƒ  j |  | ƒ SWq` t k
 r\ t j d | | j ƒ |  j ƒ  SXn  t j d | ƒ |  j ƒ  S(   NsP   cannot determine version of editable source in %s (%s command not found in path)st   cannot determine version of editable source in %s (is not SVN checkout, Git clone, Mercurial clone or Bazaar branch)(   R   R3   R	   R   R&   R'   R$   t   as_requirement(   R   R.   t   version_control(    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR	   [  s    
(   t   __doc__t
   __future__R    R‚   t   loggingR;   Rs   Ru   t   pip._vendor.six.moves.urllibR   R   t   pip.exceptionsR   t	   pip.utilsR   R   R   R   R   t   __all__t	   getLoggerR(   R&   t   objectR
   R   R6   R	   (    (    (    s4   /usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt   <module>   s   (G	úPK     (\Y]k–éMã*  ã*    git.pyonu „[µü¤        ó
•�abc           @@  sø   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 d  d l
 m Z d  d l
 m Z d  d l m Z d  d l m Z m Z d  d l m Z m Z e j Z e j Z e j e ƒ Z d	 e f d
 „  ƒ  YZ e j e ƒ d S(   i    (   t   absolute_importN(   t   samefile(   t
   BadCommand(   t   parse(   t   request(   t   display_patht   rmtree(   t   vcst   VersionControlt   Gitc           B@  sï   e  Z d  Z d Z d Z d Z d d „ Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z RS(    t   gits   .gitt   clones   git+https	   git+httpss   git+sshs   git+gits   git+filec         O@  sí   | rÍ t  | ƒ \ } } } } } | j d ƒ rÍ | t | j d ƒ ƒ  }	 |	 t j | ƒ j d d ƒ j d ƒ }
 t | | |
 | | f ƒ } | j d ƒ d } | |  t | | | |
 | | f ƒ } qÍ n  t	 t
 |  ƒ j | | | Ž d  S(   Nt   filet   /s   \t   +i   (   t   urlsplitt   endswitht   lent   lstript   urllib_requestt   url2pathnamet   replacet
   urlunsplitt   findt   superR	   t   __init__(   t   selft   urlt   argst   kwargst   schemet   netloct   patht   queryt   fragmentt   initial_slashest   newpatht
   after_plus(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyR       s    
#c         C@  sl   d } |  j  d g d t ƒ} | j | ƒ r@ | t | ƒ } n d } d j | j d ƒ d  ƒ } t | ƒ S(   Ns   git version t   versiont   show_stdoutt    t   .i   (   t   run_commandt   Falset
   startswithR   t   joint   splitt   parse_version(   R   t   VERSION_PFXR&   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   get_git_version5   s    c         C@  sy   t  j d d ƒ } |  j | ƒ zH | j d ƒ s> | d } n  |  j d d d d | g d t d	 | ƒWd
 t | ƒ Xd
 S(   s@   Export the Git repository at the url to the destination locations   -exports   pip-R   s   checkout-indexs   -as   -fs   --prefixR'   t   cwdN(   t   tempfilet   mkdtempt   unpackR   R*   R+   R   (   R   t   locationt   temp_dir(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   exportB   s    c         C@  s_   |  j  | ƒ } d | } | | k r0 | | g S| | k rG | | g St j d | ƒ | Sd S(   s¶   Check the revision options before checkout to compensate that tags
        and branches may need origin/ as a prefix.
        Returns the SHA1 of the branch or tag if found.
        s	   origin/%ss5   Could not find a tag or branch '%s', assuming commit.N(   t   get_short_refst   loggert   warning(   R   t   revt   destt   rev_optionst	   revisionst
   origin_rev(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   check_rev_optionsO   s    

c         C@  s   |  j  | ƒ j | d ƒ S(   s
  
        Compare the current sha to the ref. ref may be a branch or tag name,
        but current rev will always point to a sha. This means that a branch
        or tag will never compare as True. So this ultimately only matches
        against exact shas.
        i    (   t   get_revisionR,   (   R   R=   R>   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   check_versionc   s    c         C@  sJ   |  j  d d | g d | ƒ|  j  d d g | d | ƒ|  j | ƒ d  S(   Nt   configs   remote.origin.urlR2   t   checkouts   -q(   R*   t   update_submodules(   R   R=   R   R>   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   switchl   s    c         C@  s£   |  j  ƒ  t d ƒ k r7 |  j d d d g d | ƒn |  j d d g d | ƒ| rr |  j | d | | ƒ } n  |  j d d d g | d | ƒ|  j | ƒ d  S(	   Ns   1.9.0t   fetchs   -qs   --tagsR2   i    t   resets   --hard(   R1   R/   R*   RA   RF   (   R   R=   R>   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   updater   s     c         C@  sî   |  j  ƒ  \ } } | r. | g } d | } n d g } d } |  j | | | | ƒ rê t j d | | t | ƒ ƒ |  j d d | | g ƒ | rÚ |  j | | | ƒ } |  j | | ƒ sÚ |  j d d g | d | ƒqÚ n  |  j | ƒ n  d  S(	   Ns    (to %s)s   origin/masterR(   s   Cloning %s%s to %sR   s   -qRE   R2   (	   t   get_url_revt   check_destinationR:   t   infoR   R*   RA   RC   RF   (   R   R=   R   R<   R>   t   rev_display(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   obtain‚   s"    		c         C@  s�   |  j  d d d g d t d | ƒ} | j ƒ  } | d } x' | D] } | j d ƒ rA | } PqA qA W| j d ƒ d	 } | j ƒ  S(
   s+   Return URL of the first remote encountered.RD   s   --get-regexps   remote\..*\.urlR'   R2   i    s   remote.origin.url t    i   (   R*   R+   t
   splitlinesR,   R.   t   strip(   R   R6   t   remotest   found_remotet   remoteR   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   get_url›   s    
c         C@  s+   |  j  d d g d t d | ƒ} | j ƒ  S(   Ns	   rev-parset   HEADR'   R2   (   R*   R+   RR   (   R   R6   t   current_rev(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyRB   ©   s    c         c@  sn   |  j  d g d t d | ƒ} xI | j ƒ  j ƒ  D]5 } | j d d ƒ \ } } | j ƒ  | j ƒ  f Vq1 Wd S(   s4   Yields tuples of (commit, ref) for branches and tagss   show-refR'   R2   RP   i   N(   R*   R+   RR   RQ   R.   (   R   R6   t   outputt   linet   committ   ref(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   get_full_refs®   s
    c         C@  s   | j  d ƒ S(   Ns   refs/remotes/(   R,   (   R   R\   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   is_ref_remote¶   s    c         C@  s   | j  d ƒ S(   Ns   refs/heads/(   R,   (   R   R\   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   is_ref_branch¹   s    c         C@  s   | j  d ƒ S(   Ns
   refs/tags/(   R,   (   R   R\   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt
   is_ref_tag¼   s    c         C@  s/   t  |  j | ƒ |  j | ƒ |  j | ƒ f ƒ S(   s0   A ref is a commit sha if it is not anything else(   t   anyR^   R_   R`   (   R   R\   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   is_ref_commit¿   s    c         C@  s   |  j  | ƒ S(   N(   R9   (   R   R6   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   get_refsÈ   s    c         C@  s¯   i  } x¢ |  j  | ƒ D]‘ \ } } d } |  j | ƒ rJ | t d ƒ } nD |  j | ƒ rl | t d ƒ } n" |  j | ƒ rŽ | t d ƒ } n  | d k	 r | | | <q q W| S(   s=   Return map of named refs (branches or tags) to commit hashes.s   refs/remotes/s   refs/heads/s
   refs/tags/N(   R]   t   NoneR^   R   R_   R`   (   R   R6   t   rvR[   R\   t   ref_name(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyR9   Ë   s    c         C@  sò   |  j  d d g d t d | ƒj ƒ  } t j j | ƒ sQ t j j | | ƒ } n  t j j | d ƒ } | } x] t j j t j j | d ƒ ƒ sË | } t j j | ƒ } | | k ro t	 j
 d | ƒ d Sqo Wt | | ƒ rß d St j j | | ƒ S(	   s:   Return the relative path of setup.py to the git repo root.s	   rev-parses	   --git-dirR'   R2   s   ..s   setup.pysG   Could not find setup.py for directory %s (tried all parent directories)N(   R*   R+   RR   t   osR    t   isabsR-   t   existst   dirnameR:   R;   Rd   R   t   relpath(   R   R6   t   git_dirt   root_dirt   orig_locationt   last_location(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   _get_subdirectoryÚ   s"    $c         C@  s£   |  j  | ƒ } | j ƒ  j d ƒ s1 d | } n  | j ƒ  j d d ƒ d } | sW d  S|  j | ƒ } d | | | f } |  j | ƒ } | rŸ | d | 7} n  | S(   Ns   git:s   git+t   -i   i    s   %s@%s#egg=%ss   &subdirectory=(   RV   t   lowerR,   t   egg_nameR.   Rd   RB   Rp   (   R   t   distR6   t   repot   egg_project_nameRX   t   reqt   subdirectory(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   get_src_requirementõ   s    c         C@  s|   d |  j  k rW |  j  j d d ƒ |  _  t t |  ƒ j ƒ  \ } } | j d d ƒ } n t t |  ƒ j ƒ  \ } } | | f S(   s;  
        Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'.
        That's required because although they use SSH they sometimes doesn't
        work with a ssh:// scheme (e.g. Github). But we need a scheme for
        parsing. Hence we remove it again afterwards and return it as a stub.
        s   ://s   git+s
   git+ssh://s   ssh://R(   (   R   R   R   R	   RK   (   R   R   R<   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyRK     s    c         C@  sK   t  j j t  j j | d ƒ ƒ s% d  S|  j d d d d d g d | ƒd  S(   Ns   .gitmodulest	   submoduleRJ   s   --inits   --recursives   -qR2   (   Rg   R    Ri   R-   R*   (   R   R6   (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyRF     s
    !c         C@  su   t  t |  ƒ j | ƒ r t Sy0 |  ƒ  j d g d | d t d d ƒ} | SWn" t k
 rp t j d | ƒ t SXd  S(   Ns	   rev-parseR2   R'   t   on_returncodet   ignoresK   could not determine if %s is under git control because git is not available(	   R   R	   t   controls_locationt   TrueR*   R+   R   R:   t   debug(   t   clsR6   t   r(    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyR}     s    			(   R
   s   git+https	   git+httpss   git+sshs   git+gits   git+fileN(   t   __name__t
   __module__t   nameRj   t	   repo_namet   schemesRd   R   R1   R8   RA   RC   RG   RJ   RO   RV   RB   R]   R^   R_   R`   Rb   Rc   R9   Rp   Ry   RK   RF   t   classmethodR}   (    (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyR	      s4   																						(   t
   __future__R    t   loggingR3   t   os.pathRg   t
   pip.compatR   t   pip.exceptionsR   t   pip._vendor.six.moves.urllibR   t   urllib_parseR   R   t   pip._vendor.packaging.versionR/   t	   pip.utilsR   R   t   pip.vcsR   R   R   R   t	   getLoggerR‚   R:   R	   t   register(    (    (    s/   /usr/lib/python2.7/site-packages/pip/vcs/git.pyt   <module>   s    		ÿ PK     (\Y](¾Þ0½+  ½+    git.pynu „[µü¤        from __future__ import absolute_import

import logging
import tempfile
import os.path

from pip.compat import samefile
from pip.exceptions import BadCommand
from pip._vendor.six.moves.urllib import parse as urllib_parse
from pip._vendor.six.moves.urllib import request as urllib_request
from pip._vendor.packaging.version import parse as parse_version

from pip.utils import display_path, rmtree
from pip.vcs import vcs, VersionControl


urlsplit = urllib_parse.urlsplit
urlunsplit = urllib_parse.urlunsplit


logger = logging.getLogger(__name__)


class Git(VersionControl):
    name = 'git'
    dirname = '.git'
    repo_name = 'clone'
    schemes = (
        'git', 'git+http', 'git+https', 'git+ssh', 'git+git', 'git+file',
    )

    def __init__(self, url=None, *args, **kwargs):

        # Works around an apparent Git bug
        # (see http://article.gmane.org/gmane.comp.version-control.git/146500)
        if url:
            scheme, netloc, path, query, fragment = urlsplit(url)
            if scheme.endswith('file'):
                initial_slashes = path[:-len(path.lstrip('/'))]
                newpath = (
                    initial_slashes +
                    urllib_request.url2pathname(path)
                    .replace('\\', '/').lstrip('/')
                )
                url = urlunsplit((scheme, netloc, newpath, query, fragment))
                after_plus = scheme.find('+') + 1
                url = scheme[:after_plus] + urlunsplit(
                    (scheme[after_plus:], netloc, newpath, query, fragment),
                )

        super(Git, self).__init__(url, *args, **kwargs)

    def get_git_version(self):
        VERSION_PFX = 'git version '
        version = self.run_command(['version'], show_stdout=False)
        if version.startswith(VERSION_PFX):
            version = version[len(VERSION_PFX):]
        else:
            version = ''
        # get first 3 positions of the git version becasue
        # on windows it is x.y.z.windows.t, and this parses as
        # LegacyVersion which always smaller than a Version.
        version = '.'.join(version.split('.')[:3])
        return parse_version(version)

    def export(self, location):
        """Export the Git repository at the url to the destination location"""
        temp_dir = tempfile.mkdtemp('-export', 'pip-')
        self.unpack(temp_dir)
        try:
            if not location.endswith('/'):
                location = location + '/'
            self.run_command(
                ['checkout-index', '-a', '-f', '--prefix', location],
                show_stdout=False, cwd=temp_dir)
        finally:
            rmtree(temp_dir)

    def check_rev_options(self, rev, dest, rev_options):
        """Check the revision options before checkout to compensate that tags
        and branches may need origin/ as a prefix.
        Returns the SHA1 of the branch or tag if found.
        """
        revisions = self.get_short_refs(dest)

        origin_rev = 'origin/%s' % rev
        if origin_rev in revisions:
            # remote branch
            return [revisions[origin_rev]]
        elif rev in revisions:
            # a local tag or branch name
            return [revisions[rev]]
        else:
            logger.warning(
                "Could not find a tag or branch '%s', assuming commit.", rev,
            )
            return rev_options

    def check_version(self, dest, rev_options):
        """
        Compare the current sha to the ref. ref may be a branch or tag name,
        but current rev will always point to a sha. This means that a branch
        or tag will never compare as True. So this ultimately only matches
        against exact shas.
        """
        return self.get_revision(dest).startswith(rev_options[0])

    def switch(self, dest, url, rev_options):
        self.run_command(['config', 'remote.origin.url', url], cwd=dest)
        self.run_command(['checkout', '-q'] + rev_options, cwd=dest)

        self.update_submodules(dest)

    def update(self, dest, rev_options):
        # First fetch changes from the default remote
        if self.get_git_version() >= parse_version('1.9.0'):
            # fetch tags in addition to everything else
            self.run_command(['fetch', '-q', '--tags'], cwd=dest)
        else:
            self.run_command(['fetch', '-q'], cwd=dest)
        # Then reset to wanted revision (maybe even origin/master)
        if rev_options:
            rev_options = self.check_rev_options(
                rev_options[0], dest, rev_options,
            )
        self.run_command(['reset', '--hard', '-q'] + rev_options, cwd=dest)
        #: update submodules
        self.update_submodules(dest)

    def obtain(self, dest):
        url, rev = self.get_url_rev()
        if rev:
            rev_options = [rev]
            rev_display = ' (to %s)' % rev
        else:
            rev_options = ['origin/master']
            rev_display = ''
        if self.check_destination(dest, url, rev_options, rev_display):
            logger.info(
                'Cloning %s%s to %s', url, rev_display, display_path(dest),
            )
            self.run_command(['clone', '-q', url, dest])

            if rev:
                rev_options = self.check_rev_options(rev, dest, rev_options)
                # Only do a checkout if rev_options differs from HEAD
                if not self.check_version(dest, rev_options):
                    self.run_command(
                        ['checkout', '-q'] + rev_options,
                        cwd=dest,
                    )
            #: repo may contain submodules
            self.update_submodules(dest)

    def get_url(self, location):
        """Return URL of the first remote encountered."""
        remotes = self.run_command(
            ['config', '--get-regexp', 'remote\..*\.url'],
            show_stdout=False, cwd=location)
        remotes = remotes.splitlines()
        found_remote = remotes[0]
        for remote in remotes:
            if remote.startswith('remote.origin.url '):
                found_remote = remote
                break
        url = found_remote.split(' ')[1]
        return url.strip()

    def get_revision(self, location):
        current_rev = self.run_command(
            ['rev-parse', 'HEAD'], show_stdout=False, cwd=location)
        return current_rev.strip()

    def get_full_refs(self, location):
        """Yields tuples of (commit, ref) for branches and tags"""
        output = self.run_command(['show-ref'],
                                  show_stdout=False, cwd=location)
        for line in output.strip().splitlines():
            commit, ref = line.split(' ', 1)
            yield commit.strip(), ref.strip()

    def is_ref_remote(self, ref):
        return ref.startswith('refs/remotes/')

    def is_ref_branch(self, ref):
        return ref.startswith('refs/heads/')

    def is_ref_tag(self, ref):
        return ref.startswith('refs/tags/')

    def is_ref_commit(self, ref):
        """A ref is a commit sha if it is not anything else"""
        return not any((
            self.is_ref_remote(ref),
            self.is_ref_branch(ref),
            self.is_ref_tag(ref),
        ))

    # Should deprecate `get_refs` since it's ambiguous
    def get_refs(self, location):
        return self.get_short_refs(location)

    def get_short_refs(self, location):
        """Return map of named refs (branches or tags) to commit hashes."""
        rv = {}
        for commit, ref in self.get_full_refs(location):
            ref_name = None
            if self.is_ref_remote(ref):
                ref_name = ref[len('refs/remotes/'):]
            elif self.is_ref_branch(ref):
                ref_name = ref[len('refs/heads/'):]
            elif self.is_ref_tag(ref):
                ref_name = ref[len('refs/tags/'):]
            if ref_name is not None:
                rv[ref_name] = commit
        return rv

    def _get_subdirectory(self, location):
        """Return the relative path of setup.py to the git repo root."""
        # find the repo root
        git_dir = self.run_command(['rev-parse', '--git-dir'],
                                   show_stdout=False, cwd=location).strip()
        if not os.path.isabs(git_dir):
            git_dir = os.path.join(location, git_dir)
        root_dir = os.path.join(git_dir, '..')
        # find setup.py
        orig_location = location
        while not os.path.exists(os.path.join(location, 'setup.py')):
            last_location = location
            location = os.path.dirname(location)
            if location == last_location:
                # We've traversed up to the root of the filesystem without
                # finding setup.py
                logger.warning(
                    "Could not find setup.py for directory %s (tried all "
                    "parent directories)",
                    orig_location,
                )
                return None
        # relative path of setup.py to repo root
        if samefile(root_dir, location):
            return None
        return os.path.relpath(location, root_dir)

    def get_src_requirement(self, dist, location):
        repo = self.get_url(location)
        if not repo.lower().startswith('git:'):
            repo = 'git+' + repo
        egg_project_name = dist.egg_name().split('-', 1)[0]
        if not repo:
            return None
        current_rev = self.get_revision(location)
        req = '%s@%s#egg=%s' % (repo, current_rev, egg_project_name)
        subdirectory = self._get_subdirectory(location)
        if subdirectory:
            req += '&subdirectory=' + subdirectory
        return req

    def get_url_rev(self):
        """
        Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'.
        That's required because although they use SSH they sometimes doesn't
        work with a ssh:// scheme (e.g. Github). But we need a scheme for
        parsing. Hence we remove it again afterwards and return it as a stub.
        """
        if '://' not in self.url:
            assert 'file:' not in self.url
            self.url = self.url.replace('git+', 'git+ssh://')
            url, rev = super(Git, self).get_url_rev()
            url = url.replace('ssh://', '')
        else:
            url, rev = super(Git, self).get_url_rev()

        return url, rev

    def update_submodules(self, location):
        if not os.path.exists(os.path.join(location, '.gitmodules')):
            return
        self.run_command(
            ['submodule', 'update', '--init', '--recursive', '-q'],
            cwd=location,
        )

    @classmethod
    def controls_location(cls, location):
        if super(Git, cls).controls_location(location):
            return True
        try:
            r = cls().run_command(['rev-parse'],
                                  cwd=location,
                                  show_stdout=False,
                                  on_returncode='ignore')
            return not r
        except BadCommand:
            logger.debug("could not determine if %s is under git control "
                         "because git is not available", location)
            return False


vcs.register(Git)
PK       (\Y]n4•A†$  †$                  subversion.pynu „[µü¤        PK       (\Y]f·ê«3  «3              Ã$  __init__.pycnu „[µü¤        PK       (\Y]y©¦6ž  ž  
            ªX  bazaar.pyonu „[µü¤        PK       (\Y]ybj�  �              ‚k  mercurial.pynu „[µü¤        PK       (\Y]°{^TZ!  Z!              Ny  subversion.pyonu „[µü¤        PK       (\Y]y©¦6ž  ž  
            æš  bazaar.pycnu „[µü¤        PK       (\Y]	@‘þ  þ              ¾­  mercurial.pycnu „[µü¤        PK       (\Y]ÈVÅKV0  V0              ù¿  __init__.pynu „[µü¤        PK       (\Y]H`½¤Õ!  Õ!              Šð  subversion.pycnu „[µü¤        PK       (\Y]ûÀÌÅÛ  Û  	            � bazaar.pynu „[µü¤        PK       (\Y]	@‘þ  þ              ±! mercurial.pyonu „[µü¤        PK       (\Y]ì¢Šû+  +              ì3 git.pycnu „[µü¤        PK       (\Y]3Á3E3  3              :_ __init__.pyonu „[µü¤        PK       (\Y]k–éMã*  ã*              ƒ’ git.pyonu „[µü¤        PK       (\Y](¾Þ0½+  ½+              �½ git.pynu „[µü¤        PK      c  �é   