Skip to content

Commit

Permalink
Fixed issue #609 - method to detect VCS backend
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocerqueira committed Aug 14, 2012
1 parent 1749343 commit 3870f51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def from_dist(cls, dist, dependency_links, find_tags=False):
location = os.path.normcase(os.path.abspath(dist.location))
comments = []
from pip.vcs import vcs, get_src_requirement
if vcs.get_backend_name(location):
if vcs.get_backend_name(dist):
editable = True
try:
req = get_src_requirement(dist, location, find_tags)
Expand Down
11 changes: 6 additions & 5 deletions pip/vcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ def unregister(self, cls=None, name=None):
else:
logger.warn('Cannot unregister because no class or name given')

def get_backend_name(self, location):
def get_backend_name(self, dist):
"""
Return the name of the version control backend if found at given
location, e.g. vcs.get_backend_name('/path/to/vcs/checkout')
location, e.g. vcs.get_backend_name(dist)
"""
for vc_type in self._registry.values():
location = os.path.join(dist.location.split(dist.key)[0], dist.key)
path = os.path.join(location, vc_type.dirname)
if os.path.exists(path):
return vc_type.name
Expand All @@ -73,8 +74,8 @@ def get_backend(self, name):
if name in self._registry:
return self._registry[name]

def get_backend_from_location(self, location):
vc_type = self.get_backend_name(location)
def get_backend_from_location(self, dist):
vc_type = self.get_backend_name(dist)
if vc_type:
return self.get_backend(vc_type)
return None
Expand Down Expand Up @@ -244,7 +245,7 @@ def get_src_requirement(self, dist, location, find_tags=False):


def get_src_requirement(dist, location, find_tags):
version_control = vcs.get_backend_from_location(location)
version_control = vcs.get_backend_from_location(dist)
if version_control:
return version_control().get_src_requirement(dist, location, find_tags)
logger.warn('cannot determine version of editable source in %s (is not SVN checkout, Git clone, Mercurial clone or Bazaar branch)' % location)
Expand Down

0 comments on commit 3870f51

Please sign in to comment.