You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/02/19 20:26:45 UTC
[5/6] git commit: [#5685] Change GitImplementation.commits back to
GitPython implementation
[#5685] Change GitImplementation.commits back to GitPython implementation
The implementation of GitImplementation.commits() that calls out to git
to list commits which modified a given path is, under certain
circumstances, significantly more efficient than the implementation
using the mongo cache to determine the same.
Testing on a copy of the Merciless repository, the _git.iter_commits
implementation takes roughly 1.5s to generate the history log for the
path /flyway, while the mongo / Allura model implementation takes
somewhere around 20s.
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/8866f9e3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/8866f9e3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/8866f9e3
Branch: refs/heads/master
Commit: 8866f9e3dd6ecc460fb0d84c686434d4922f1576
Parents: 9ae902a
Author: Cory Johns <jo...@geek.net>
Authored: Tue Feb 19 01:31:16 2013 +0000
Committer: Dave Brondsema <db...@geek.net>
Committed: Tue Feb 19 19:26:30 2013 +0000
----------------------------------------------------------------------
ForgeGit/forgegit/model/git_repo.py | 32 +++++++----------------------
1 files changed, 8 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8866f9e3/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 67a1906..7154a6d 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -239,30 +239,14 @@ class GitImplementation(M.RepositoryImplementation):
return doc
def commits(self, path=None, rev=None, skip=None, limit=None):
- if rev is None:
- 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 = _pred
-
- iter_tree = self.commit(rev).climb_commit_tree(predicate)
- for commit in itertools.islice(iter_tree, start, stop):
- yield commit._id
+ params = dict(paths=path)
+ if rev is not None:
+ params['rev'] = rev
+ if skip is not None:
+ params['skip'] = skip
+ if limit is not None:
+ params['max_count'] = limit
+ return (c.hexsha for c in self._git.iter_commits(**params))
def commits_count(self, path=None, rev=None):
commit = self._git.commit(rev)