allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject git commit: [#4961] WIP
Date Thu, 13 Dec 2012 21:01:29 GMT
Updated Branches:
  refs/heads/tv/4961 e9ba55415 -> ab0b66315


[#4961] WIP


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/ab0b6631
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ab0b6631
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ab0b6631

Branch: refs/heads/tv/4961
Commit: ab0b6631515adbe2166bc586f2f65c6b899bd977
Parents: e9ba554
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Thu Dec 13 21:01:13 2012 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Thu Dec 13 21:01:13 2012 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py                   |   37 ++++++++++-------
 ForgeSVN/forgesvn/tests/model/test_repository.py |    4 --
 2 files changed, 22 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ab0b6631/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index e1349c2..8f74d12 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -9,10 +9,10 @@ from subprocess import Popen, PIPE
 from hashlib import sha1
 from cStringIO import StringIO
 from datetime import datetime
-from glob import glob
 
 import tg
 import pysvn
+from paste.deploy.converters import asbool
 from pymongo.errors import DuplicateKeyError
 from pylons import tmpl_context as c, app_globals as g
 
@@ -22,7 +22,6 @@ from ming.utils import LazyProperty
 
 from allura import model as M
 from allura.lib import helpers as h
-from allura.model.repository import GitLikeTree
 from allura.model.auth import User
 from allura.lib.utils import svn_path_exists
 
@@ -155,6 +154,22 @@ class SVNImplementation(M.RepositoryImplementation):
             self._repo._impl._svn.checkin([fullname+'/tmp/trunk',fullname+'/tmp/tags',fullname+'/tmp/branches'],'Initial
commit')
             shutil.rmtree(fullname+'/tmp')
 
+    def can_hotcopy(self, source_url):
+        if not (asbool(tg.config.get('scm.svn.hotcopy', True)) and
+                source_url.startswith('file://')):
+            return False
+        stdout, stderr = self.check_call(['svn', '--version'])
+        return re.search('version 1.7', stdout):
+
+    def check_call(self, cmd):
+        p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
+        stdout, stderr = p.communicate(input='p\n')
+        if p.returncode != 0:
+            self._repo.status = 'ready'
+            session(self._repo).flush(self._repo)
+            raise SVNCalledProcessError(cmd, p.returncode, stdout, stderr)
+        return stdout, stderr
+
     def clone_from(self, source_url):
         '''Initialize a repo as a clone of another using svnsync'''
         self.init(default_dirs=False, skip_special_files=True)
@@ -166,36 +181,28 @@ class SVNImplementation(M.RepositoryImplementation):
                 fp.write('#!/bin/sh\n')
             os.chmod(fn, 0755)
 
-        def check_call(cmd):
-            p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
-            stdout, stderr = p.communicate(input='p\n')
-            if p.returncode != 0:
-                self._repo.status = 'ready'
-                session(self._repo).flush(self._repo)
-                raise SVNCalledProcessError(cmd, p.returncode, stdout, stderr)
-
         self._repo.status = 'importing'
         session(self._repo).flush(self._repo)
         log.info('Initialize %r as a clone of %s',
                  self._repo, source_url)
 
-        if source_url.startswith('file://'):
+        if self.can_hotcopy(source_url):
             # src repo is on the local filesystem - use hotcopy (faster)
             source_path, dest_path = source_url[7:], self._url[7:]
             fullname = os.path.join(self._repo.fs_path, self._repo.name)
             # hotcopy expects dest dir to not exist yet
             if os.path.exists(fullname):
                 shutil.rmtree(fullname)
-            check_call(['svnadmin', 'hotcopy', source_path, dest_path])
+            self.check_call(['svnadmin', 'hotcopy', source_path, dest_path])
             # make sure new repo has a pre-revprop-change hook,
             # otherwise the sync will fail
             set_hook('pre-revprop-change')
-            check_call(['svnsync', '--non-interactive', '--allow-non-empty',
+            self.check_call(['svnsync', '--non-interactive', '--allow-non-empty',
               'initialize', self._url, source_url])
         else:
             set_hook('pre-revprop-change')
-            check_call(['svnsync', 'init', self._url, source_url])
-            check_call(['svnsync', '--non-interactive', 'sync', self._url])
+            self.check_call(['svnsync', 'init', self._url, source_url])
+            self.check_call(['svnsync', '--non-interactive', 'sync', self._url])
 
         log.info('... %r cloned', self._repo)
         if not svn_path_exists("file://%s%s/%s" %

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ab0b6631/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index fd71837..e7dcfc0 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -134,8 +134,6 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         assert os.access('/tmp/testsvn/hooks/pre-revprop-change', os.X_OK)
         with open('/tmp/testsvn/hooks/pre-revprop-change') as f: c = f.read()
         self.assertEqual(c, '#!/bin/sh\n')
-        # assert not os.path.exists('/tmp/testsvn/hooks/post-revprop-change')
-        # assert not os.path.exists('/tmp/testsvn/hooks/post-commit-user')
         assert os.path.exists('/tmp/testsvn/hooks/post-commit')
         assert os.access('/tmp/testsvn/hooks/post-commit', os.X_OK)
         with open('/tmp/testsvn/hooks/post-commit') as f: c = f.read()
@@ -166,8 +164,6 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         assert os.access('/tmp/testsvn/hooks/pre-revprop-change', os.X_OK)
         with open('/tmp/testsvn/hooks/pre-revprop-change') as f: c = f.read()
         self.assertEqual(c, '#!/bin/sh\n')
-        # assert not os.path.exists('/tmp/testsvn/hooks/post-revprop-change')
-        # assert not os.path.exists('/tmp/testsvn/hooks/post-commit-user')
         assert os.path.exists('/tmp/testsvn/hooks/post-commit')
         assert os.access('/tmp/testsvn/hooks/post-commit', os.X_OK)
         with open('/tmp/testsvn/hooks/post-commit') as f: c = f.read()


Mime
View raw message