You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/04/01 23:10:39 UTC
[22/45] allura git commit: [#7857] initial contribution from David
Burley
[#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/a6b536c0
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/a6b536c0
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/a6b536c0
Branch: refs/heads/hss/7072
Commit: a6b536c0b89f734713ffa2febaa30863c0c78402
Parents: 1f1a2c5
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Mar 20 20:52:09 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Fri Mar 27 10:56:40 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/a6b536c0/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)