incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [3/3] git commit: [#4691] Changed refresh-last-commits.py to mark repo as analyzing and post refresh for new commits when done
Date Wed, 06 Feb 2013 19:35:19 GMT
Updated Branches:
  refs/heads/master b67150660 -> e096621af


[#4691] Changed refresh-last-commits.py to mark repo as analyzing and post refresh for new
commits when done

Signed-off-by: Cory Johns <johnsca@geek.net>


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

Branch: refs/heads/master
Commit: e096621afe4caf9aed533dc7c8ca1cd725e938a1
Parents: 0a93358
Author: Cory Johns <johnsca@geek.net>
Authored: Wed Feb 6 17:25:47 2013 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Wed Feb 6 19:23:51 2013 +0000

----------------------------------------------------------------------
 scripts/refresh-last-commits.py |   35 +++++++++++++++++++++------------
 1 files changed, 22 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e096621a/scripts/refresh-last-commits.py
----------------------------------------------------------------------
diff --git a/scripts/refresh-last-commits.py b/scripts/refresh-last-commits.py
index a23f582..e3b643f 100644
--- a/scripts/refresh-last-commits.py
+++ b/scripts/refresh-last-commits.py
@@ -8,10 +8,11 @@ from contextlib import contextmanager
 
 import faulthandler
 from pylons import c
-from ming.orm import ThreadLocalORMSession
+from ming.orm import ThreadLocalORMSession, session
 
 from allura import model as M
 from allura.lib.utils import chunked_find, chunked_list
+from allura.tasks.repo_tasks import refresh
 
 log = logging.getLogger(__name__)
 
@@ -50,20 +51,22 @@ def main(options):
                             c.app.repo.tool.lower())
                     continue
 
-                ci_ids = list(reversed(list(c.app.repo.all_commit_ids())))
-                if options.clean:
-                    if options.diffs:
-                        # delete DiffInfoDocs
-                        i = M.repo.DiffInfoDoc.m.find(dict(commit_ids={'$in': ci_ids})).count()
-                        log.info("Deleting %i DiffInfoDoc docs, by repo id...", i)
+                c.app.repo.status = 'analyzing'
+                session(c.app.repo).flush(c.app.repo)
+                try:
+                    ci_ids = list(reversed(list(c.app.repo.all_commit_ids())))
+                    if options.clean:
+                        if options.diffs:
+                            # delete DiffInfoDocs
+                            i = M.repo.DiffInfoDoc.m.find(dict(commit_ids={'$in': ci_ids})).count()
+                            log.info("Deleting %i DiffInfoDoc docs, by repo id...", i)
+                            M.repo.LastCommitDoc.m.remove(dict(commit_ids={'$in': ci_ids}))
+
+                        # delete LastCommitDocs
+                        i = M.repo.LastCommitDoc.m.find(dict(commit_ids={'$in': ci_ids})).count()
+                        log.info("Deleting %i LastCommitDoc docs, by repo id...", i)
                         M.repo.LastCommitDoc.m.remove(dict(commit_ids={'$in': ci_ids}))
 
-                    # delete LastCommitDocs
-                    i = M.repo.LastCommitDoc.m.find(dict(commit_ids={'$in': ci_ids})).count()
-                    log.info("Deleting %i LastCommitDoc docs, by repo id...", i)
-                    M.repo.LastCommitDoc.m.remove(dict(commit_ids={'$in': ci_ids}))
-
-                try:
                     log.info('Refreshing all last commits in %r', c.app.repo)
                     if options.profile:
                         import cProfile
@@ -71,9 +74,15 @@ def main(options):
                                 globals(), locals(), '/tmp/refresh_lcds.profile')
                     else:
                         refresh_repo_lcds(ci_ids, options)
+                    new_commit_ids = app.repo.unknown_commit_ids()
+                    if len(new_commit_ids) > 0:
+                        refresh.post()
                 except:
                     log.exception('Error refreshing %r', c.app.repo)
                     raise
+                finally:
+                    c.app.repo.status = 'ready'
+                    session(c.app.repo).flush(c.app.repo)
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
 


Mime
View raw message