You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2012/12/07 16:36:06 UTC
git commit: [#4691] Fail gracefully if objects don't exist
Updated Branches:
refs/heads/cj/4691 1ce4bd57e -> dc1056edf
[#4691] Fail gracefully if objects don't exist
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/dc1056ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/dc1056ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/dc1056ed
Branch: refs/heads/cj/4691
Commit: dc1056edf98c1502d5a28d1c026048000878c5a2
Parents: 1ce4bd5
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Fri Dec 7 15:35:47 2012 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Dec 7 15:35:47 2012 +0000
----------------------------------------------------------------------
Allura/allura/model/repo.py | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dc1056ed/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 11e78b7..f89afdd 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -209,6 +209,8 @@ class Commit(RepoObject):
try:
cache = getattr(c, 'model_cache', '') or ModelCache()
ci = cache.get(Commit, dict(_id=self.parent_ids[index]))
+ if not ci:
+ return None
ci.set_context(self.repo)
return ci
except IndexError as e:
@@ -366,13 +368,14 @@ class Commit(RepoObject):
'''
diff_info = DiffInfoDoc.m.get(_id=self._id)
diffs = set()
- for d in diff_info.differences:
- diffs.add(d.name.strip('/'))
- node_path = os.path.dirname(d.name)
- while node_path:
- diffs.add(node_path)
- node_path = os.path.dirname(node_path)
- diffs.add('') # include '/' if there are any changes
+ if diff_info:
+ for d in diff_info.differences:
+ diffs.add(d.name.strip('/'))
+ node_path = os.path.dirname(d.name)
+ while node_path:
+ diffs.add(node_path)
+ node_path = os.path.dirname(node_path)
+ diffs.add('') # include '/' if there are any changes
return diffs
@LazyProperty
@@ -481,6 +484,8 @@ class Tree(RepoObject):
return old_style_results
# finally, use the new implentation that auto-vivifies
last_commit = LastCommit.get(self)
+ if not last_commit:
+ return []
sorted_entries = sorted(last_commit.entries, cmp=lambda a,b: cmp(b.type,a.type) or cmp(a.name,b.name))
mapped_entries = [self._dirent_map(e) for e in sorted_entries]
return mapped_entries