Hugo Lopes Tavares avatar Hugo Lopes Tavares committed 77ab4af

splitted local_repo into `local_repo` and `local_checkout`: `local_repo` returns file://url, while `local_checkout` returns vcs+file://url and updated code used `local_repo` function

Comments (0)

Files changed (7)

tests/local_repos.py

     return folder_name
 
 
-def _get_vcs_checkout_url(remote_repository):
+def _get_vcs_and_checkout_url(remote_repository):
     vcs_repos = _get_vcs_folder()
     vcs_classes = {'svn': subversion.Subversion,
                    'git': git.Git,
     destination_path = os.path.join(vcs_repos, repository_name)
     if not os.path.exists(destination_path):
         vcs_class(remote_repository).obtain(destination_path)
-    return path_to_url('/'.join([vcs_repos, repository_name, branch]))
+    return '%s+%s' % (vcs, path_to_url('/'.join([vcs_repos, repository_name, branch])))
+
+
+def local_checkout(remote_repo):
+    if remote_repo.startswith('svn'):
+        _create_svn_repository_for_initools()
+    return _get_vcs_and_checkout_url(remote_repo)
 
 
 def local_repo(remote_repo):
-    if remote_repo.startswith('svn'):
-        _create_svn_repository_for_initools()
-    return _get_vcs_checkout_url(remote_repo)
+    return local_checkout(remote_repo).split('+', 1)[1] 

tests/test_basic.py

 import filecmp
 from os.path import abspath, join, curdir, pardir
 from test_pip import here, reset_env, run_pip, pyversion, mkdir, src_folder
-from local_repos import local_repo
+from local_repos import local_checkout
 from path import Path
 
 
     reset_env()
     result = run_pip('install',
                      '-e',
-                     'svn+%s#egg=initools-dev' %
-                     local_repo('svn+http://svn.colorstudy.com/INITools/trunk'))
+                     '%s#egg=initools-dev' %
+                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
     result.assert_installed('INITools', with_files=['.svn'])
 
 
     mkdir('customdl')
     result = run_pip('install',
                      '-e',
-                     'svn+%s#egg=initools-dev' %
-                     local_repo('svn+http://svn.colorstudy.com/INITools/trunk'),
+                     '%s#egg=initools-dev' %
+                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
                      '--src',
                      'customsrc',
                      '--download',
 
     result = run_pip('install',
                      '-e',
-                     'svn+%s#egg=initools-dev' %
-                     local_repo('svn+http://svn.colorstudy.com/INITools/trunk'),
+                     '%s#egg=initools-dev' %
+                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
                      '--no-install', expect_error=True)
     result.assert_installed('INITools', without_egg_link=True, with_files=['.svn'])
 
     result = run_pip('install',
                      '-e',
-                     'svn+%s#egg=initools-dev' %
-                     local_repo('svn+http://svn.colorstudy.com/INITools/trunk'),
+                     '%s#egg=initools-dev' %
+                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
                      '--no-download', expect_error=True)
     result.assert_installed('INITools', without_files=[curdir, '.svn'])
 
     """
     reset_env()
     result = run_pip('install', '-e',
-                     'git+%s#egg=django-feedutil' %
-                     local_repo('git+http://github.com/jezdez/django-feedutil.git'),
+                     '%s#egg=django-feedutil' %
+                     local_checkout('git+http://github.com/jezdez/django-feedutil.git'),
                      expect_error=True)
     result.assert_installed('django-feedutil', with_files=['.git'])
 
     """
     reset_env()
     result = run_pip('install', '-e',
-                     'hg+%s#egg=django-registration' %
-                     local_repo('hg+http://bitbucket.org/ubernostrum/django-registration'),
+                     '%s#egg=django-registration' %
+                     local_checkout('hg+http://bitbucket.org/ubernostrum/django-registration'),
                      expect_error=True)
     result.assert_installed('django-registration', with_files=['.hg'])
 
     """
     reset_env()
     result = run_pip('install', '-e',
-                     'hg+%s/#egg=django-registration' %
-                     local_repo('hg+http://bitbucket.org/ubernostrum/django-registration'),
+                     '%s/#egg=django-registration' %
+                     local_checkout('hg+http://bitbucket.org/ubernostrum/django-registration'),
                      expect_error=True)
     assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
 
     """
     reset_env()
     result = run_pip('install', '-e',
-                     'bzr+%s/@174#egg=django-wikiapp' %
-                     local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
+                     '%s/@174#egg=django-wikiapp' %
+                     local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
                      expect_error=True)
     result.assert_installed('django-wikiapp', with_files=['.bzr'])
 
     """
     reset_env()
     result = run_pip('install', '-e',
-                     'bzr+%s/#egg=django-wikiapp' %
-                     local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
+                     '%s/#egg=django-wikiapp' %
+                     local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
                      expect_error=True)
     assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
 

tests/test_bundle.py

 from pip.util import path_to_url2
 from test_pip import here, reset_env, run_pip, write_file
 from path import Path
-from local_repos import local_repo
+from local_repos import local_checkout
 
 
 def test_create_bundle():
     run_pip('install', '-e', fspkg)
     pkg_lines = textwrap.dedent('''\
             -e %s
-            -e svn+%s#egg=initools-dev
-            pip''' % (fspkg, local_repo('svn+http://svn.colorstudy.com/INITools/trunk')))
+            -e %s#egg=initools-dev
+            pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
     write_file('bundle-req.txt', pkg_lines)
     # Create a bundle in env.scratch_path/ test.pybundle
     result = run_pip('bundle', '-r', env.scratch_path/ 'bundle-req.txt', env.scratch_path/ 'test.pybundle')

tests/test_cleanup.py

 import textwrap
 from os.path import abspath, exists, join
 from test_pip import here, reset_env, run_pip, write_file
-from local_repos import local_repo
+from local_repos import local_checkout
 
 
 def test_cleanup_after_install_from_pypi():
     env = reset_env()
     run_pip('install',
             '-e',
-            'hg+%s#egg=django-registration' %
-            local_repo('hg+http://bitbucket.org/ubernostrum/django-registration'),
+            '%s#egg=django-registration' %
+            local_checkout('hg+http://bitbucket.org/ubernostrum/django-registration'),
             expect_error=True)
     build = env.venv_path/'build'
     src = env.venv_path/'src'
     env = reset_env()
     # Install an editable to create a src/ dir.
     run_pip('install', '-e',
-            'git+%s#egg=django-feedutil' %
-            local_repo('git+http://github.com/jezdez/django-feedutil.git'))
+            '%s#egg=django-feedutil' %
+            local_checkout('git+http://github.com/jezdez/django-feedutil.git'))
     build = env.venv_path/"build"
     src = env.venv_path/"src"
     assert not exists(build), "build/ dir still exists: %s" % build
     fspkg = 'file://%s/FSPkg' %join(here, 'packages')
     pkg_lines = textwrap.dedent('''\
             -e %s
-            -e svn+%s#egg=initools-dev
-            pip''' % (fspkg, local_repo('svn+http://svn.colorstudy.com/INITools/trunk')))
+            -e %s#egg=initools-dev
+            pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
     write_file('bundle-req.txt', pkg_lines)
     run_pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle')
     build_bundle = env.scratch_path/"build-bundle"

tests/test_freeze.py

 import textwrap
 from doctest import OutputChecker, ELLIPSIS
 from test_pip import reset_env, run_pip, write_file, get_env
-from local_repos import local_repo
+from local_repos import local_checkout, local_repo
 
 
 distribute_re = re.compile('^distribute==[0-9.]+\n', re.MULTILINE)
     expected = textwrap.dedent("""\
         Script result: ...pip freeze
         -- stdout: --------------------
-        -e svn+%s@3472#egg=INITools-0.2.1dev_r3472-py2...-dev_r3472
+        -e %s@3472#egg=INITools-0.2.1dev_r3472-py2...-dev_r3472
         simplejson==1.7.4...
-        <BLANKLINE>""" % local_repo('svn+http://svn.colorstudy.com/INITools/trunk'))
+        <BLANKLINE>""" % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
     _check_output(result, expected)
 
     # Now, straight from trunk (but not editable/setup.py develop)::
 
     # Bah, that's no good!  Let's give it a hint::
     result = run_pip('freeze', '-f',
-                     'svn+%s#egg=INITools-dev' %
-                     local_repo('svn+http://svn.colorstudy.com/INITools/trunk'),
+                     '%s#egg=INITools-dev' %
+                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
                      expect_stderr=True)
     expected = textwrap.dedent("""\
-        Script result: ...pip freeze -f svn+%(repo)s#egg=INITools-dev
+        Script result: ...pip freeze -f %(repo)s#egg=INITools-dev
         -- stdout: --------------------
-        -f svn+%(repo)s#egg=INITools-dev
+        -f %(repo)s#egg=INITools-dev
         # Installing as editable to satisfy requirement INITools==...dev-r...:
-        -e svn+%(repo)s@...#egg=INITools-...dev_r...
+        -e %(repo)s@...#egg=INITools-...dev_r...
         simplejson==1.7.4...
-        <BLANKLINE>""" % {'repo': local_repo('svn+http://svn.colorstudy.com/INITools/trunk')})
+        <BLANKLINE>""" % {'repo': local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')})
     _check_output(result, expected)
 
 
     expected = textwrap.dedent("""\
         Script result: ...pip freeze
         -- stdout: --------------------
-        -e git+%s@...#egg=django_pagination-...
-        ...""" % local_repo('git+http://github.com/jezdez/django-pagination.git'))
+        -e %s@...#egg=django_pagination-...
+        ...""" % local_checkout('git+http://github.com/jezdez/django-pagination.git'))
     _check_output(result, expected)
 
     result = run_pip('freeze', '-f',
-                     'git+%s#egg=django_pagination' % local_repo('git+http://github.com/jezdez/django-pagination.git'),
+                     '%s#egg=django_pagination' % local_checkout('git+http://github.com/jezdez/django-pagination.git'),
                      expect_stderr=True)
     expected = textwrap.dedent("""\
-        Script result: pip freeze -f git+%(repo)s#egg=django_pagination
+        Script result: pip freeze -f %(repo)s#egg=django_pagination
         -- stdout: --------------------
-        -f git+%(repo)s#egg=django_pagination
-        -e git+%(repo)s@...#egg=django_pagination-...-dev
-        ...""" % {'repo': local_repo('git+http://github.com/jezdez/django-pagination.git')})
+        -f %(repo)s#egg=django_pagination
+        -e %(repo)s@...#egg=django_pagination-...-dev
+        ...""" % {'repo': local_checkout('git+http://github.com/jezdez/django-pagination.git')})
     _check_output(result, expected)
 
 
     expected = textwrap.dedent("""\
         Script result: ...pip freeze
         -- stdout: --------------------
-        -e hg+%s@...#egg=django_dbtemplates-...
-        ...""" % local_repo('hg+http://bitbucket.org/jezdez/django-dbtemplates'))
+        -e %s@...#egg=django_dbtemplates-...
+        ...""" % local_checkout('hg+http://bitbucket.org/jezdez/django-dbtemplates'))
     _check_output(result, expected)
 
     result = run_pip('freeze', '-f',
-                     'hg+%s#egg=django_dbtemplates' % local_repo('hg+http://bitbucket.org/jezdez/django-dbtemplates'),
+                     '%s#egg=django_dbtemplates' % local_checkout('hg+http://bitbucket.org/jezdez/django-dbtemplates'),
                      expect_stderr=True)
     expected = textwrap.dedent("""\
-        Script result: ...pip freeze -f hg+%(repo)s#egg=django_dbtemplates
+        Script result: ...pip freeze -f %(repo)s#egg=django_dbtemplates
         -- stdout: --------------------
-        -f hg+%(repo)s#egg=django_dbtemplates
-        -e hg+%(repo)s@...#egg=django_dbtemplates-...
-        ...""" % {'repo': local_repo('hg+http://bitbucket.org/jezdez/django-dbtemplates')})
+        -f %(repo)s#egg=django_dbtemplates
+        -e %(repo)s@...#egg=django_dbtemplates-...
+        ...""" % {'repo': local_checkout('hg+http://bitbucket.org/jezdez/django-dbtemplates')})
     _check_output(result, expected)
 
 
     expected = textwrap.dedent("""\
         Script result: ...pip freeze
         -- stdout: --------------------
-        -e bzr+%s@...#egg=django_wikiapp-...
-        ...""" % local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'))
+        -e %s@...#egg=django_wikiapp-...
+        ...""" % local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'))
     _check_output(result, expected)
 
     result = run_pip('freeze', '-f',
-                     'bzr+%s/#egg=django-wikiapp' %
-                     local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
+                     '%s/#egg=django-wikiapp' %
+                     local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
                      expect_stderr=True)
     expected = textwrap.dedent("""\
-        Script result: ...pip freeze -f bzr+%(repo)s/#egg=django-wikiapp
+        Script result: ...pip freeze -f %(repo)s/#egg=django-wikiapp
         -- stdout: --------------------
-        -f bzr+%(repo)s/#egg=django-wikiapp
-        -e bzr+%(repo)s@...#egg=django_wikiapp-...
+        -f %(repo)s/#egg=django-wikiapp
+        -e %(repo)s@...#egg=django_wikiapp-...
         ...""" % {'repo':
-                  local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1')})
+                  local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1')})
     _check_output(result, expected)
 
 

tests/test_requirements.py

 import textwrap
 from test_pip import reset_env, run_pip, write_file, pyversion
-from local_repos import local_repo
+from local_repos import local_checkout
 
 
 def test_requirements_file():
     """
     env = reset_env()
     write_file('initools-req.txt', textwrap.dedent("""\
-        -e svn+%s@3139#egg=INITools-dev
-        -r simplejson-req.txt""" % local_repo('http://svn.colorstudy.com/INITools/trunk')))
+        -e %s@3139#egg=INITools-dev
+        -r simplejson-req.txt""" % local_checkout('http://svn.colorstudy.com/INITools/trunk')))
     write_file('simplejson-req.txt', textwrap.dedent("""\
         simplejson<=1.7.4
         """))

tests/test_uninstall.py

 from os.path import join
 from tempfile import mkdtemp
 from test_pip import reset_env, run_pip, assert_all_changes, write_file
-from local_repos import local_repo
+from local_repos import local_repo, local_checkout
 
 
 def test_simple_uninstall():
 
     """
     env = reset_env()
-    result = run_pip('install', '-e', 'svn+%s#egg=initools-dev' %
-                     local_repo('svn+http://svn.colorstudy.com/INITools/trunk'))
+    result = run_pip('install', '-e', '%s#egg=initools-dev' %
+                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
     result.assert_installed('INITools')
     result2 = run_pip('uninstall', '-y', 'initools')
     assert (env.venv/'src'/'initools' in result2.files_after), 'oh noes, pip deleted my sources!'
     """
     env = reset_env()
     write_file('test-req.txt', textwrap.dedent("""\
-        -e svn+%s#egg=initools-dev
+        -e %s#egg=initools-dev
         # and something else to test out:
         PyLogo<0.4
-        """ % local_repo('svn+http://svn.colorstudy.com/INITools/trunk')))
+        """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
     result = run_pip('install', '-r', 'test-req.txt')
     write_file('test-req.txt', textwrap.dedent("""\
         # -f, -i, and --extra-index-url should all be ignored by uninstall
         -i http://www.example.com
         --extra-index-url http://www.example.com
 
-        -e svn+%s#egg=initools-dev
+        -e %s#egg=initools-dev
         # and something else to test out:
         PyLogo<0.4
-        """ % local_repo('svn+http://svn.colorstudy.com/INITools/trunk')))
+        """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
     result2 = run_pip('uninstall', '-r', 'test-req.txt', '-y')
     assert_all_changes(
         result, result2, [env.venv/'build', env.venv/'src', env.scratch/'test-req.txt'])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.