##// END OF EJS Templates
Added recursive scanning for repositories in directory
marcink -
r877:bc9a73ad beta
parent child Browse files
Show More
@@ -110,31 +110,38 b' def action_logger(user, action, repo, ip'
110 110 log.error(traceback.format_exc())
111 111 sa.rollback()
112 112
113 def get_repos(path, recursive=False, initial=False):
113 def get_repos(path, recursive=False):
114 114 """
115 115 Scans given path for repos and return (name,(type,path)) tuple
116 116
117 :param prefix:
118 :param path:
119 :param recursive:
120 :param initial:
117 :param path: path to scann for repositories
118 :param recursive: recursive search and return names with subdirs in front
121 119 """
122 120 from vcs.utils.helpers import get_scm
123 121 from vcs.exceptions import VCSError
124 122
123 if path.endswith('/'):
124 #add ending slash for better results
125 path = path[:-1]
126
127 def _get_repos(p):
128 for dirpath in os.listdir(p):
129 if os.path.isfile(os.path.join(p, dirpath)):
130 continue
131 cur_path = os.path.join(p, dirpath)
125 132 try:
126 scm = get_scm(path)
127 except:
128 pass
129 else:
130 raise Exception('The given path %s should not be a repository got %s',
131 path, scm)
133 scm_info = get_scm(cur_path)
134 yield scm_info[1].split(path)[-1].lstrip('/'), scm_info
135 except VCSError:
136 if not recursive:
137 continue
138 #check if this dir containts other repos for recursive scan
139 rec_path = os.path.join(p, dirpath)
140 if os.path.isdir(rec_path):
141 for inner_scm in _get_repos(rec_path):
142 yield inner_scm
132 143
133 for dirpath in os.listdir(path):
134 try:
135 yield dirpath, get_scm(os.path.join(path, dirpath))
136 except VCSError:
137 pass
144 return _get_repos(path)
138 145
139 146 def check_repo_fast(repo_name, base_path):
140 147 """
@@ -41,7 +41,7 b' from beaker.cache import cache_region, r'
41 41 from rhodecode import BACKENDS
42 42 from rhodecode.lib import helpers as h
43 43 from rhodecode.lib.auth import HasRepoPermissionAny
44 from rhodecode.lib.utils import get_repos, make_ui, action_logger
44 from rhodecode.lib.utils import get_repos as get_filesystem_repos, make_ui, action_logger
45 45 from rhodecode.model import BaseModel
46 46 from rhodecode.model.user import UserModel
47 47
@@ -90,7 +90,7 b' class ScmModel(BaseModel):'
90 90 baseui = make_ui('db')
91 91 repos_list = {}
92 92
93 for name, path in get_repos(repos_path):
93 for name, path in get_filesystem_repos(repos_path, recursive=True):
94 94 try:
95 95 if repos_list.has_key(name):
96 96 raise RepositoryError('Duplicate repository name %s '
General Comments 0
You need to be logged in to leave comments. Login now