incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/2] git commit: [#5703] re-apply LCD changes to refresh core logic
Date Wed, 13 Feb 2013 17:24:00 GMT
Updated Branches:
  refs/heads/db/5703 [created] 224d54cbe


[#5703] re-apply LCD changes to refresh core logic


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

Branch: refs/heads/db/5703
Commit: 224d54cbe6a9664658f5617aa83a7f8879478e13
Parents: 05012ca
Author: Dave Brondsema <dbrondsema@geek.net>
Authored: Wed Feb 13 17:23:48 2013 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Wed Feb 13 17:23:48 2013 +0000

----------------------------------------------------------------------
 Allura/allura/scripts/refreshrepo.py |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/224d54cb/Allura/allura/scripts/refreshrepo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/refreshrepo.py b/Allura/allura/scripts/refreshrepo.py
index 09b6242..e7a5110 100644
--- a/Allura/allura/scripts/refreshrepo.py
+++ b/Allura/allura/scripts/refreshrepo.py
@@ -20,7 +20,7 @@ class RefreshRepo(ScriptTask):
         if options.nbhd:
             nbhd = M.Neighborhood.query.get(url_prefix=options.nbhd)
             if not nbhd:
-                raise AttributeError("Invalid neighborhood url prefix.")
+                return "Invalid neighborhood url prefix."
             q_project['neighborhood_id'] = nbhd._id
         if options.project:
             q_project['shortname'] = options.project
@@ -28,6 +28,15 @@ class RefreshRepo(ScriptTask):
             q_project['shortname'] = {'$regex': options.project_regex}
 
         log.info('Refreshing repositories')
+        if options.clean_all:
+            log.info('Removing all repository objects')
+            M.repo.CommitDoc.m.remove({})
+            M.repo.TreeDoc.m.remove({})
+            M.repo.TreesDoc.m.remove({})
+            M.repo.DiffInfoDoc.m.remove({})
+            M.repo.CommitRunDoc.m.remove({})
+            M.repo.LastCommitDoc.m.remove({})
+
         for chunk in chunked_find(M.Project, q_project):
             for p in chunk:
                 log.info("Refreshing repos for project '%s'." % p.shortname)
@@ -67,9 +76,6 @@ class RefreshRepo(ScriptTask):
                             i = M.repo.TreeDoc.m.find({"_id": {"$in": tree_ids_chunk}}).count()
                             log.info("Deleting %i TreeDoc docs...", i)
                             M.repo.TreeDoc.m.remove({"_id": {"$in": tree_ids_chunk}})
-                            i = M.repo.LastCommitDoc.m.find({"object_id": {"$in": tree_ids_chunk}}).count()
-                            log.info("Deleting %i LastCommitDoc docs...", i)
-                            M.repo.LastCommitDoc.m.remove({"object_id": {"$in": tree_ids_chunk}})
                         del tree_ids
 
                         # delete these after TreeDoc and LastCommitDoc so that if
@@ -78,11 +84,10 @@ class RefreshRepo(ScriptTask):
                         log.info("Deleting %i TreesDoc docs...", i)
                         M.repo.TreesDoc.m.remove({"_id": {"$in": ci_ids}})
 
-                        # delete LastCommitDocs for non-trees
-                        repo_lastcommit_re = re.compile("^{}:".format(c.app.repo._id))
-                        i = M.repo.LastCommitDoc.m.find(dict(_id=repo_lastcommit_re)).count()
+                        # delete LastCommitDocs
+                        i = M.repo.LastCommitDoc.m.find(dict(commit_ids={'$in': ci_ids})).count()
                         log.info("Deleting %i remaining LastCommitDoc docs, by repo id...",
i)
-                        M.repo.LastCommitDoc.m.remove(dict(_id=repo_lastcommit_re))
+                        M.repo.LastCommitDoc.m.remove(dict(commit_ids={'$in': ci_ids}))
 
                         i = M.repo.DiffInfoDoc.m.find({"_id": {"$in": ci_ids}}).count()
                         log.info("Deleting %i DiffInfoDoc docs...", i)


Mime
View raw message