You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2012/10/26 21:33:22 UTC

[18/26] git commit: [#4927] ticket:185 check the repo status and abort if it says it's refreshing

[#4927] ticket:185 check the repo status and abort if it says it's refreshing


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

Branch: refs/heads/cj/4942
Commit: d3b5142c81aa5e430588b4bd381c779471d26674
Parents: 0e48fcf
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Mon Oct 8 00:24:50 2012 +0300
Committer: Cory Johns <jo...@geek.net>
Committed: Mon Oct 15 20:23:07 2012 +0000

----------------------------------------------------------------------
 Allura/allura/tasks/repo_tasks.py      |   11 ++++++++++-
 Allura/allura/tests/model/test_repo.py |    5 +++++
 2 files changed, 15 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d3b5142c/Allura/allura/tasks/repo_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/repo_tasks.py b/Allura/allura/tasks/repo_tasks.py
index fe3db97..f7bb7aa 100644
--- a/Allura/allura/tasks/repo_tasks.py
+++ b/Allura/allura/tasks/repo_tasks.py
@@ -88,7 +88,16 @@ def reclone(*args, **kwargs):
 
 @task
 def refresh(**kwargs):
-    c.app.repo.refresh()
+    from allura import model as M
+    q = {
+        'task_name': 'allura.tasks.repo_tasks.refresh',
+        'state': 'busy'
+    }
+    refresh_tasks_count = M.MonQTask.query.find(q).count()
+    q['state'] = 'ready'
+    refresh_tasks_count += M.MonQTask.query.find(q).count()
+    if refresh_tasks_count == 0:
+        c.app.repo.refresh()
 
 @task
 def uninstall(**kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d3b5142c/Allura/allura/tests/model/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py
index 24b4800..56acdd9 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -204,6 +204,11 @@ class TestRepo(_TestWithRepo):
             self.repo.refresh()
             post_event.assert_called_with(
                     'repo_refreshed', commit_number=0, new=False)
+        with mock.patch('allura.model.repository.refresh') as refresh:
+            self.repo.refresh()
+            self.repo.refresh()
+            refresh.assert_called_once()
+            M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
         notifications = M.Notification.query.find().all()
         for n in notifications: