allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hei...@apache.org
Subject allura git commit: [#7873] Pre-cache git branches/tags after repo_refresh
Date Tue, 16 Jun 2015 18:27:11 GMT
Repository: allura
Updated Branches:
  refs/heads/hs/7873 6da8d103c -> 6005ecd08 (forced update)


[#7873] Pre-cache git branches/tags after repo_refresh


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

Branch: refs/heads/hs/7873
Commit: 6005ecd086f09bb662185dd50e094aafc84add8e
Parents: f24debe
Author: Heith Seewald <hseewald@slashdotmedia.com>
Authored: Tue Jun 16 14:02:20 2015 -0400
Committer: Heith Seewald <hseewald@slashdotmedia.com>
Committed: Tue Jun 16 14:27:05 2015 -0400

----------------------------------------------------------------------
 Allura/allura/model/repo_refresh.py                    | 4 ++++
 Allura/development.ini                                 | 2 +-
 ForgeGit/forgegit/model/git_repo.py                    | 3 +--
 ForgeGit/forgegit/tests/functional/test_controllers.py | 5 +----
 ForgeGit/forgegit/tests/model/test_repository.py       | 2 ++
 5 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6005ecd0/Allura/allura/model/repo_refresh.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo_refresh.py b/Allura/allura/model/repo_refresh.py
index 74e79ba..1ca82e8 100644
--- a/Allura/allura/model/repo_refresh.py
+++ b/Allura/allura/model/repo_refresh.py
@@ -132,6 +132,10 @@ def refresh_repo(repo, all_commits=False, notify=True, new_clone=False):
     if repo.cached_tags:
         repo.cached_tags = []
         session(repo).flush()
+    # The first view can be expensive to cache,
+    # so we want to do it here instead of on the first view.
+    repo.get_branches()
+    repo.get_tags()
 
     if not all_commits and not new_clone:
         for commit in commit_ids:

http://git-wip-us.apache.org/repos/asf/allura/blob/6005ecd0/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 284f620..4c9e353 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -298,7 +298,7 @@ scm.import.retry_count = 50
 scm.import.retry_sleep_secs = 5
 
 ; When getting a list of valid references (branches/tags) from a repo, you can cache
-; the resaults in mongo based on a threshold. Set `repo_refs_cache_threshold` (in seconds)
and the resulting
+; the results in mongo based on a threshold. Set `repo_refs_cache_threshold` (in seconds)
and the resulting
 ; lists will be cached and served from cache on subsequent requests until reset by `repo_refresh`.
 ; Set to 0 to cache all references. Remove entirely to cache nothing.
 repo_refs_cache_threshold = .5

http://git-wip-us.apache.org/repos/asf/allura/blob/6005ecd0/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index d9ede88..4ec48be 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -545,10 +545,9 @@ class GitImplementation(M.RepositoryImplementation):
         if cache:
             return cache
 
-        ref_list = getattr(self._git, field_name)
-
         refs = []
         start_time = time()
+        ref_list = getattr(self._git, field_name)
         for ref in ref_list:
             try:
                 hex_sha = ref.commit.hexsha

http://git-wip-us.apache.org/repos/asf/allura/blob/6005ecd0/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 29c6453..917f765 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -390,10 +390,7 @@ class TestRootController(_TestCase):
 
     def test_default_branch(self):
         assert_equal(c.app.default_branch_name, 'master')
-        vv = c.app.repo.set_default_branch('zz')
-        print('-' * 10)
-        print(vv)
-        print('-' * 10)
+        c.app.repo.set_default_branch('zz')
         assert_equal(c.app.default_branch_name, 'zz')
         c.app.repo.set_default_branch('master')
         assert_equal(c.app.default_branch_name, 'master')

http://git-wip-us.apache.org/repos/asf/allura/blob/6005ecd0/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 47dc34d..c28daf1 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -746,6 +746,7 @@ class TestGitImplementation(unittest.TestCase):
         repo_dir = pkg_resources.resource_filename(
             'forgegit', 'tests/data/testgit.git')
         repo = mock.Mock(full_fs_path=repo_dir)
+        repo.cached_branches = []
         impl = GM.git_repo.GitImplementation(repo)
         self.assertEqual(impl.branches, [
             Object(name='master',
@@ -758,6 +759,7 @@ class TestGitImplementation(unittest.TestCase):
         repo_dir = pkg_resources.resource_filename(
             'forgegit', 'tests/data/testgit.git')
         repo = mock.Mock(full_fs_path=repo_dir)
+        repo.cached_tags = []
         impl = GM.git_repo.GitImplementation(repo)
         self.assertEqual(impl.tags, [
             Object(name='foo',


Mime
View raw message