changeset 3952:ebde99f10d77 beta

Cleanup code
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 05 Jun 2013 21:06:59 +0200
parents 9378d8640a4b
children fc63a1d93803
files rhodecode/model/scm.py
diffstat 1 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/model/scm.py	Wed Jun 05 20:45:05 2013 +0200
+++ b/rhodecode/model/scm.py	Wed Jun 05 21:06:59 2013 +0200
@@ -30,7 +30,7 @@
 import logging
 import cStringIO
 import pkg_resources
-from os.path import dirname as dn, join as jn
+from os.path import join as jn
 
 from sqlalchemy import func
 from pylons.i18n.translation import _
@@ -47,9 +47,9 @@
 from rhodecode.lib.utils2 import safe_str, safe_unicode, get_server_url,\
     _set_extras
 from rhodecode.lib.auth import HasRepoPermissionAny, HasReposGroupPermissionAny,\
-    HasUserGroupPermissionAnyDecorator, HasUserGroupPermissionAny
+    HasUserGroupPermissionAny
 from rhodecode.lib.utils import get_filesystem_repos, make_ui, \
-    action_logger, REMOVED_REPO_PAT
+    action_logger
 from rhodecode.model import BaseModel
 from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \
     UserFollowing, UserLog, User, RepoGroup, PullRequest
@@ -486,12 +486,15 @@
         :param scm_type:
         """
         if scm_type == 'hg':
-            from rhodecode.lib.vcs.backends.hg import \
-                MercurialInMemoryChangeset as IMC
-        elif scm_type == 'git':
-            from rhodecode.lib.vcs.backends.git import \
-                GitInMemoryChangeset as IMC
-        return IMC
+            from rhodecode.lib.vcs.backends.hg import MercurialInMemoryChangeset
+            return MercurialInMemoryChangeset
+
+        if scm_type == 'git':
+            from rhodecode.lib.vcs.backends.git import GitInMemoryChangeset
+            return GitInMemoryChangeset
+
+        raise Exception('Invalid scm_type, must be one of hg,git got %s'
+                        % (scm_type,))
 
     def pull_changes(self, repo, username):
         dbrepo = self.__get_repo(repo)
@@ -724,7 +727,6 @@
             if os.path.exists(_hook_file):
                 # let's take a look at this hook, maybe it's rhodecode ?
                 log.debug('hook exists, checking if it is from rhodecode')
-                _HOOK_VER_PAT = re.compile(r'^RC_HOOK_VER')
                 with open(_hook_file, 'rb') as f:
                     data = f.read()
                     matches = re.compile(r'(?:%s)\s*=\s*(.*)'
@@ -741,7 +743,7 @@
                 _rhodecode_hook = True
 
             if _rhodecode_hook or force_create:
-                log.debug('writing %s hook file !' % h_type)
+                log.debug('writing %s hook file !' % (h_type,))
                 with open(_hook_file, 'wb') as f:
                     tmpl = tmpl.replace('_TMPL_', rhodecode.__version__)
                     f.write(tmpl)