[#6272] TMW tracking of additional SCM methods
Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index 6c121b4..e156e94 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -228,15 +228,21 @@
'checkin', 'info2', 'log', 'cat', 'list'))
with pass_on_exc(ImportError):
import git
+ import forgegit
timers.append(Timer('git_lib.{method_name}', git.Repo, 'rev_parse', 'iter_commits', 'commit'))
+ timers.append(Timer('git_lib.{method_name}', forgegit.model.git_repo.GitLibCmdWrapper, 'log'))
with pass_on_exc(ImportError):
import mercurial.hg
timers.append(Timer('hg_lib.{method_name}', mercurial.hg.localrepo.localrepository, 'heads',
'branchtags', 'tags'))
+ timers.append(Timer('hg_lib.{method_name}', mercurial.cmdutil, 'walkchangerevs'))
return timers
def repo_impl_timers(self):
timers= []
+ from allura.model.repository import Repository, RepositoryImplementation
+ timers.append(Timer('base_tool.{method_name}', Repository, 'commitlog'))
+ timers.append(Timer('base_tool.{method_name}', RepositoryImplementation, 'last_commit_ids'))
with pass_on_exc(ImportError):
from forgegit.model.git_repo import GitImplementation
timers.append(Timer('git_tool.{method_name}', GitImplementation, '*'))
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index c66ae91..6081a55 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -49,6 +49,16 @@
gitdb.util.mman = gitdb.util.mman.__class__(
max_open_handles=128)
+class GitLibCmdWrapper(object):
+ def __init__(self, client):
+ self.client = client
+
+ def __getattr__(self, name):
+ return getattr(self.client, name)
+
+ def log(self, *args, **kwargs):
+ return self.client.log(*args, **kwargs)
+
class Repository(M.Repository):
tool_name='Git'
repo_id='git'
@@ -95,7 +105,9 @@
@LazyProperty
def _git(self):
try:
- return git.Repo(self._repo.full_fs_path, odbt=git.GitCmdObjectDB)
+ _git = git.Repo(self._repo.full_fs_path, odbt=git.GitCmdObjectDB)
+ _git.git = GitLibCmdWrapper(_git.git)
+ return _git
except (git.exc.NoSuchPathError, git.exc.InvalidGitRepositoryError), err:
log.error('Problem looking up repo: %r', err)
return None