Show More
@@ -110,31 +110,38 b' def action_logger(user, action, repo, ip' | |||||
110 | log.error(traceback.format_exc()) |
|
110 | log.error(traceback.format_exc()) | |
111 | sa.rollback() |
|
111 | sa.rollback() | |
112 |
|
112 | |||
113 |
def get_repos(path, recursive=False |
|
113 | def get_repos(path, recursive=False): | |
114 | """ |
|
114 | """ | |
115 | Scans given path for repos and return (name,(type,path)) tuple |
|
115 | Scans given path for repos and return (name,(type,path)) tuple | |
116 |
|
116 | |||
117 | :param prefix: |
|
117 | :param path: path to scann for repositories | |
118 | :param path: |
|
118 | :param recursive: recursive search and return names with subdirs in front | |
119 | :param recursive: |
|
|||
120 | :param initial: |
|
|||
121 | """ |
|
119 | """ | |
122 | from vcs.utils.helpers import get_scm |
|
120 | from vcs.utils.helpers import get_scm | |
123 | from vcs.exceptions import VCSError |
|
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 | try: |
|
132 | try: | |
126 | scm = get_scm(path) |
|
133 | scm_info = get_scm(cur_path) | |
127 | except: |
|
134 | yield scm_info[1].split(path)[-1].lstrip('/'), scm_info | |
128 | pass |
|
135 | except VCSError: | |
129 | else: |
|
136 | if not recursive: | |
130 | raise Exception('The given path %s should not be a repository got %s', |
|
137 | continue | |
131 | path, scm) |
|
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): |
|
144 | return _get_repos(path) | |
134 | try: |
|
|||
135 | yield dirpath, get_scm(os.path.join(path, dirpath)) |
|
|||
136 | except VCSError: |
|
|||
137 | pass |
|
|||
138 |
|
145 | |||
139 | def check_repo_fast(repo_name, base_path): |
|
146 | def check_repo_fast(repo_name, base_path): | |
140 | """ |
|
147 | """ |
@@ -41,7 +41,7 b' from beaker.cache import cache_region, r' | |||||
41 | from rhodecode import BACKENDS |
|
41 | from rhodecode import BACKENDS | |
42 | from rhodecode.lib import helpers as h |
|
42 | from rhodecode.lib import helpers as h | |
43 | from rhodecode.lib.auth import HasRepoPermissionAny |
|
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 | from rhodecode.model import BaseModel |
|
45 | from rhodecode.model import BaseModel | |
46 | from rhodecode.model.user import UserModel |
|
46 | from rhodecode.model.user import UserModel | |
47 |
|
47 | |||
@@ -90,7 +90,7 b' class ScmModel(BaseModel):' | |||||
90 | baseui = make_ui('db') |
|
90 | baseui = make_ui('db') | |
91 | repos_list = {} |
|
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 | try: |
|
94 | try: | |
95 | if repos_list.has_key(name): |
|
95 | if repos_list.has_key(name): | |
96 | raise RepositoryError('Duplicate repository name %s ' |
|
96 | raise RepositoryError('Duplicate repository name %s ' |
General Comments 0
You need to be logged in to leave comments.
Login now