aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2013-01-26 20:11:55 +0100
committerMarcin Kuzminski <marcin@python-works.com>2013-01-26 20:11:55 +0100
commita63d1f87339692bc64002476efadb5de14e44ce5 (patch)
tree732f63e3bf7306d3bac9fa52738b5f32f368caea
parentc836104309c0ed996a9b9f0bd84071d184d4bfe6 (diff)
reposcann should skip directories with starting with '.'
some code cleanup, moved all skipping to get_repos function --HG-- extra : source : ba2e2514a01a53f6e8af014540135c76956eb7b6
-rw-r--r--rhodecode/lib/utils.py15
-rw-r--r--rhodecode/lib/vcs/utils/helpers.py3
-rw-r--r--rhodecode/model/scm.py8
3 files changed, 18 insertions, 8 deletions
diff --git a/rhodecode/lib/utils.py b/rhodecode/lib/utils.py
index 24a3ffa6..a0c8fb03 100644
--- a/rhodecode/lib/utils.py
+++ b/rhodecode/lib/utils.py
@@ -171,7 +171,7 @@ def action_logger(user, action, repo, ipaddr='', sa=None, commit=False):
raise
-def get_repos(path, recursive=False):
+def get_repos(path, recursive=False, skip_removed_repos=True):
"""
Scans given path for repos and return (name,(type,path)) tuple
@@ -181,6 +181,7 @@ def get_repos(path, recursive=False):
# remove ending slash for better results
path = path.rstrip(os.sep)
+ log.debug('now scanning in %s location recursive:%s...' % (path, recursive))
def _get_repos(p):
if not os.access(p, os.W_OK):
@@ -189,6 +190,15 @@ def get_repos(path, recursive=False):
if os.path.isfile(os.path.join(p, dirpath)):
continue
cur_path = os.path.join(p, dirpath)
+
+ # skip removed repos
+ if skip_removed_repos and REMOVED_REPO_PAT.match(dirpath):
+ continue
+
+ #skip .<somethin> dirs
+ if dirpath.startswith('.'):
+ continue
+
try:
scm_info = get_scm(cur_path)
yield scm_info[1].split(path, 1)[-1].lstrip(os.sep), scm_info
@@ -203,6 +213,9 @@ def get_repos(path, recursive=False):
return _get_repos(path)
+#alias for backward compat
+get_filesystem_repos = get_repos
+
def is_valid_repo(repo_name, base_path, scm=None):
"""
diff --git a/rhodecode/lib/vcs/utils/helpers.py b/rhodecode/lib/vcs/utils/helpers.py
index 6c1d50cf..20b1bf1b 100644
--- a/rhodecode/lib/vcs/utils/helpers.py
+++ b/rhodecode/lib/vcs/utils/helpers.py
@@ -80,7 +80,7 @@ def get_scms_for_path(path):
continue
dirname = os.path.join(path, 'rm__.' + key)
if os.path.isdir(dirname):
- return [None]
+ return result
# We still need to check if it's not bare repository as
# bare repos don't have working directories
try:
@@ -131,6 +131,7 @@ def get_highlighted_code(name, code, type='terminal'):
content = code
return content
+
def parse_changesets(text):
"""
Returns dictionary with *start*, *main* and *end* ids.
diff --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py
index 4490293e..b21b11c8 100644
--- a/rhodecode/model/scm.py
+++ b/rhodecode/model/scm.py
@@ -46,7 +46,7 @@ from rhodecode import BACKENDS
from rhodecode.lib import helpers as h
from rhodecode.lib.utils2 import safe_str, safe_unicode
from rhodecode.lib.auth import HasRepoPermissionAny, HasReposGroupPermissionAny
-from rhodecode.lib.utils import get_repos as get_filesystem_repos, make_ui, \
+from rhodecode.lib.utils import get_filesystem_repos, make_ui, \
action_logger, REMOVED_REPO_PAT
from rhodecode.model import BaseModel
from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \
@@ -224,10 +224,6 @@ class ScmModel(BaseModel):
repos = {}
for name, path in get_filesystem_repos(repos_path, recursive=True):
- # skip removed repos
- if REMOVED_REPO_PAT.match(name) or path[0] is None:
- continue
-
# name need to be decomposed and put back together using the /
# since this is internal storage separator for rhodecode
name = Repository.normalize_repo_name(name)
@@ -247,7 +243,7 @@ class ScmModel(BaseModel):
repos[name] = klass(path[1])
except OSError:
continue
-
+ log.debug('found %s paths with repositories' % (len(repos)))
return repos
def get_repos(self, all_repos=None, sort_key=None, simple=False):