Make _get_subdirectory(), _get_svn_url_rev(), and _is_local_repository() class methods.

This commit is contained in:
Chris Jerdonek 2019-01-06 16:27:27 -08:00
parent 00ae3f594d
commit 41f058b4f5
3 changed files with 10 additions and 7 deletions

View File

@ -210,7 +210,8 @@ class VersionControl(object):
"""
return RevOptions(self, rev, extra_args=extra_args)
def _is_local_repository(self, repo):
@classmethod
def _is_local_repository(cls, repo):
# type: (str) -> bool
"""
posix absolute paths start with os.path.sep,

View File

@ -283,11 +283,12 @@ class Git(VersionControl):
)
return current_rev.strip()
def _get_subdirectory(self, location):
@classmethod
def _get_subdirectory(cls, location):
"""Return the relative path of setup.py to the git repo root."""
# find the repo root
git_dir = self.run_command(['rev-parse', '--git-dir'],
show_stdout=False, cwd=location).strip()
git_dir = cls.run_command(['rev-parse', '--git-dir'],
show_stdout=False, cwd=location).strip()
if not os.path.isabs(git_dir):
git_dir = os.path.join(location, git_dir)
root_dir = os.path.join(git_dir, '..')

View File

@ -136,10 +136,11 @@ class Subversion(VersionControl):
return self._get_svn_url_rev(location)[0]
def _get_svn_url_rev(self, location):
@classmethod
def _get_svn_url_rev(cls, location):
from pip._internal.exceptions import InstallationError
entries_path = os.path.join(location, self.dirname, 'entries')
entries_path = os.path.join(location, cls.dirname, 'entries')
if os.path.exists(entries_path):
with open(entries_path) as f:
data = f.read()
@ -162,7 +163,7 @@ class Subversion(VersionControl):
else:
try:
# subversion >= 1.7
xml = self.run_command(
xml = cls.run_command(
['info', '--xml', location],
show_stdout=False,
)