You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/03/23 18:06:03 UTC

[1/3] allura git commit: [#7857] initial contribution from David Burley

Repository: allura
Updated Branches:
  refs/heads/db/7857 [created] deabe7d34


[#7857] initial contribution from David Burley


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

Branch: refs/heads/db/7857
Commit: a2dd744063d9a4d8438165e8939fc0fe5be1fe87
Parents: e146bbe
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Mar 20 20:52:09 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 20:52:09 2015 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/a2dd7440/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 92dc292..c5643e1 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -21,6 +21,7 @@ import shutil
 import string
 import logging
 import subprocess
+import time
 from subprocess import Popen, PIPE
 from hashlib import sha1
 from cStringIO import StringIO
@@ -226,7 +227,7 @@ class SVNImplementation(M.RepositoryImplementation):
                 source_url.startswith('file://')):
             return False
         # check for svn version 1.7 or later
-        stdout, stderr = self.check_call(['svn', '--version'])
+        stdout, stderr, returncode = self.check_call(['svn', '--version'])
         pattern = r'version (?P<maj>\d+)\.(?P<min>\d+)'
         m = re.search(pattern, stdout)
         return m and (int(m.group('maj')) * 10 + int(m.group('min'))) >= 17
@@ -237,7 +238,7 @@ class SVNImplementation(M.RepositoryImplementation):
         if p.returncode != 0:
             self._repo.set_status('ready')
             raise SVNCalledProcessError(cmd, p.returncode, stdout, stderr)
-        return stdout, stderr
+        return stdout, stderr, p.returncode
 
     def clone_from(self, source_url):
         '''Initialize a repo as a clone of another using svnsync'''
@@ -276,10 +277,25 @@ class SVNImplementation(M.RepositoryImplementation):
                  'initialize', self._url, source_url])
             clear_hook('pre-revprop-change')
         else:
+            # retry logic
+            max_fail = 60
+            fail_count = 0
+            returncode = -1
             set_hook('pre-revprop-change')
-            self.check_call(['svnsync', 'init', self._url, source_url])
-            self.check_call(
-                ['svnsync', '--non-interactive', 'sync', self._url])
+            while returncode != 0 && fail_count < max_fail:
+                stdout, stderr, returncode = self.check_call(['svnsync', 'init', self._url, source_url])
+                # Sleep for 10s and bump the fail counter if svnsync didn't run clean
+                if returncode != 0:
+                    time.sleep(10)
+                    fail_count++
+            # Reset the return code to non-zero for next command interation, but reuse the fail counter
+            returncode = -1
+            while returncode != 0 && fail_count < max_fail:
+                stdout, stderr, returncode = self.check_call(
+                    ['svnsync', '--non-interactive', 'sync', self._url])
+                if returncode != 0:
+                    time.sleep(10)
+                    fail_count++
             clear_hook('pre-revprop-change')
 
         log.info('... %r cloned', self._repo)


[2/3] allura git commit: [#7857] syntax fixes

Posted by br...@apache.org.
[#7857] syntax fixes


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

Branch: refs/heads/db/7857
Commit: 295d1ee569a174ae51f8ed6efd2f600e7ffbced8
Parents: a2dd744
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Mar 20 20:53:52 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 20:53:52 2015 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/295d1ee5/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index c5643e1..94d29b0 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -282,20 +282,20 @@ class SVNImplementation(M.RepositoryImplementation):
             fail_count = 0
             returncode = -1
             set_hook('pre-revprop-change')
-            while returncode != 0 && fail_count < max_fail:
+            while returncode != 0 and fail_count < max_fail:
                 stdout, stderr, returncode = self.check_call(['svnsync', 'init', self._url, source_url])
                 # Sleep for 10s and bump the fail counter if svnsync didn't run clean
                 if returncode != 0:
                     time.sleep(10)
-                    fail_count++
+                    fail_count += 1
             # Reset the return code to non-zero for next command interation, but reuse the fail counter
             returncode = -1
-            while returncode != 0 && fail_count < max_fail:
+            while returncode != 0 and fail_count < max_fail:
                 stdout, stderr, returncode = self.check_call(
                     ['svnsync', '--non-interactive', 'sync', self._url])
                 if returncode != 0:
                     time.sleep(10)
-                    fail_count++
+                    fail_count += 1
             clear_hook('pre-revprop-change')
 
         log.info('... %r cloned', self._repo)


[3/3] allura git commit: [#7857] test fix, improve error handling and logging

Posted by br...@apache.org.
[#7857] test fix, improve error handling and logging


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

Branch: refs/heads/db/7857
Commit: deabe7d34e9b98bc3be854004aecf690122910c0
Parents: 295d1ee
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Mar 20 21:57:59 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 21:57:59 2015 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/deabe7d3/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 94d29b0..44d625f 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -31,7 +31,7 @@ from shutil import rmtree
 
 import tg
 import pysvn
-from paste.deploy.converters import asbool
+from paste.deploy.converters import asbool, asint
 from pymongo.errors import DuplicateKeyError
 from pylons import tmpl_context as c, app_globals as g
 
@@ -232,10 +232,10 @@ class SVNImplementation(M.RepositoryImplementation):
         m = re.search(pattern, stdout)
         return m and (int(m.group('maj')) * 10 + int(m.group('min'))) >= 17
 
-    def check_call(self, cmd):
+    def check_call(self, cmd, fail_on_error=True):
         p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
         stdout, stderr = p.communicate(input='p\n')
-        if p.returncode != 0:
+        if p.returncode != 0 and fail_on_error:
             self._repo.set_status('ready')
             raise SVNCalledProcessError(cmd, p.returncode, stdout, stderr)
         return stdout, stderr, p.returncode
@@ -277,25 +277,21 @@ class SVNImplementation(M.RepositoryImplementation):
                  'initialize', self._url, source_url])
             clear_hook('pre-revprop-change')
         else:
-            # retry logic
-            max_fail = 60
-            fail_count = 0
-            returncode = -1
+            def retry_cmd(cmd, fail_count=0):
+                max_fail = asint(tg.config.get('scm.import.retry_count', 50))
+                returncode = -1
+                while returncode != 0 and fail_count < max_fail:
+                    stdout, stderr, returncode = self.check_call(cmd, fail_on_error=False)
+                    if returncode != 0:
+                        fail_count += 1
+                        log.info('Attempt %s.  Error running %s Details:\n%s', fail_count, cmd, stderr)
+                        time.sleep(asint(tg.config.get('scm.import.retry_sleep_secs', 5)))
+                    if fail_count == max_fail:
+                        raise SVNCalledProcessError(cmd, returncode, stdout, stderr)
+                return fail_count
             set_hook('pre-revprop-change')
-            while returncode != 0 and fail_count < max_fail:
-                stdout, stderr, returncode = self.check_call(['svnsync', 'init', self._url, source_url])
-                # Sleep for 10s and bump the fail counter if svnsync didn't run clean
-                if returncode != 0:
-                    time.sleep(10)
-                    fail_count += 1
-            # Reset the return code to non-zero for next command interation, but reuse the fail counter
-            returncode = -1
-            while returncode != 0 and fail_count < max_fail:
-                stdout, stderr, returncode = self.check_call(
-                    ['svnsync', '--non-interactive', 'sync', self._url])
-                if returncode != 0:
-                    time.sleep(10)
-                    fail_count += 1
+            fail_count = retry_cmd(['svnsync', 'init', self._url, source_url])
+            fail_count = retry_cmd(['svnsync', '--non-interactive', 'sync', self._url], fail_count=fail_count)
             clear_hook('pre-revprop-change')
 
         log.info('... %r cloned', self._repo)

http://git-wip-us.apache.org/repos/asf/allura/blob/deabe7d3/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 eb952e1..7f34f45 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -195,7 +195,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
             source_url = combo[0]
             tg.config = {'scm.svn.hotcopy': combo[1]}
             stdout = combo[2]
-            obj.check_call.return_value = stdout, ''
+            obj.check_call.return_value = stdout, '', 0
             expected = (source_url.startswith('file://') and
                         tg.config['scm.svn.hotcopy'] and
                         stdout != 'version 1.6')