You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/01/29 18:23:28 UTC
git commit: [#4832] Don't assume scm tools are installed
Updated Branches:
refs/heads/tv/4832 b0077398a -> cf328622a
[#4832] Don't assume scm tools are installed
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/cf328622
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/cf328622
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/cf328622
Branch: refs/heads/tv/4832
Commit: cf328622a9676d6b8ee6c077bb599ad47aac42ce
Parents: b007739
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Jan 29 17:23:12 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jan 29 17:23:12 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/custom_middleware.py | 48 ++++++++++++++-------------
1 files changed, 25 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cf328622/Allura/allura/lib/custom_middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index 709e688..093af17 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -1,6 +1,7 @@
import os
import re
import logging
+from contextlib import contextmanager
import tg
import pkg_resources
@@ -193,36 +194,37 @@ class AlluraTimerMiddleware(TimerMiddleware):
return stat_record
def scm_lib_timers(self):
- import forgesvn
- timers = [Timer('svn', forgesvn.model.svn.SVNLibWrapper, 'checkout', 'add',
- 'checkin', 'info2', 'log', 'cat', 'list')]
- try:
+ timers = []
+ with pass_on_exc(ImportError):
+ import forgesvn
+ timers.append(Timer('svn', forgesvn.model.svn.SVNLibWrapper, 'checkout', 'add',
+ 'checkin', 'info2', 'log', 'cat', 'list'))
+ with pass_on_exc(ImportError):
import git
timers.append(Timer('git', git.Repo, 'rev_parse', 'iter_commits', 'commit'))
- except ImportError:
- pass
- try:
+ with pass_on_exc(ImportError):
import mercurial
timers.append(Timer('hg', mercurial.hg.localrepo.localrepository, 'heads',
'branchtags', 'tags'))
- except ImportError:
- pass
return timers
def repo_impl_timers(self):
- from forgegit.model.git_repo import GitImplementation
- from forgesvn.model.svn import SVNImplementation
-
- repo_impl_timers = [
- Timer('git_impl', GitImplementation, '*'),
- Timer('svn_impl', SVNImplementation, '*'),
- ]
-
- try:
+ timers= []
+ with pass_on_exc(ImportError):
+ from forgegit.model.git_repo import GitImplementation
+ timers.append(Timer('git_impl', GitImplementation, '*'))
+ with pass_on_exc(ImportError):
+ from forgesvn.model.svn import SVNImplementation
+ timers.append(Timer('svn_impl', SVNImplementation, '*'))
+ with pass_on_exc(ImportError):
from forgehg.model.hg import HgImplementation
- repo_impl_timers.append(
- Timer('hg_impl', HgImplementation, '*'))
- except ImportError:
- pass
+ timers.append(Timer('hg_impl', HgImplementation, '*'))
+ return timers
+
- return repo_impl_timers
+@contextmanager
+def pass_on_exc(exc):
+ try:
+ yield
+ except exc:
+ pass