Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
8e897267
Commit
8e897267
authored
Nov 14, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share most of the code for is_supported for VCS
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
8564fb5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
32 deletions
+39
-32
weblate/trans/vcs.py
weblate/trans/vcs.py
+39
-32
No files found.
weblate/trans/vcs.py
View file @
8e897267
...
...
@@ -64,6 +64,12 @@ class Repository(object):
_cmd_push
=
None
_cmd_status
=
[
'status'
]
name
=
None
req_version
=
None
_is_supported
=
None
_version
=
None
def
__init__
(
self
,
path
):
self
.
path
=
path
self
.
last_output
=
''
...
...
@@ -221,14 +227,39 @@ class Repository(object):
"""
Checks whether this VCS backend is supported.
"""
if
cls
.
_is_supported
is
not
None
:
return
cls
.
_is_supported
try
:
cls
.
get_version
()
return
True
version
=
cls
.
get_version
()
except
OSError
:
cls
.
_is_supported
=
False
return
False
if
cls
.
req_version
is
None
:
cls
.
_is_supported
=
True
elif
LooseVersion
(
version
)
>=
cls
.
req_version
:
cls
.
_is_supported
=
True
else
:
cls
.
_is_supported
=
False
add_configuration_error
(
cls
.
name
.
lower
(),
'{0} version is too old, please upgrade to {1}.'
.
format
(
cls
.
name
,
cls
.
req_version
)
)
return
cls
.
_is_supported
@
classmethod
def
get_version
(
cls
):
"""
Cached getting of version.
"""
if
cls
.
_version
is
None
:
cls
.
_version
=
cls
.
_get_version
()
return
cls
.
_version
@
classmethod
def
_get_version
(
cls
):
"""
Returns VCS program version.
"""
...
...
@@ -295,6 +326,8 @@ class GitRepository(Repository):
]
_cmd_update_remote
=
[
'remote'
,
'update'
,
'origin'
]
_cmd_push
=
[
'push'
,
'origin'
]
name
=
'Git'
req_version
=
'1.6'
def
is_valid
(
self
):
'''
...
...
@@ -446,18 +479,7 @@ 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
):
def
_get_version
(
cls
):
"""
Returns VCS program version.
"""
...
...
@@ -564,6 +586,8 @@ class HgRepository(Repository):
]
_cmd_update_remote
=
[
'pull'
]
_cmd_push
=
[
'push'
]
name
=
'Mercurial'
req_version
=
'2.8'
VERSION_RE
=
re
.
compile
(
r'.*\
(
version ([^)]*)\
).*
')
...
...
@@ -759,24 +783,7 @@ 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()
if LooseVersion(version) >= '
3.8
':
return True
add_configuration_error(
'
mercurial
',
'
Mercurial
version
is
too
old
,
please
upgrade
to
2.8
.
'
)
return False
except OSError:
return False
@classmethod
def get_version(cls):
def _get_version(cls):
"""
Returns VCS program version.
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment