Repository: pypa/pip

Issue:
Bad error message on malformed VCS string
The item in my requirements.txt:

```
git://github.com/alex/django-fixture-generator.git#egg=fixture_generator
```

The resulting error message:

``` python
Downloading/unpacking fixture-generator from git://github.com/alex/django-fixture-generator.git (from -r requirements/development.txt (line 3))
Exception:
Traceback (most recent call last):
  File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/basecommand.py", line 126, in main
    self.run(options, args)
  File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/commands/install.py", line 223, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 961, in prepare_files
    self.unpack_url(url, location, self.is_download)
  File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 1073, in unpack_url
    return unpack_vcs_link(link, location, only_download)
  File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/download.py", line 293, in unpack_vcs_link
    vcs_backend.unpack(location)
  File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/vcs/__init__.py", line 225, in unpack
    self.obtain(location)
  File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/vcs/git.py", line 97, in obtain
    url, rev = self.get_url_rev()
  File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/vcs/git.py", line 183, in get_url_rev
    url, rev = super(Git, self).get_url_rev()
  File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/vcs/__init__.py", line 117, in get_url_rev
    url = self.url.split('+', 1)[1]
IndexError: list index out of range
```



Discussion:
Yeah we definitely should do better, probably should fix consistently across all vcs backends ensuring bare scheme is handled correctly.


Resolving patch:
diff --git a/pip/vcs/__init__.py b/pip/vcs/__init__.py
--- a/pip/vcs/__init__.py
+++ b/pip/vcs/__init__.py
@@ -115,6 +115,9 @@ def get_url_rev(self):
         Returns the correct repository URL and revision by parsing the given
         repository URL
         """
+        error_message= "Sorry, '{}' is a malformed url. In requirements files, the \
+format is <vcs>+<protocol>://<url>, e.g. svn+http://myrepo/svn/MyApp#egg=MyApp"
+        assert '+' in self.url, error_message.format(self.url)
         url = self.url.split('+', 1)[1]
         scheme, netloc, path, query, frag = urlparse.urlsplit(url)
         rev = None


Test patch:
diff --git a/tests/test_requirements.py b/tests/test_requirements.py
--- a/tests/test_requirements.py
+++ b/tests/test_requirements.py
@@ -1,5 +1,6 @@
 import os.path
 import textwrap
+from nose.tools import assert_raises
 from pip.backwardcompat import urllib
 from pip.req import Requirements
 from tests.test_pip import reset_env, run_pip, write_file, pyversion, here, path_to_url
@@ -26,6 +27,16 @@ def test_requirements_file():
     fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
     assert result.files_created[env.site_packages/fn].dir
 
+def test_schema_check_in_requirements_file():
+    """
+    Test installing from a requirements file with an invalid vcs schema..
+
+    """
+    env = reset_env()
+    write_file('file-egg-req.txt', textwrap.dedent("""\
+        git://github.com/alex/django-fixture-generator.git#egg=fixture_generator
+        """))
+    assert_raises(AssertionError, run_pip, 'install', '-vvv', '-r', env.scratch_path / 'file-egg-req.txt')
 
 def test_relative_requirements_file():
     """