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 2013/05/16 20:34:10 UTC

[1/6] git commit: [#6232] ticket:351 Use binary zip to generate svn snapshots

Updated Branches:
  refs/heads/master 8ae6a00e8 -> 69f660068


[#6232] ticket:351 Use binary zip to generate svn snapshots


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

Branch: refs/heads/master
Commit: 3944f9a7f89f7726dffa5855e617d4872ed74c91
Parents: 8791885
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed May 15 10:11:56 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 16 18:28:18 2013 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py                   |   11 ++---------
 ForgeSVN/forgesvn/tests/model/test_repository.py |    2 +-
 2 files changed, 3 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3944f9a7/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 2994aeb..07ffb9c 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -27,9 +27,7 @@ from hashlib import sha1
 from cStringIO import StringIO
 from datetime import datetime
 import tempfile
-import tarfile
 from shutil import rmtree
-from zipfile import ZipFile, ZIP_DEFLATED
 
 import tg
 import pysvn
@@ -44,6 +42,7 @@ from ming.utils import LazyProperty
 from allura import model as M
 from allura.lib import helpers as h
 from allura.model.auth import User
+from allura.model.repository import zip
 
 log = logging.getLogger(__name__)
 
@@ -650,13 +649,7 @@ class SVNImplementation(M.RepositoryImplementation):
             self._svn.export(self._url,
                              path,
                              revision=pysvn.Revision(pysvn.opt_revision_kind.number, commit))
-            with ZipFile(tmpfilename, 'w') as tarball_zip:
-               for root, dirs, files in os.walk(path):
-                    for name in files:
-                        file_to_zip = os.path.join(root, name)
-                        arcname = file_to_zip[len(os.path.dirname(path)):].strip('/')
-                        tarball_zip.write(file_to_zip, arcname, compress_type=ZIP_DEFLATED)
-
+            zip(path, tmpfilename)
             os.rename(tmpfilename, filename)
         finally:
             rmtree(path)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3944f9a7/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 820f493..164947b 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -294,7 +294,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         self.repo.tarball('1')
         assert os.path.isfile("/tmp/tarball/svn/t/te/test/testsvn/test-src-1.zip")
         tarball_zip = ZipFile('/tmp/tarball/svn/t/te/test/testsvn/test-src-1.zip', 'r')
-        assert_equal(tarball_zip.namelist(), ['test-src-1/README'])
+        assert_equal(tarball_zip.namelist(), ['test-src-1/', 'test-src-1/README'])
 
     def test_is_empty(self):
         assert not self.repo.is_empty()


[3/6] git commit: [#6232] ticket:351 zip helper

Posted by br...@apache.org.
[#6232] ticket:351 zip helper


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

Branch: refs/heads/master
Commit: 8791885e71b8fce23a26829c3739102c6e461dac
Parents: 2d6d698
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed May 15 09:37:58 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 16 18:28:18 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8791885e/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 53d166f..f760e3e 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -23,6 +23,7 @@ import mimetypes
 import logging
 import string
 import re
+from subprocess import Popen
 from difflib import SequenceMatcher
 from hashlib import sha1
 from datetime import datetime
@@ -1342,4 +1343,18 @@ def topological_sort(graph):
                 roots.append(child)
     assert not graph, 'Cycle detected'
 
+
+def zip(source, zipfile, exclude=None):
+    """Create zip archive using zip binary."""
+    zipbin = tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')
+    source = source.rstrip('/')
+    # this is needed to get proper prefixes inside zip-file
+    working_dir = os.path.dirname(source)
+    source_fn = os.path.basename(source)
+    command = [zipbin, '-r', zipfile, source_fn]
+    if exclude:
+        command += ['-x', exclude]
+    Popen(command, cwd=working_dir).communicate()
+
+
 Mapper.compile_all()


[6/6] git commit: [#6232] ticket:351 Unit test for `zipdir()`

Posted by br...@apache.org.
[#6232] ticket:351 Unit test for `zipdir()`


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

Branch: refs/heads/master
Commit: 69f660068043c2a2db8cf86aadf1014d9ea67943
Parents: 680be13
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed May 15 12:32:17 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 16 18:28:19 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/unit/test_repo.py |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/69f66006/Allura/allura/tests/unit/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_repo.py b/Allura/allura/tests/unit/test_repo.py
index 8fccc6a..5fb6590 100644
--- a/Allura/allura/tests/unit/test_repo.py
+++ b/Allura/allura/tests/unit/test_repo.py
@@ -24,6 +24,7 @@ from pylons import tmpl_context as c
 
 from allura import model as M
 from allura.controllers.repository import topo_sort
+from allura.model.repository import zipdir
 from alluratest.controller import setup_unit_test
 
 class TestCommitRunBuilder(unittest.TestCase):
@@ -285,3 +286,17 @@ class TestCommit(unittest.TestCase):
         commit.get_tree = Mock()
         tree = commit.tree
         commit.get_tree.assert_called_with(create=True)
+
+
+@patch('allura.model.repository.Popen')
+@patch('allura.model.repository.tg')
+def test_zipdir(tg, popen):
+    tg.config = {'scm.repos.tarball.zip_binary': '/bin/zip'}
+    src = '/fake/path/to/repo'
+    zipfile = '/fake/zip/file.tmp'
+    zipdir(src, zipfile)
+    popen.assert_called_once_with(['/bin/zip', '-r', zipfile, 'repo'], cwd='/fake/path/to')
+    popen.reset_mock()
+    src = '/fake/path/to/repo/'
+    zipdir(src, zipfile, exclude='file.txt')
+    popen.assert_called_once_with(['/bin/zip', '-r', zipfile, 'repo', '-x', 'file.txt'], cwd='/fake/path/to')


[4/6] git commit: [#6232] ticket:351 Rename zip helper to zipdir to avoid conflicts with built-in function

Posted by br...@apache.org.
[#6232] ticket:351 Rename zip helper to zipdir to avoid conflicts with built-in function


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

Branch: refs/heads/master
Commit: 4057fb352447518581e461da1cceaa9b8b8df65b
Parents: 3944f9a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed May 15 10:25:50 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 16 18:28:19 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py |    2 +-
 ForgeSVN/forgesvn/model/svn.py    |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4057fb35/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index f760e3e..37b95ab 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1344,7 +1344,7 @@ def topological_sort(graph):
     assert not graph, 'Cycle detected'
 
 
-def zip(source, zipfile, exclude=None):
+def zipdir(source, zipfile, exclude=None):
     """Create zip archive using zip binary."""
     zipbin = tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')
     source = source.rstrip('/')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4057fb35/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 07ffb9c..bc4da97 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -42,7 +42,7 @@ from ming.utils import LazyProperty
 from allura import model as M
 from allura.lib import helpers as h
 from allura.model.auth import User
-from allura.model.repository import zip
+from allura.model.repository import zipdir
 
 log = logging.getLogger(__name__)
 
@@ -649,7 +649,7 @@ class SVNImplementation(M.RepositoryImplementation):
             self._svn.export(self._url,
                              path,
                              revision=pysvn.Revision(pysvn.opt_revision_kind.number, commit))
-            zip(path, tmpfilename)
+            zipdir(path, tmpfilename)
             os.rename(tmpfilename, filename)
         finally:
             rmtree(path)


[2/6] git commit: [#6232] ticket:351 ini setting for zip binary path

Posted by br...@apache.org.
[#6232] ticket:351 ini setting for zip binary path


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

Branch: refs/heads/master
Commit: 2d6d69802b6ffdaed3fc52a705a504ffbaeb4d86
Parents: 8ae6a00
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed May 15 09:36:16 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 16 18:28:18 2013 +0000

----------------------------------------------------------------------
 Allura/development.ini |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2d6d6980/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index f485d17..cdde88e 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -139,6 +139,7 @@ scm.repos.root = /tmp
 scm.repos.tarball.enable = false
 scm.repos.tarball.root = /usr/share/nginx/www/
 scm.repos.tarball.url_prefix = http://localhost/
+scm.repos.tarball.zip_binary = /usr/bin/zip
 
 trovecategories.enableediting = true
 


[5/6] git commit: [#6232] ticket:351 Skip tarball test if zip binary isn't found

Posted by br...@apache.org.
[#6232] ticket:351 Skip tarball test if zip binary isn't found


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

Branch: refs/heads/master
Commit: 680be1349e2aa499f0f425383e3fae9d22207bff
Parents: 4057fb3
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed May 15 12:13:01 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 16 18:28:19 2013 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/tests/model/test_repository.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/680be134/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 164947b..fa4feb0 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -32,6 +32,7 @@ import ming
 from ming.base import Object
 from ming.orm import session, ThreadLocalORMSession
 from testfixtures import TempDirectory
+from IPython.testing.decorators import onlyif
 
 from alluratest.controller import setup_basic_test, setup_global_objects
 from allura import model as M
@@ -288,6 +289,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         ci = mock.Mock(_id='deadbeef:100')
         self.assertEqual(self.repo.count_revisions(ci), 100)
 
+    @onlyif(os.path.exists(tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')), 'zip binary is missing')
     def test_tarball(self):
         assert_equal(self.repo.tarball_path, '/tmp/tarball/svn/t/te/test/testsvn')
         assert_equal(self.repo.tarball_url('1'), 'file:///svn/t/te/test/testsvn/test-src-1.zip')