You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/09/23 19:09:25 UTC
[2/3] git commit: [#6695] Added sanity check in LCD for loops in
commit data
[#6695] Added sanity check in LCD for loops in commit data
Signed-off-by: Cory Johns <cj...@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/9d029ebe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9d029ebe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9d029ebe
Branch: refs/heads/master
Commit: 9d029ebeb70f04d839138d3d4836cae87f96cab8
Parents: 4ed71de
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Sep 20 22:27:25 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Sep 23 17:09:04 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/repository.py | 4 ++++
Allura/allura/tests/model/test_repo.py | 14 ++++++++++++++
2 files changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d029ebe/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 32b9bf1..b371295 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -149,9 +149,13 @@ class RepositoryImplementation(object):
start_time = time()
paths = set(paths)
result = {}
+ seen_commits = set()
while paths and commit:
if time() - start_time > timeout:
return result
+ if commit._id in seen_commits:
+ return result # sanity check for bad data (loops)
+ seen_commits.add(commit._id)
changed = paths & set(commit.changed_paths)
result.update({path: commit._id for path in changed})
paths = paths - changed
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d029ebe/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 b67be9f..ef39e4b 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -334,6 +334,20 @@ class TestLastCommit(unittest.TestCase):
self.assertEqual(len(lcd.entries), 1)
self.assertEqual(lcd.by_name['file2'], commit3._id)
+ def test_loop(self):
+ commit1 = self._add_commit('Commit 1', ['file1'])
+ commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
+ commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
+ commit2.parent_ids = [commit3._id]
+ session(commit2).flush(commit2)
+ lcd = M.repo.LastCommit.get(commit3.tree)
+ self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
+ self.assertEqual(lcd.commit_id, commit3._id)
+ self.assertEqual(lcd.path, '')
+ self.assertEqual(len(lcd.entries), 2)
+ self.assertEqual(lcd.by_name['dir1'], commit2._id)
+ self.assertEqual(lcd.by_name['file2'], commit3._id)
+
class TestModelCache(unittest.TestCase):
def setUp(self):