allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [15/42] git commit: [#4691] Fail gracefully if objects don't exist
Date Tue, 05 Feb 2013 20:23:35 GMT
[#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/f95b0941
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f95b0941
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f95b0941

Branch: refs/heads/master
Commit: f95b09411c415b18cde1409075eec6c85a60b7ab
Parents: 9d48b05
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Fri Dec 7 16:19:40 2012 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Feb 5 20:22:50 2013 +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/f95b0941/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 8eb23d9..85e44ad 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


Mime
View raw message