Moved up check to see if 'repo' was valid before calling the lower() method on it.
Merge pull request #920 from wcerfgba/patch-1

Incorrect operation sequence in bzr-handling code
Fix pep8
install -d works on vcs links fix #798 fix #1060