Repository: WeblateOrg/weblate

Issue:
Add SVN support
Adding SVN support should be quite easy when using git-svn, basically just push, rebase and pull need to be adjusted, rest works same as git. This backend would obviously loose authorship, so it might be good idea to add author to commit message.



Discussion:
You may want to consider the following git-svn options to track authorship:

--use-log-author
  When retrieving svn commits into git (as part of fetch, rebase, or dcommit operations), look for the
  first From: or Signed-off-by: line in the log message and use that as the author string.

--add-author-from
  When committing to svn from git (as part of commit or dcommit operations), if the existing log
  message doesn’t already have a From: or Signed-off-by: line, append a From:
  line based on the git commit’s author string. If you use this, then --use-log-author will retrieve a valid 
  author string for all commits.

Any evolution on this ?
We would like to use Weblate for the translation of @Piwigo project and its plugins but most plugins are hosted on our Subversion repository.

AFAIK currently nobody is working on this.

Can you point me out where VCS are managed ?
I like to take a look if I can add basic support

It's here: https://github.com/nijel/weblate/blob/master/weblate/trans/vcs.py

I don't have patience to work with Python. It would be great if you could do it someday.

I am starting on this.

See https://github.com/nijel/weblate/pull/1171


Resolving patch:
diff --git a/weblate/trans/vcs.py b/weblate/trans/vcs.py
--- a/weblate/trans/vcs.py
+++ b/weblate/trans/vcs.py
@@ -675,6 +675,66 @@ def push(self):
             raise
 
 
+@register_vcs
+class SubversionWithGitSvnRepository(GitRepository):
+
+    name = 'Subversion (git-svn)'
+
+    _cmd_update_remote = ['svn', 'fetch']
+    _cmd_push = ['svn', 'dcommit']
+
+    def configure_remote(self, pull_url, push_url, branch):
+        '''
+        Initializes the git-svn repository.
+        '''
+        try:
+            self.get_config('svn-remote.svn.url')
+        except subprocess.CalledProcessError:
+            self.execute(['svn', 'init', '-s',
+                          '--prefix=origin/',
+                          pull_url, self.path])
+
+    @classmethod
+    def clone(cls, source, target, branch=None, bare=False):
+        """
+        Clones svn repository with git-svn and returns
+        Repository object for cloned repository.
+        """
+        clone_command = ['svn', 'clone', source, target]
+        cls.execute(clone_command)
+        return cls(target, branch)
+
+    def merge(self, abort=False):
+        """
+        Rebases. Git-svn does not support merge.
+        """
+        self.rebase(abort)
+
+    def rebase(self, abort=False):
+        """
+        Rebases remote branch or reverts the rebase.
+        Git-svn does not support merge.
+        """
+        if abort:
+            pass
+        else:
+            self.execute(['svn', 'rebase'])
+
+    # @property
+    # def last_remote_revision(self):
+    #     '''
+    #     Returns last remote revision.
+    #     '''
+    #     if self._last_remote_revision is None:
+    #         _svn_log = self.execute(
+    #             ['svn', 'log', '-n', '1', '@{upstream}']
+    #         )
+    #         _revision_line = _svn_log.split('\n')[1]
+    #         self._last_remote_revision = \
+    #             re.search('^r(\d+)', _revision_line).group(1)
+    #     return self._last_remote_revision
+
+
 @register_vcs
 class GithubRepository(GitRepository):
 


Test patch:
diff --git a/weblate/trans/tests/test_vcs.py b/weblate/trans/tests/test_vcs.py
--- a/weblate/trans/tests/test_vcs.py
+++ b/weblate/trans/tests/test_vcs.py
@@ -40,6 +40,11 @@ class GithubFakeRepository(GithubRepository):
     _cmd = get_test_file('hub')
 
 
+class GitSvnFakeRepository(GitRepository):
+    _is_supported = None
+    _version = None
+
+
 class GitTestRepository(GitRepository):
     _is_supported = None
     _version = None
@@ -383,6 +388,11 @@ class VCSGithubTest(VCSGitTest):
     _vcs = 'git'
 
 
+class VCSSubversionTest(VCSGitTest):
+    _class = GitSvnFakeRepository
+    _vcs = 'git'
+
+
 class VCSHgTest(VCSGitTest):
     """
     Mercurial repository testing.