incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [9/11] git commit: [#5685] Changed default LCD creation to use SCM (requires ForgeHg fix)
Date Tue, 12 Feb 2013 22:21:49 GMT
[#5685] Changed default LCD creation to use SCM (requires ForgeHg fix)

Signed-off-by: Cory Johns <johnsca@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/110e0bbf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/110e0bbf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/110e0bbf

Branch: refs/heads/cj/5685
Commit: 110e0bbfbf5bd14bda3abea24d8d062e4bba0f33
Parents: 231ee23
Author: Cory Johns <johnsca@geek.net>
Authored: Tue Feb 12 21:19:04 2013 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Tue Feb 12 22:21:20 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repo.py         |   11 ++++++++---
 Allura/allura/model/repository.py   |   21 +++++++++++++++++----
 ForgeGit/forgegit/model/git_repo.py |   14 --------------
 ForgeSVN/forgesvn/model/svn.py      |   10 +++++-----
 4 files changed, 30 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/110e0bbf/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 569cbb3..f17415d 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -489,8 +489,11 @@ class Tree(RepoObject):
         last_commit = LastCommit.get(self, create=True)
         # ensure that the LCD is saved, even if
         # there is an error later in the request
-        session(last_commit).flush(last_commit)
-        return self._lcd_map(LastCommit.get(self))
+        if last_commit:
+            session(last_commit).flush(last_commit)
+            return self._lcd_map(last_commit)
+        else:
+            return []
 
     def _lcd_map(self, lcd):
         if lcd is None:
@@ -505,7 +508,9 @@ class Tree(RepoObject):
         results = []
         for type, names in (('DIR', tree_names), ('BLOB', blob_names)):
             for name in names:
-                commit_info = commit_infos[lcd.by_name[name]]
+                commit_info = commit_infos.get(lcd.by_name.get(name))
+                if not commit_info:
+                    continue
                 results.append(dict(
                         kind=type,
                         name=name,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/110e0bbf/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 05dc771..4e0a075 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -117,9 +117,16 @@ class RepositoryImplementation(object):
         Return a mapping {path: commit_id} of the _id of the last
         commit to touch each path, starting from the given commit.
         '''
+        from allura import model as M
+        cache = getattr(c, 'model_cache', '') or M.repo.ModelCache()
+        tree_path = os.path.commonprefix(paths).strip('/')
         paths = set(paths)
         result = {}
-        while paths and commit:
+        for commit_id in self.commits(path=tree_path, rev=commit._id):
+            commit = cache.get(M.repo.Commit, dict(_id=commit_id))
+            if not commit:
+                log.error('Missing commit, cannot compute LCD: %s', commit_id)
+                return None
             changed = paths & set(commit.changed_paths)
             result.update({path: commit._id for path in changed})
             paths = paths - changed
@@ -127,15 +134,21 @@ class RepositoryImplementation(object):
             # Hacky work-around for DiffInfoDocs previously having been
             # computed wrong (not including children of added trees).
             # Can be removed once all projects have had diffs / LCDs refreshed.
-            parent = commit.get_parent()
-            if parent:
+            if commit.parent_ids:
+                parent = commit.get_parent()
+                if not commit:
+                    log.error('Missing commit, cannot compute LCD: %s', commit.parent_ids[0])
+                    return None
                 changed = set([path for path in paths if not parent.has_path(path)])
                 result.update({path: commit._id for path in changed})
                 paths = paths - changed
             else:
                 result.update({path: commit._id for path in paths})
+                paths = set()
+            # end hacky work-around
 
-            commit = commit.get_parent()
+            if not paths:
+                break
         return result
 
     @classmethod

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/110e0bbf/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 0bcd4c2..7154a6d 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -252,20 +252,6 @@ class GitImplementation(M.RepositoryImplementation):
         commit = self._git.commit(rev)
         return commit.count(path)
 
-    def last_commit_ids(self, commit, paths):
-        cache = getattr(c, 'model_cache', '') or M.repo.ModelCache()
-        tree_path = os.path.commonprefix(paths).strip('/')
-        paths = set(paths)
-        result = {}
-        for commit_id in self.commits(path=tree_path, rev=commit._id):
-            commit = cache.get(M.repo.Commit, dict(_id=commit_id))
-            changed = paths & set(commit.changed_paths)
-            result.update({path: commit_id for path in changed})
-            paths = paths - changed
-            if not paths:
-                break
-        return result
-
     def log(self, object_id, skip, count):
         obj = self._git.commit(object_id)
         candidates = [ obj ]

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/110e0bbf/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 33bac43..8d9ee77 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -550,9 +550,9 @@ class SVNImplementation(M.RepositoryImplementation):
             opts['limit'] = skip + limit
         try:
             revs = self._svn.log(path, **opts)
-        except pysvn.ClientError:
-            log.info('ClientError processing commits for path %s, rev %s, skip=%s, limit=%s,
treating as empty',
-                    path, rev, skip, limit, exc_info=True)
+        except pysvn.ClientError as e:
+            log.exception('ClientError processing commits for SVN: path %s, rev %s, skip=%s,
limit=%s, treating as empty',
+                    path, rev, skip, limit)
             return []
         if skip:
             # pysvn has already limited result for us, we just need to skip
@@ -570,8 +570,8 @@ class SVNImplementation(M.RepositoryImplementation):
             opts['revision_end'] = pysvn.Revision(pysvn.opt_revision_kind.number, 0)
         try:
             return len(self._svn.log(path, **opts))
-        except pysvn.ClientError:
-            log.info('ClientError processing commits for path %s, rev %s, treating as empty',
path, rev, exc_info=True)
+        except pysvn.ClientError as e:
+            log.exception('ClientError processing commits for SVN: path %s, rev %s, treating
as empty', path, rev)
             return 0
 
     def last_commit_ids(self, commit, paths):


Mime
View raw message