Mercurial > kallithea
comparison rhodecode/lib/utils.py @ 2899:c76aa8b06179 beta
Fix typos.
author | Andrew Shadura <bugzilla@tut.by> |
---|---|
date | Mon, 08 Oct 2012 00:08:46 +0200 |
parents | 84414d73c233 |
children | 8c54b294d3e4 |
comparison
equal
deleted
inserted
replaced
2898:74672d4bdbee | 2899:c76aa8b06179 |
---|---|
134 if hasattr(user, 'user_id'): | 134 if hasattr(user, 'user_id'): |
135 user_obj = user | 135 user_obj = user |
136 elif isinstance(user, basestring): | 136 elif isinstance(user, basestring): |
137 user_obj = User.get_by_username(user) | 137 user_obj = User.get_by_username(user) |
138 else: | 138 else: |
139 raise Exception('You have to provide user object or username') | 139 raise Exception('You have to provide a user object or a username') |
140 | 140 |
141 if hasattr(repo, 'repo_id'): | 141 if hasattr(repo, 'repo_id'): |
142 repo_obj = Repository.get(repo.repo_id) | 142 repo_obj = Repository.get(repo.repo_id) |
143 repo_name = repo_obj.repo_name | 143 repo_name = repo_obj.repo_name |
144 elif isinstance(repo, basestring): | 144 elif isinstance(repo, basestring): |
253 return True | 253 return True |
254 | 254 |
255 return False | 255 return False |
256 | 256 |
257 | 257 |
258 def ask_ok(prompt, retries=4, complaint='Yes or no, please!'): | 258 def ask_ok(prompt, retries=4, complaint='Yes or no please!'): |
259 while True: | 259 while True: |
260 ok = raw_input(prompt) | 260 ok = raw_input(prompt) |
261 if ok in ('y', 'ye', 'yes'): | 261 if ok in ('y', 'ye', 'yes'): |
262 return True | 262 return True |
263 if ok in ('n', 'no', 'nop', 'nope'): | 263 if ok in ('n', 'no', 'nop', 'nope'): |
297 baseui._ucfg = config.config() | 297 baseui._ucfg = config.config() |
298 baseui._tcfg = config.config() | 298 baseui._tcfg = config.config() |
299 | 299 |
300 if read_from == 'file': | 300 if read_from == 'file': |
301 if not os.path.isfile(path): | 301 if not os.path.isfile(path): |
302 log.debug('hgrc file is not present at %s skipping...' % path) | 302 log.debug('hgrc file is not present at %s, skipping...' % path) |
303 return False | 303 return False |
304 log.debug('reading hgrc from %s' % path) | 304 log.debug('reading hgrc from %s' % path) |
305 cfg = config.config() | 305 cfg = config.config() |
306 cfg.read(path) | 306 cfg.read(path) |
307 for section in ui_sections: | 307 for section in ui_sections: |
408 from rhodecode.model.scm import ScmModel | 408 from rhodecode.model.scm import ScmModel |
409 sa = meta.Session() | 409 sa = meta.Session() |
410 rm = RepoModel() | 410 rm = RepoModel() |
411 user = sa.query(User).filter(User.admin == True).first() | 411 user = sa.query(User).filter(User.admin == True).first() |
412 if user is None: | 412 if user is None: |
413 raise Exception('Missing administrative account !') | 413 raise Exception('Missing administrative account!') |
414 added = [] | 414 added = [] |
415 | 415 |
416 # # clear cache keys | 416 # # clear cache keys |
417 # log.debug("Clearing cache keys now...") | 417 # log.debug("Clearing cache keys now...") |
418 # CacheInvalidation.clear_cache() | 418 # CacheInvalidation.clear_cache() |
421 for name, repo in initial_repo_list.items(): | 421 for name, repo in initial_repo_list.items(): |
422 group = map_groups(name) | 422 group = map_groups(name) |
423 db_repo = rm.get_by_repo_name(name) | 423 db_repo = rm.get_by_repo_name(name) |
424 # found repo that is on filesystem not in RhodeCode database | 424 # found repo that is on filesystem not in RhodeCode database |
425 if not db_repo: | 425 if not db_repo: |
426 log.info('repository %s not found creating now' % name) | 426 log.info('repository %s not found, creating now' % name) |
427 added.append(name) | 427 added.append(name) |
428 desc = (repo.description | 428 desc = (repo.description |
429 if repo.description != 'unknown' | 429 if repo.description != 'unknown' |
430 else '%s repository' % name) | 430 else '%s repository' % name) |
431 new_repo = rm.create_repo( | 431 new_repo = rm.create_repo( |
444 if db_repo.repo_type == 'git': | 444 if db_repo.repo_type == 'git': |
445 ScmModel().install_git_hook(db_repo.scm_instance) | 445 ScmModel().install_git_hook(db_repo.scm_instance) |
446 # during starting install all cache keys for all repositories in the | 446 # during starting install all cache keys for all repositories in the |
447 # system, this will register all repos and multiple instances | 447 # system, this will register all repos and multiple instances |
448 key, _prefix, _org_key = CacheInvalidation._get_key(name) | 448 key, _prefix, _org_key = CacheInvalidation._get_key(name) |
449 log.debug("Creating cache key for %s instance_id:`%s`" % (name, _prefix)) | 449 log.debug("Creating a cache key for %s instance_id:`%s`" % (name, _prefix)) |
450 CacheInvalidation._get_or_create_key(key, _prefix, _org_key, commit=False) | 450 CacheInvalidation._get_or_create_key(key, _prefix, _org_key, commit=False) |
451 sa.commit() | 451 sa.commit() |
452 removed = [] | 452 removed = [] |
453 if remove_obsolete: | 453 if remove_obsolete: |
454 # remove from database those repositories that are not in the filesystem | 454 # remove from database those repositories that are not in the filesystem |
455 for repo in sa.query(Repository).all(): | 455 for repo in sa.query(Repository).all(): |
456 if repo.repo_name not in initial_repo_list.keys(): | 456 if repo.repo_name not in initial_repo_list.keys(): |
457 log.debug("Removing non existing repository found in db `%s`" % | 457 log.debug("Removing non-existing repository found in db `%s`" % |
458 repo.repo_name) | 458 repo.repo_name) |
459 try: | 459 try: |
460 sa.delete(repo) | 460 sa.delete(repo) |
461 sa.commit() | 461 sa.commit() |
462 removed.append(repo.repo_name) | 462 removed.append(repo.repo_name) |
675 | 675 |
676 | 676 |
677 def check_git_version(): | 677 def check_git_version(): |
678 """ | 678 """ |
679 Checks what version of git is installed in system, and issues a warning | 679 Checks what version of git is installed in system, and issues a warning |
680 if it's to old for RhodeCode to properly work. | 680 if it's too old for RhodeCode to properly work. |
681 """ | 681 """ |
682 import subprocess | 682 import subprocess |
683 from distutils.version import StrictVersion | 683 from distutils.version import StrictVersion |
684 from rhodecode import BACKENDS | 684 from rhodecode import BACKENDS |
685 | 685 |
701 if 'git' in BACKENDS: | 701 if 'git' in BACKENDS: |
702 log.debug('GIT version detected: %s' % stdout) | 702 log.debug('GIT version detected: %s' % stdout) |
703 if stderr: | 703 if stderr: |
704 log.warning('Unable to detect git version org error was:%r' % stderr) | 704 log.warning('Unable to detect git version org error was:%r' % stderr) |
705 elif to_old_git: | 705 elif to_old_git: |
706 log.warning('RhodeCode detected git version %s, which is to old ' | 706 log.warning('RhodeCode detected git version %s, which is too old ' |
707 'for the system to function properly make sure ' | 707 'for the system to function properly. Make sure ' |
708 'it is at least in version %s' % (ver, req_ver)) | 708 'it is at least in version %s' % (ver, req_ver)) |
709 return _ver | 709 return _ver |