You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/03/01 21:04:51 UTC

git commit: [#5896] Improved error handling of missing trees and blob prev_commit context

Updated Branches:
  refs/heads/cj/5896 [created] 4ffc13e19


[#5896] Improved error handling of missing trees and blob prev_commit context

Signed-off-by: Cory Johns <jo...@geek.net>


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

Branch: refs/heads/cj/5896
Commit: 4ffc13e1917947205ce3cbdbe7a69f4d744bbfe6
Parents: fa73101
Author: Cory Johns <jo...@geek.net>
Authored: Fri Mar 1 19:45:29 2013 +0000
Committer: Cory Johns <jo...@geek.net>
Committed: Fri Mar 1 19:45:29 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repo.py |   30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4ffc13e1/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 1510de6..668f00e 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -665,21 +665,9 @@ class Blob(object):
 
     @LazyProperty
     def prev_commit(self):
-        lc = LastCommit.get(self.tree, create=False)
-        if lc:
-            last_commit = self.repo.commit(lc.by_name[self.name])
-            prev_commit = last_commit.get_parent()
-            try:
-                tree = prev_commit and prev_commit.get_path(self.tree.path().rstrip('/'), create=False)
-            except KeyError:
-                return None  # parent tree added this commit
-            if not tree or self.name not in tree.by_name:
-                return None  # tree or file added this commit
-            lc = LastCommit.get(tree, create=False)
-            commit_id = lc and lc.by_name.get(self.name)
-            if commit_id:
-                prev_commit = self.repo.commit(commit_id)
-                return prev_commit
+        pcid = LastCommit._prev_commit_id(self.commit, self.path().strip('/'))
+        if pcid:
+            return self.repo.commit(pcid)
         return None
 
     @LazyProperty
@@ -733,8 +721,16 @@ class Blob(object):
         path = self.path()
         prev = self.prev_commit
         next = self.next_commit
-        if prev is not None: prev = prev.get_path(path, create=False)
-        if next is not None: next = next.get_path(path, create=False)
+        if prev is not None:
+            try:
+                prev = prev.get_path(path, create=False)
+            except KeyError as e:
+                prev = None
+        if next is not None:
+            try:
+                next = next.get_path(path, create=False)
+            except KeyError as e:
+                next = None
         return dict(
             prev=prev,
             next=next)