From 2f16b88fb39e2ac269262b804aa2ce2cbeb91421 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Wed, 10 Oct 2018 02:16:00 -0700 Subject: [PATCH] Refactor away VcsSupport.get_backend_from_location(). --- news/D9A540D9-7665-48A5-A1C8-5141ED49E404.trivial | 0 src/pip/_internal/operations/freeze.py | 10 ++++++++-- src/pip/_internal/vcs/__init__.py | 10 ++-------- 3 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 news/D9A540D9-7665-48A5-A1C8-5141ED49E404.trivial diff --git a/news/D9A540D9-7665-48A5-A1C8-5141ED49E404.trivial b/news/D9A540D9-7665-48A5-A1C8-5141ED49E404.trivial new file mode 100644 index 000000000..e69de29bb diff --git a/src/pip/_internal/operations/freeze.py b/src/pip/_internal/operations/freeze.py index b173875bf..3911a0fcc 100644 --- a/src/pip/_internal/operations/freeze.py +++ b/src/pip/_internal/operations/freeze.py @@ -173,12 +173,18 @@ class FrozenRequirement(object): """ location = os.path.normcase(os.path.abspath(dist.location)) from pip._internal.vcs import vcs, get_src_requirement - if not dist_is_editable(dist) or not vcs.get_backend_name(location): + if not dist_is_editable(dist): + req = dist.as_requirement() + return (req, False, []) + + vc_name = vcs.get_backend_name(location) + + if not vc_name: req = dist.as_requirement() return (req, False, []) try: - req = get_src_requirement(dist, location) + req = get_src_requirement(vc_name, dist, location) except InstallationError as exc: logger.warning( "Error when trying to get requirement for VCS system %s, " diff --git a/src/pip/_internal/vcs/__init__.py b/src/pip/_internal/vcs/__init__.py index 794b35d65..4249a7c0e 100644 --- a/src/pip/_internal/vcs/__init__.py +++ b/src/pip/_internal/vcs/__init__.py @@ -150,12 +150,6 @@ class VcsSupport(object): 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() @@ -487,8 +481,8 @@ class VersionControl(object): return cls.is_repository_directory(location) -def get_src_requirement(dist, location): - version_control = vcs.get_backend_from_location(location) +def get_src_requirement(vc_name, dist, location): + version_control = vcs.get_backend(vc_name) if version_control: try: return version_control().get_src_requirement(dist,