incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [09/38] git commit: [#6235] ticket:352 Pass path to the snapshot task
Date Mon, 03 Jun 2013 19:19:08 GMT
[#6235] ticket:352 Pass path to the snapshot task


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

Branch: refs/heads/cj/6218
Commit: 20be6df0394588f830731b776b25f9f480775bce
Parents: 43364b2
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri May 17 15:28:06 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri May 31 22:14:07 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py            |    9 +-
 Allura/allura/model/repository.py                  |    3 -
 Allura/allura/tasks/repo_tasks.py                  |    6 +-
 Allura/allura/templates/repo/tree.html             |    4 +-
 ForgeSVN/forgesvn/model/svn.py                     |    6 ++
 .../forgesvn/tests/functional/test_controllers.py  |   60 +++++++++++++++
 6 files changed, 76 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/20be6df0/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 6967685..a8f8c68 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -452,20 +452,21 @@ class CommitBrowser(BaseController):
 
     @expose('jinja:allura:templates/repo/tarball.html')
     def tarball(self, **kw):
+        path = kw.pop('path', None)
         if not asbool(tg.config.get('scm.repos.tarball.enable', False)):
             raise exc.HTTPNotFound()
         rev = self._commit.url().split('/')[-2]
-        status = c.app.repo.get_tarball_status(rev)
+        status = c.app.repo.get_tarball_status(rev, path)
         if status is None:
-            allura.tasks.repo_tasks.tarball.post(revision=rev)
+            allura.tasks.repo_tasks.tarball.post(revision=rev, path=path)
         return dict(commit=self._commit, revision=rev, status=status)
 
     @expose('json:')
-    def tarball_status(self):
+    def tarball_status(self, path=None, **kw):
         if not asbool(tg.config.get('scm.repos.tarball.enable', False)):
             raise exc.HTTPNotFound()
         rev = self._commit.url().split('/')[-2]
-        return dict(status=c.app.repo.get_tarball_status(rev))
+        return dict(status=c.app.repo.get_tarball_status(rev, path))
 
 
     @expose('jinja:allura:templates/repo/log.html')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/20be6df0/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index b728987..65ac0a2 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -270,9 +270,6 @@ class Repository(Artifact, ActivityObject):
         shortname = c.project.shortname.replace('/', '-')
         mount_point = c.app.config.options.mount_point
         filename = '%s-%s-%s' % (shortname, mount_point, revision)
-        if path:
-            path = path.strip('/')
-            filename += '-' + '-'.join(path.split('/'))
         return filename
 
     def tarball_url(self, revision):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/20be6df0/Allura/allura/tasks/repo_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/repo_tasks.py b/Allura/allura/tasks/repo_tasks.py
index 837c686..95d7052 100644
--- a/Allura/allura/tasks/repo_tasks.py
+++ b/Allura/allura/tasks/repo_tasks.py
@@ -120,17 +120,17 @@ def reclone_repo(*args, **kwargs):
         g.post_event('repo_clone_task_failed', source_url, source_path, traceback.format_exc())
 
 @task
-def tarball(revision=None):
+def tarball(revision=None, path=None):
     log = logging.getLogger(__name__)
     if revision:
         repo = c.app.repo
-        status = repo.get_tarball_status(revision)
+        status = repo.get_tarball_status(revision, path)
         if status:
             log.info('Skipping tarball for repository %s:%s rev %s because it is already
%s' %
                      (c.project.shortname, c.app.config.options.mount_point, revision, status))
         else:
             try:
-                repo.tarball(revision)
+                repo.tarball(revision, path)
             except:
                 log.error('Could not create tarball for repository %s:%s revision %s' % (c.project.shortname,
c.app.config.options.mount_point, revision), exc_info=True)
     else:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/20be6df0/Allura/allura/templates/repo/tree.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/tree.html b/Allura/allura/templates/repo/tree.html
index 740ed04..b2dbcfe 100644
--- a/Allura/allura/templates/repo/tree.html
+++ b/Allura/allura/templates/repo/tree.html
@@ -31,8 +31,8 @@ Tree <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a>
{{commit_labels(co
 
 {% block actions %}
 {% if tarball_url %}
-    <a href="{{tarball_url}}" rel="nofollow">
-        <b data-icon="{{g.icons.folder.char}}" class="ico {{g.icons.folder.css}}" title="Snapshot">
</b> Download Snapshot
+<a href="{{ tarball_url + ('?path=' + path if path else '') }}" rel="nofollow">
+    <b data-icon="{{g.icons.folder.char}}" class="ico {{g.icons.folder.css}}" title="Snapshot">
</b> Download Snapshot
 </a>
 {% endif %}
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/20be6df0/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 8c65f78..363dd27 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -101,6 +101,12 @@ class Repository(M.Repository):
         if not self.heads: return None
         return self._impl.commit(self.heads[0].object_id)
 
+    def tarball_filename(self, revision, path=None):
+        fn =  super(Repository, self).tarball_filename(revision, path)
+        path = self._impl._path_to_root(path, revision)
+        fn += '-' + '-'.join(path.split('/'))
+        return fn
+
 
 class SVNCalledProcessError(Exception):
     def __init__(self, cmd, returncode, stdout, stderr):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/20be6df0/ForgeSVN/forgesvn/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/functional/test_controllers.py b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
index 46a42e3..5a69ee6 100644
--- a/ForgeSVN/forgesvn/tests/functional/test_controllers.py
+++ b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
@@ -16,6 +16,7 @@
 #       under the License.
 
 import json
+import shutil
 
 import pkg_resources
 from pylons import tmpl_context as c
@@ -26,6 +27,7 @@ from allura import model as M
 from allura.lib import helpers as h
 from alluratest.controller import TestController
 from forgesvn.tests import with_svn
+from allura.tests.decorators import with_tool
 
 class SVNTestController(TestController):
     def setUp(self):
@@ -33,6 +35,7 @@ class SVNTestController(TestController):
         self.setup_with_tools()
 
     @with_svn
+    @with_tool('test', 'SVN', 'svn-tags', 'SVN with tags')
     def setup_with_tools(self):
         h.set_context('test', 'src', neighborhood='Projects')
         repo_dir = pkg_resources.resource_filename(
@@ -46,6 +49,13 @@ class SVNTestController(TestController):
         c.app.repo.refresh()
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
+        h.set_context('test', 'svn-tags', neighborhood='Projects')
+        c.app.repo.fs_path = repo_dir
+        c.app.repo.status = 'ready'
+        c.app.repo.name = 'testsvn-trunk-tags-branches'
+        c.app.repo.refresh()
+        ThreadLocalORMSession.flush_all()
+        ThreadLocalORMSession.close_all()
         h.set_context('test', 'src', neighborhood='Projects')
 
 
@@ -185,6 +195,56 @@ class TestRootController(SVNTestController):
         r = self.app.get('/src/3/tarball_status')
         assert '{"status": "ready"}' in r
 
+    def test_tarball_tags_aware(self):
+        h.set_context('test', 'svn-tags', neighborhood='Projects')
+        shutil.rmtree(c.app.repo.tarball_path, ignore_errors=True)
+        r = self.app.get('/svn-tags/19/tree/')
+        link = r.html.find('h2', attrs={'class': 'dark title'})
+        link = link.find('small').findAll('a')[0]
+        assert_equal(link.text, 'Download Snapshot')
+        assert_equal(link.get('href'), '/p/test/svn-tags/19/tarball')
+
+        r = self.app.get('/svn-tags/19/tree/tags/tag-1.0/')
+        link = r.html.find('h2', attrs={'class': 'dark title'})
+        link = link.find('small').findAll('a')[0]
+        assert_equal(link.text, 'Download Snapshot')
+        assert_equal(link.get('href'), '/p/test/svn-tags/19/tarball?path=/tags/tag-1.0')
+
+        r = self.app.get('/svn-tags/19/tarball_status?path=/tags/tag-1.0')
+        assert_equal(r.json['status'], None)
+        r = self.app.get(link.get('href'))
+        assert 'Generating snapshot...' in r
+        M.MonQTask.run_ready()
+        r = self.app.get('/svn-tags/19/tarball_status?path=/tags/tag-1.0')
+        assert_equal(r.json['status'], 'ready')
+
+        r = self.app.get('/svn-tags/19/tarball_status?path=/trunk')
+        assert_equal(r.json['status'], None)
+        r = self.app.get('/svn-tags/19/tarball?path=/trunk/')
+        assert 'Generating snapshot...' in r
+        M.MonQTask.run_ready()
+        r = self.app.get('/svn-tags/19/tarball_status?path=/trunk')
+        assert_equal(r.json['status'], 'ready')
+
+        r = self.app.get('/svn-tags/19/tarball_status?path=/branches/aaa/')
+        assert_equal(r.json['status'], None)
+
+        # All of the following also should be ready because...
+        # ...this is essentially the same as trunk snapshot
+        r = self.app.get('/svn-tags/19/tarball_status?path=/trunk/some/path/')
+        assert_equal(r.json['status'], 'ready')
+        r = self.app.get('/svn-tags/19/tarball_status')
+        assert_equal(r.json['status'], 'ready')
+        # ...the same as trunk, 'cause concrete tag isn't specified
+        r = self.app.get('/svn-tags/19/tarball_status?path=/tags/')
+        assert_equal(r.json['status'], 'ready')
+        # ...the same as trunk, 'cause concrete branch isn't specified
+        r = self.app.get('/svn-tags/19/tarball_status?path=/branches/')
+        assert_equal(r.json['status'], 'ready')
+        # ...this is essentially the same as tag snapshot
+        r = self.app.get('/svn-tags/19/tarball_status?path=/tags/tag-1.0/dir')
+        assert_equal(r.json['status'], 'ready')
+
 
 class TestImportController(SVNTestController):
     def test_index(self):


Mime
View raw message