incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#4691] Work-around for old, incorrectly computed DiffInfoDocs
Date Wed, 06 Feb 2013 16:07:04 GMT
Updated Branches:
  refs/heads/cj/4691 a7ba5776a -> 8190353df


[#4691] Work-around for old, incorrectly computed DiffInfoDocs

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/8190353d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/8190353d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/8190353d

Branch: refs/heads/cj/4691
Commit: 8190353df535dd0f8d2bc5a0a9c9585fd3785f2a
Parents: a7ba577
Author: Cory Johns <johnsca@geek.net>
Authored: Wed Feb 6 16:06:46 2013 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Wed Feb 6 16:06:46 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repo.py         |    7 +++++++
 Allura/allura/model/repository.py   |   10 ++++++++++
 ForgeGit/forgegit/model/git_repo.py |   14 +++++++++++++-
 3 files changed, 30 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8190353d/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index c97f408..3c48e5e 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -347,6 +347,13 @@ class Commit(RepoObject):
                 cur = cur[part]
         return cur
 
+    def has_path(self, path):
+        try:
+            self.get_path(path)
+            return True
+        except KeyError:
+            return False
+
     @LazyProperty
     def changed_paths(self):
         '''

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8190353d/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index fbdb14d..ef1ef88 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -123,6 +123,16 @@ class RepositoryImplementation(object):
             changed = paths & set(commit.changed_paths)
             result.update({path: commit._id for path in changed})
             paths = paths - changed
+
+            # 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.
+            for path in list(paths):
+                parent = commit.get_parent()
+                if commit.has_path(path) and not (parent and parent.has_path(path)):
+                    paths.remove(path)
+                    result[path] = commit._id
+
             commit = commit.get_parent()
         return result
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8190353d/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 3b20706..67a1906 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -243,10 +243,22 @@ class GitImplementation(M.RepositoryImplementation):
             rev = 'HEAD'
         start = skip or 0
         stop = start + limit if limit is not None else None
+
+        def _pred(c):
+            '''
+            Work-around for potentially b0rked changed_paths.
+            This could be replaced with lambda c: path in c.changed_paths
+            once all projects have had their DiffInfoDocs refreshed.'''
+            if path in c.changed_paths:
+                return True
+            parent = c.get_parent()
+            if c.has_path(path) and not (parent and parent.has_path(path)):
+                return True  # added in this commit, inspite of changed_paths
+            return False
         predicate = None
         if path is not None:
             path = path.strip('/')
-            predicate = lambda c: path in c.changed_paths
+            predicate = _pred
 
         iter_tree = self.commit(rev).climb_commit_tree(predicate)
         for commit in itertools.islice(iter_tree, start, stop):


Mime
View raw message