Commit 9e0db53e authored by Michal Čihař's avatar Michal Čihař

Support various VCS systems

This links VCS registry to the subproject model, so that it can choose
which VCS to use.

Issue #511
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 47a25466
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import weblate.trans.validators
class Migration(migrations.Migration):
dependencies = [
('trans', '0010_source_check_flags'),
]
operations = [
migrations.AddField(
model_name='subproject',
name='vcs',
field=models.CharField(default=b'git', help_text='Version control system to use to access your repository with translations.', max_length=20, verbose_name='Version control system', choices=[(b'git', b'Git'), (b'mercurial', b'Mercurial')]),
preserve_default=True,
),
migrations.AlterField(
model_name='source',
name='check_flags',
field=models.TextField(default=b'', blank=True, validators=[weblate.trans.validators.validate_check_flags]),
preserve_default=True,
),
]
......@@ -33,7 +33,7 @@ from weblate.trans.formats import FILE_FORMAT_CHOICES, FILE_FORMATS
from weblate.trans.mixins import PercentMixin, URLMixin, PathMixin
from weblate.trans.filelock import FileLock
from weblate.trans.util import is_repo_link, get_site_url, cleanup_repo_url
from weblate.trans.vcs import GitRepository, RepositoryException
from weblate.trans.vcs import RepositoryException, VCS_REGISTRY, VCS_CHOICES
from weblate.trans.models.translation import Translation
from weblate.trans.validators import (
validate_repoweb, validate_filemask,
......@@ -90,6 +90,16 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
'Project',
verbose_name=ugettext_lazy('Project'),
)
vcs = models.CharField(
verbose_name=ugettext_lazy('Version control system'),
max_length=20,
help_text=ugettext_lazy(
'Version control system to use to access your '
'repository with translations.'
),
choices=VCS_CHOICES,
default='git',
)
repo = models.CharField(
verbose_name=ugettext_lazy('Source code repository'),
max_length=200,
......@@ -461,7 +471,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
return self.linked_subproject.repository
if self._repository is None:
self._repository = GitRepository(self.get_path())
self._repository = VCS_REGISTRY[self.vcs](self.get_path())
return self._repository
......
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