You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/03/12 21:04:51 UTC

[10/50] [abbrv] git commit: [#2840] ticket:273 fixed errors

[#2840] ticket:273 fixed errors


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

Branch: refs/heads/si/5453
Commit: 584a9df397477ce196e062b7d7d331e3f90212bc
Parents: bb43fda
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Fri Mar 1 18:08:06 2013 +0400
Committer: Cory Johns <jo...@geek.net>
Committed: Mon Mar 11 22:29:45 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py            |   20 +++++--------
 Allura/allura/model/repository.py                  |   11 +++----
 Allura/allura/nf/allura/css/site_style.css         |    4 --
 Allura/allura/tasks/repo_tasks.py                  |    5 +--
 Allura/allura/templates/repo/tarball.html          |   23 +++++++--------
 Allura/allura/templates/repo/tree.html             |    4 +-
 Allura/allura/tests/test_tasks.py                  |    6 ++++
 Allura/development.ini                             |    4 +-
 Allura/test.ini                                    |    2 +-
 ForgeGit/forgegit/model/git_repo.py                |    2 +-
 .../forgegit/tests/functional/test_controllers.py  |    9 +++++-
 ForgeGit/forgegit/tests/model/test_repository.py   |    4 +--
 .../forgesvn/tests/functional/test_controllers.py  |    2 +-
 ForgeSVN/forgesvn/tests/model/test_repository.py   |    5 +--
 14 files changed, 48 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index f3ead26..9c63a65 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -33,7 +33,7 @@ from allura import model as M
 from allura.lib.widgets import form_fields as ffw
 from allura.controllers.base import DispatchIndex
 from allura.lib.diff import HtmlSideBySideDiff
-
+from paste.deploy.converters import asbool
 from .base import BaseController
 
 log = logging.getLogger(__name__)
@@ -427,22 +427,17 @@ class CommitBrowser(BaseController):
 
     @expose('jinja:allura:templates/repo/tarball.html')
     def tarball(self, **kw):
-        if tg.config.get('scm.repos.tarball.enable', 'false') != 'true':
+        if not asbool(tg.config.get('scm.repos.tarball.enable', False)):
             return
-        c.app.repo.set_tarball_status(self._revision, None)
-        shortname = c.app.repo.project.shortname
-        mount_point = c.app.repo.app.config.options.mount_point
-        filename = '%s-%s-%s.tar' % (shortname, mount_point, self._revision)
-        if (os.path.isfile(os.path.join(c.app.repo.tarball_path, filename)) and
-                (c.app.repo.get_tarball_status(self._revision) == 'ready')):
+        if (c.app.repo.get_tarball_status(self._revision) == 'ready'):
             redirect(c.app.repo.tarball_url(self._revision))
-        else:
+        elif (c.app.repo.get_tarball_status(self._revision) == None):
             allura.tasks.repo_tasks.tarball.post(revision=self._revision)
-        return dict(commit=self._commit)
+        return dict(commit=self._commit, revision=self._revision)
 
     @expose('json:')
     def tarball_status(self):
-        if tg.config.get('scm.repos.tarball.enable', 'false') != 'true':
+        if not asbool(tg.config.get('scm.repos.tarball.enable', False)):
             return
         return dict(status=c.app.repo.get_tarball_status(self._revision))
 
@@ -493,7 +488,8 @@ class TreeBrowser(BaseController, DispatchIndex):
             tree=self._tree,
             path=self._path,
             parent=self._parent,
-            tool_subscribed=tool_subscribed)
+            tool_subscribed=tool_subscribed,
+            tarball_enable = asbool(tg.config.get('scm.repos.tarball.enable', False)))
 
     @expose()
     def _lookup(self, next, *rest):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 19ec7cb..ce411a3 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -11,6 +11,7 @@ from hashlib import sha1
 from datetime import datetime
 from collections import defaultdict
 from itertools import izip
+from urlparse import urljoin
 
 import tg
 from paste.deploy.converters import asbool
@@ -242,21 +243,19 @@ class Repository(Artifact, ActivityObject):
         mount_point = c.app.repo.app.config.options.mount_point
         filename = '%s-%s-%s.tar' % (shortname, mount_point, revision)
         r = os.path.join(self.tool,self.project.url()[1:],self.name,filename)
-        return tg.config.get('scm.repos.tarball.url', '/') + r
+        return urljoin(tg.config.get('scm.repos.tarball.url_prefix', '/'), r)
 
     def get_tarball_status(self, revision):
         tarballs = dict((t.revision, t.status) for t in self.tarball_status)
-        if revision in tarballs.keys():
-            return tarballs[revision]
+        return tarballs.get(revision)
 
     def set_tarball_status(self, revision, status):
-        if self.get_tarball_status(revision):
             for tarball in self.tarball_status:
                 if tarball['revision'] == revision:
                     tarball['status'] = status
-        else:
+                    return
             self.tarball_status.append(dict(revision=revision, status=status))
-
+            session(self).flush(self)
 
     def __repr__(self): # pragma no cover
         return '<%s %s>' % (

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 10b13f3..1b28457 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2745,10 +2745,6 @@ h1.title .viewer:hover {
   padding-left: 33px;
 }
 
-#tarball_status h2 {
-    padding-left: 33px;
-}
-
 .neighborhood_feed_entry h3 {
   font-size: 1.1em;
 }

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/Allura/allura/tasks/repo_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/repo_tasks.py b/Allura/allura/tasks/repo_tasks.py
index 4d5047b..72ceb2c 100644
--- a/Allura/allura/tasks/repo_tasks.py
+++ b/Allura/allura/tasks/repo_tasks.py
@@ -105,16 +105,13 @@ def reclone_repo(*args, **kwargs):
 
 @task
 def tarball(revision=None):
-    from ming.orm import ThreadLocalORMSession
-
     log = logging.getLogger(__name__)
-    c.app.repo.set_tarball_status(revision, None)
     if revision:
         repo = c.app.repo
+        c.app.repo.set_tarball_status(revision, 'busy')
         try:
             repo.tarball(revision)
             c.app.repo.set_tarball_status(revision, 'ready')
-            ThreadLocalORMSession.flush_all()
         except:
             c.app.repo.set_tarball_status(revision, None)
             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)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/Allura/allura/templates/repo/tarball.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/tarball.html b/Allura/allura/templates/repo/tarball.html
index 72e482d..6aff982 100644
--- a/Allura/allura/templates/repo/tarball.html
+++ b/Allura/allura/templates/repo/tarball.html
@@ -1,7 +1,4 @@
 {% extends 'allura:templates/repo/repo_master.html' %}
-
-{% do g.register_forge_css('css/forge/diff.css') %}
-
 {% block title %}
 {{c.project.name}} / {{c.app.config.options.mount_label}} / Commit {{commit.shorthand_id()}}
 {% endblock %}
@@ -10,12 +7,6 @@
 Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(commit)}}
 {%- endblock %}
 
-{% block actions %}
-<a href="{{commit.url()}}log/">
-    <b data-icon="{{g.icons.history.char}}" class="ico {{g.icons.history.css}}" title="History"> </b> History
-</a>
-{% endblock %}
-
 {% block extra_js %}
 {{ super() }}
 <script type="text/javascript">(function() {
@@ -45,8 +36,8 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                     spinner.opts.speed = 0;
                     spinner.opts.opacity = 1;
                     spinner.spin(tarball_status);
-                    $('#tarball_status h2').html(' <a href="{{commit.url()}}tree">Click here to return to repository</a>');
-                    window.location.href = '{{c.app.repo.tarball_url(commit._id)}}';
+                    $('#tarball_status h2').html(' <a href="{{c.app.repo.tarball_url(revision)}}">Click here to download</a>');
+                    window.location.href = '{{c.app.repo.tarball_url(revision)}}';
                 }
             });
         }
@@ -59,6 +50,14 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
 
 {% block content %}
 <div id='tarball_status'>
-    <h2>Please wait..</h2>
+    <h2>Generating snapshot...</h2>
 </div>
 {% endblock %}
+
+{% block extra_css %}
+<style type="text/css">
+#tarball_status h2 {
+padding-left: 33px;
+}
+</style>
+{% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/Allura/allura/templates/repo/tree.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/tree.html b/Allura/allura/templates/repo/tree.html
index 83f6e6d..c71dc88 100644
--- a/Allura/allura/templates/repo/tree.html
+++ b/Allura/allura/templates/repo/tree.html
@@ -12,8 +12,8 @@ Tree <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(co
 {% endblock %}
 
 {% block actions %}
-{% if tg.config.get('scm.repos.tarball.enable', 'false')=='true' %}
-<a href="{{commit.url()}}tarball">Download tarball</a>
+{% if tarball_enable %}
+<a href="{{commit.url()}}tarball" rel="nofollow">Download tarball</a>
 {% endif %}
 
 <a href="{{commit.url()}}log/?path={{ path }}">

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 74a09d0..9e16bfb 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -38,6 +38,12 @@ class TestRepoTasks(unittest.TestCase):
         assert_equal(post_event.call_args[0][2], None)
         # ignore args[3] which is a traceback string
 
+    @mock.patch('allura.tasks.repo_tasks.c.app.repo.set_tarball_status')
+    def test_repo_tarball(self,st):
+        repo_tasks.tarball('HEAD')
+        calls = [mock.call('HEAD', 'busy'), mock.call('HEAD', 'ready')]
+        st.assert_has_calls(calls, any_order=True)
+
 
 class TestEventTasks(unittest.TestCase):
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index d468a8c..10d9cec 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -121,8 +121,8 @@ gitweb.cgi = /usr/lib/cgi-bin/gitweb.cgi
 
 scm.repos.root = /tmp
 scm.repos.tarball.enable = true
-scm.repos.tarball.root = /tmp/tarball
-scm.repos.tarball.url = http://localhost/tarball/
+scm.repos.tarball.root = /usr/share/nginx/www/
+scm.repos.tarball.url_prefix = http://localhost/
 
 trovecategories.enableediting = true
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/Allura/test.ini
----------------------------------------------------------------------
diff --git a/Allura/test.ini b/Allura/test.ini
index 9ee8420..d0bf796 100644
--- a/Allura/test.ini
+++ b/Allura/test.ini
@@ -83,7 +83,7 @@ scm.clone.svn = svn checkout --username=$username $source_url $dest_path
 scm.repos.root = /tmp
 scm.repos.tarball.enable = true
 scm.repos.tarball.root = /tmp/tarball
-scm.repos.tarball.url = file://
+scm.repos.tarball.url_prefix = file://
 
 #stats.sample_rate = 0
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 097630e..20b64c0 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -323,7 +323,7 @@ class GitImplementation(M.RepositoryImplementation):
         return tree._id
 
     def tarball(self, commit):
-        shortname = self._repo.project.shortname
+        shortname = self._repo.project.shortname.replace('/','-')
         mount_point = self._repo.app.config.options.mount_point
         if not os.path.exists(self._repo.tarball_path):
             os.makedirs(self._repo.tarball_path)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index ac1ddd1..71af94b 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -271,12 +271,19 @@ class TestRootController(_TestCase):
         r = self.app.get(ci + 'tree/')
         assert 'Download tarball' in r
         r = self.app.get(ci + 'tarball')
-        assert 'Please wait' in r
+        assert 'Generating snapshot...' in r
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
         r = self.app.get(ci + 'tarball_status')
         assert '{"status": "ready"}' in r
 
+    def test_tarball_status(self):
+        assert_equal(c.app.repo.get_tarball_status('1e146e67985dcd71c74de79613719bef7bddca4a'), None)
+        c.app.repo.set_tarball_status('1e146e67985dcd71c74de79613719bef7bddca4a', 'ready')
+        c.app.repo.set_tarball_status('df30427c488aeab84b2352bdf88a3b19223f9d7a', 'busy')
+        assert_equal(c.app.repo.get_tarball_status('1e146e67985dcd71c74de79613719bef7bddca4a'), 'ready')
+        assert_equal(c.app.repo.get_tarball_status('df30427c488aeab84b2352bdf88a3b19223f9d7a'), 'busy')
+
 
 class TestRestController(_TestCase):
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 496fa27..7cc830e 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -240,11 +240,9 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
 
     def test_tarball(self):
         assert_equal(self.repo.tarball_path, '/tmp/tarball/git/p/test/testgit.git')
-        assert_equal(self.repo.tarball_url('HEAD'), 'file://git/p/test/testgit.git/test-src-git-HEAD.tar')
+        assert_equal(self.repo.tarball_url('HEAD'), 'file:///git/p/test/testgit.git/test-src-git-HEAD.tar')
         self.repo.tarball('HEAD')
         assert os.path.isfile("/tmp/tarball/git/p/test/testgit.git/test-src-git-HEAD.tar")
-        self.repo.set_tarball_status('HEAD', 'ready')
-        assert_equal(self.repo.get_tarball_status('HEAD'), 'ready')
 
 
 class TestGitCommit(unittest.TestCase):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/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 35af593..302c890 100644
--- a/ForgeSVN/forgesvn/tests/functional/test_controllers.py
+++ b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
@@ -138,7 +138,7 @@ class TestRootController(SVNTestController):
         r = self.app.get('/src/3/tree/')
         assert 'Download tarball' in r
         r = self.app.get('/src/3/tarball')
-        assert 'Please wait' in r
+        assert 'Generating snapshot...' in r
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
         r = self.app.get('/src/3/tarball_status')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/584a9df3/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 e91c71e..f1eba67 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -267,12 +267,9 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
 
     def test_tarball(self):
         assert_equal(self.repo.tarball_path, '/tmp/tarball/svn/p/test/testsvn')
-        assert_equal(self.repo.tarball_url('1'), 'file://svn/p/test/testsvn/test-src-1.tar')
+        assert_equal(self.repo.tarball_url('1'), 'file:///svn/p/test/testsvn/test-src-1.tar')
         self.repo.tarball('1')
         assert os.path.isfile("/tmp/tarball/svn/p/test/testsvn/test-src-1.tar")
-        self.repo.set_tarball_status('1', 'ready')
-        assert_equal(self.repo.get_tarball_status('1'), 'ready')
-
 
 class TestSVNRev(unittest.TestCase):