Mercurial > kallithea
comparison rhodecode/lib/utils.py @ 3228:ba2e2514a01a beta
reposcann should skip directories with starting with '.'
some code cleanup, moved all skipping to get_repos function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 26 Jan 2013 20:11:55 +0100 |
parents | 68f9c216377d |
children | f1491bad8339 |
comparison
equal
deleted
inserted
replaced
3227:99ce5d097a09 | 3228:ba2e2514a01a |
---|---|
169 except: | 169 except: |
170 log.error(traceback.format_exc()) | 170 log.error(traceback.format_exc()) |
171 raise | 171 raise |
172 | 172 |
173 | 173 |
174 def get_repos(path, recursive=False): | 174 def get_repos(path, recursive=False, skip_removed_repos=True): |
175 """ | 175 """ |
176 Scans given path for repos and return (name,(type,path)) tuple | 176 Scans given path for repos and return (name,(type,path)) tuple |
177 | 177 |
178 :param path: path to scan for repositories | 178 :param path: path to scan for repositories |
179 :param recursive: recursive search and return names with subdirs in front | 179 :param recursive: recursive search and return names with subdirs in front |
180 """ | 180 """ |
181 | 181 |
182 # remove ending slash for better results | 182 # remove ending slash for better results |
183 path = path.rstrip(os.sep) | 183 path = path.rstrip(os.sep) |
184 log.debug('now scanning in %s location recursive:%s...' % (path, recursive)) | |
184 | 185 |
185 def _get_repos(p): | 186 def _get_repos(p): |
186 if not os.access(p, os.W_OK): | 187 if not os.access(p, os.W_OK): |
187 return | 188 return |
188 for dirpath in os.listdir(p): | 189 for dirpath in os.listdir(p): |
189 if os.path.isfile(os.path.join(p, dirpath)): | 190 if os.path.isfile(os.path.join(p, dirpath)): |
190 continue | 191 continue |
191 cur_path = os.path.join(p, dirpath) | 192 cur_path = os.path.join(p, dirpath) |
193 | |
194 # skip removed repos | |
195 if skip_removed_repos and REMOVED_REPO_PAT.match(dirpath): | |
196 continue | |
197 | |
198 #skip .<somethin> dirs | |
199 if dirpath.startswith('.'): | |
200 continue | |
201 | |
192 try: | 202 try: |
193 scm_info = get_scm(cur_path) | 203 scm_info = get_scm(cur_path) |
194 yield scm_info[1].split(path, 1)[-1].lstrip(os.sep), scm_info | 204 yield scm_info[1].split(path, 1)[-1].lstrip(os.sep), scm_info |
195 except VCSError: | 205 except VCSError: |
196 if not recursive: | 206 if not recursive: |
200 if os.path.isdir(rec_path): | 210 if os.path.isdir(rec_path): |
201 for inner_scm in _get_repos(rec_path): | 211 for inner_scm in _get_repos(rec_path): |
202 yield inner_scm | 212 yield inner_scm |
203 | 213 |
204 return _get_repos(path) | 214 return _get_repos(path) |
215 | |
216 #alias for backward compat | |
217 get_filesystem_repos = get_repos | |
205 | 218 |
206 | 219 |
207 def is_valid_repo(repo_name, base_path, scm=None): | 220 def is_valid_repo(repo_name, base_path, scm=None): |
208 """ | 221 """ |
209 Returns True if given path is a valid repository False otherwise. | 222 Returns True if given path is a valid repository False otherwise. |