Commit efb61744 authored by Michal Čihař's avatar Michal Čihař

Add is_supported method to VCS backend

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent c0cb7581
......@@ -2,4 +2,4 @@
PyICU
pyLibravatar
babel
Mercurial
Mercurial>=2.8
......@@ -117,6 +117,9 @@ class VCSGitTest(RepoTestCase):
self.assertFalse(self.repo.needs_merge(self._branch))
self.assertFalse(self.repo.needs_push(self._branch))
def test_is_supported(self):
self.assertTrue(self._class.is_supported())
def test_get_version(self):
self.assertTrue(self._class.get_version() != '')
......
......@@ -26,6 +26,7 @@ import email.utils
import re
import ConfigParser
import hashlib
from distutils.version import LooseVersion
from dateutil import parser
from weblate.trans.util import get_clean_env
......@@ -215,6 +216,17 @@ class Repository(object):
"""
raise NotImplementedError()
@classmethod
def is_supported(cls):
"""
Checks whether this VCS backend is supported.
"""
try:
cls.get_version()
return True
except OSError:
return False
@classmethod
def get_version(cls):
"""
......@@ -433,6 +445,17 @@ class GitRepository(Repository):
"""
return self._log_revisions('origin/{0}..'.format(branch)) != ''
@classmethod
def is_supported(cls):
"""
Checks whether this VCS backend is supported.
"""
try:
version = cls.get_version()
return LooseVersion(version) >= '1.6'
except OSError:
return False
@classmethod
def get_version(cls):
"""
......@@ -735,6 +758,17 @@ class HgRepository(Repository):
"""
return self.execute(['log', '-r', 'not public()']) != ''
@classmethod
def is_supported(cls):
"""
Checks whether this VCS backend is supported.
"""
try:
version = cls.get_version()
return LooseVersion(version) >= '2.8'
except OSError:
return False
@classmethod
def get_version(cls):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment