incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/6] git commit: [#6821] Handle errors in threaded git LCDs without indefinitely blocking request
Date Wed, 18 Dec 2013 22:10:45 GMT
[#6821] Handle errors in threaded git LCDs without indefinitely blocking request

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


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

Branch: refs/heads/master
Commit: 852f084f2b0cd3daa7e931b0654f14903c7ce410
Parents: db19ef7
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Fri Dec 6 16:02:59 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Dec 18 22:10:33 2013 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py             | 41 +++++++++++---------
 .../forgegit/tests/model/test_repository.py     | 10 +++++
 requirements-sf.txt                             |  2 +-
 3 files changed, 33 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/852f084f/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 145e528..f08fdd4 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -518,25 +518,28 @@ class GitImplementation(M.RepositoryImplementation):
             num_threads += 1
         def get_ids():
             paths = set(chunks.get())
-            commit_id = commit._id
-            while paths and commit_id:
-                if time() - start_time > timeout:
-                    log.error('last_commit_ids timeout for %s on %s', commit._id, ', '.join(paths))
-                    break
-                lines = self._git.git.log(
-                        commit._id, '--', *paths,
-                        pretty='format:%H',
-                        name_only=True,
-                        max_count=1,
-                        no_merges=True).split('\n')
-                commit_id = lines[0]
-                changes = set(lines[1:])
-                changed = prefix_paths_union(paths, changes)
-                for path in changed:
-                    result[path] = commit_id
-                paths -= changed
-            chunks.task_done()
-            return
+            try:
+                commit_id = commit._id
+                while paths and commit_id:
+                    if time() - start_time > timeout:
+                        log.error('last_commit_ids timeout for %s on %s', commit._id, ',
'.join(paths))
+                        break
+                    lines = self._git.git.log(
+                            commit._id, '--', *paths,
+                            pretty='format:%H',
+                            name_only=True,
+                            max_count=1,
+                            no_merges=True).split('\n')
+                    commit_id = lines[0]
+                    changes = set(lines[1:])
+                    changed = prefix_paths_union(paths, changes)
+                    for path in changed:
+                        result[path] = commit_id
+                    paths -= changed
+            except Exception as e:
+                log.exception('Error in Git thread: %s', e)
+            finally:
+                chunks.task_done()
         if num_threads == 1:
             get_ids()
         else:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/852f084f/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 d2a9413..8569025 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -456,6 +456,16 @@ class TestGitImplementation(unittest.TestCase):
         with h.push_config(tg.config, lcd_thread_chunk_size=1):
             self.test_last_commit_ids()
 
+    def test_last_commit_ids_threaded_error(self):
+        with h.push_config(tg.config, lcd_thread_chunk_size=1):
+            repo_dir = pkg_resources.resource_filename(
+                'forgegit', 'tests/data/testrename.git')
+            repo = mock.Mock(full_fs_path=repo_dir)
+            impl = GM.git_repo.GitImplementation(repo)
+            impl._git = None
+            lcds = impl.last_commit_ids(mock.Mock(_id='13951944969cf45a701bf90f83647b309815e6d5'),
['f2.txt', 'f3.txt'])
+            self.assertEqual(lcds, {})
+
 
 class TestGitCommit(unittest.TestCase):
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/852f084f/requirements-sf.txt
----------------------------------------------------------------------
diff --git a/requirements-sf.txt b/requirements-sf.txt
index 81b2424..8fa5d69 100644
--- a/requirements-sf.txt
+++ b/requirements-sf.txt
@@ -4,7 +4,7 @@ akismet==0.2.0
 amqplib==0.6.1
 kombu==1.0.4
 coverage==3.5a1-20110413
-ForgeHg==0.1.18
+ForgeHg==0.1.19
 ForgePastebin==0.3.0
 GoogleCodeWikiImporter==0.4.7
 mechanize==0.2.4


Mime
View raw message