incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject git commit: [#4832] Don't assume scm libs are installed
Date Tue, 29 Jan 2013 17:01:20 GMT
Updated Branches:
  refs/heads/tv/4832 d57603608 -> b0077398a


[#4832] Don't assume scm libs 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/b0077398
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b0077398
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b0077398

Branch: refs/heads/tv/4832
Commit: b0077398ac6410fc04130e5175dd63ff9a01b096
Parents: d576036
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Tue Jan 29 17:01:03 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Jan 29 17:01:03 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/custom_middleware.py |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b0077398/Allura/allura/lib/custom_middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index 3be5eec..709e688 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -150,23 +150,17 @@ class SSLMiddleware(object):
 class AlluraTimerMiddleware(TimerMiddleware):
     def timers(self):
         import allura
-        import forgesvn
         import genshi
-        import git
         import jinja2
         import markdown
-        import mercurial
         import ming
         import pymongo
         import socket
         import urllib2
 
-        return self.repo_impl_timers() + [
-            Timer('git', git.Repo, 'rev_parse', 'iter_commits', 'commit'),
+        return self.scm_lib_timers() + self.repo_impl_timers() + [
             Timer('jinja', jinja2.Template, 'render', 'stream', 'generate'),
             Timer('markdown', markdown.Markdown, 'convert'),
-            Timer('hg', mercurial.hg.localrepo.localrepository, 'heads',
-                'branchtags', 'tags'),
             Timer('ming', ming.odm.odmsession.ODMCursor, 'next'),
             Timer('ming', ming.odm.odmsession.ODMSession, 'flush', 'find',
                 'get'),
@@ -180,8 +174,6 @@ class AlluraTimerMiddleware(TimerMiddleware):
             Timer('mongo', pymongo.cursor.Cursor, 'count', 'distinct',
                 'explain', 'hint', 'limit', 'next', 'rewind', 'skip',
                 'sort', 'where'),
-            Timer('svn', forgesvn.model.svn.SVNLibWrapper, 'checkout', 'add',
-                'checkin', 'info2', 'log', 'cat', 'list'),
             # urlopen and socket io may or may not overlap partially
             Timer('render', genshi.Stream, 'render'),
             Timer('sidebar', allura.app.Application, 'sidebar_menu'),
@@ -200,6 +192,23 @@ class AlluraTimerMiddleware(TimerMiddleware):
             stat_record.add('request_category', c.app.config.tool_name.lower())
         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:
+            import git
+            timers.append(Timer('git', git.Repo, 'rev_parse', 'iter_commits', 'commit'))
+        except ImportError:
+            pass
+        try:
+            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


Mime
View raw message