Mercurial > kallithea
comparison rhodecode/lib/paster_commands/repo_scan.py @ 3340:f1491bad8339 beta
unified RhodeCode paster commands
- moved them to commont paster_commands package
- re-use sqlalchemy session initializaiton
- some docs updates
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 09 Feb 2013 22:21:31 +0100 |
parents | |
children | a42bfe8a9335 |
comparison
equal
deleted
inserted
replaced
3339:b76a595b7a5e | 3340:f1491bad8339 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 """ | |
3 rhodecode.lib.paster_commands.make_rcextensions | |
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5 | |
6 repo-scan paster command for RhodeCode | |
7 | |
8 | |
9 :created_on: Feb 9, 2013 | |
10 :author: marcink | |
11 :copyright: (C) 2010-2013 Marcin Kuzminski <marcin@python-works.com> | |
12 :license: GPLv3, see COPYING for more details. | |
13 """ | |
14 # This program is free software: you can redistribute it and/or modify | |
15 # it under the terms of the GNU General Public License as published by | |
16 # the Free Software Foundation, either version 3 of the License, or | |
17 # (at your option) any later version. | |
18 # | |
19 # This program is distributed in the hope that it will be useful, | |
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 # GNU General Public License for more details. | |
23 # | |
24 # You should have received a copy of the GNU General Public License | |
25 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
26 from __future__ import with_statement | |
27 | |
28 import os | |
29 import sys | |
30 import logging | |
31 | |
32 from os.path import dirname as dn, join as jn | |
33 from rhodecode.model.scm import ScmModel | |
34 #to get the rhodecode import | |
35 rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
36 sys.path.append(rc_path) | |
37 from rhodecode.lib.utils import BasePasterCommand, repo2db_mapper | |
38 | |
39 from rhodecode.model.db import Repository | |
40 from rhodecode.model.repo import RepoModel | |
41 from rhodecode.model.meta import Session | |
42 | |
43 | |
44 log = logging.getLogger(__name__) | |
45 | |
46 | |
47 class Command(BasePasterCommand): | |
48 | |
49 max_args = 1 | |
50 min_args = 1 | |
51 | |
52 usage = "CONFIG_FILE" | |
53 group_name = "RhodeCode" | |
54 takes_config_file = -1 | |
55 parser = BasePasterCommand.standard_parser(verbose=True) | |
56 summary = "Rescan default location for new repositories" | |
57 | |
58 def command(self): | |
59 #get SqlAlchemy session | |
60 self._init_session() | |
61 rm_obsolete = self.options.delete_obsolete | |
62 log.info('Now scanning root location for new repos...') | |
63 added, removed = repo2db_mapper(ScmModel().repo_scan(), | |
64 remove_obsolete=rm_obsolete) | |
65 added = ','.join(added) or '-' | |
66 removed = ','.join(removed) or '-' | |
67 log.info('Scan completed added:%s removed:%s' % (added, removed)) | |
68 | |
69 def update_parser(self): | |
70 self.parser.add_option('--delete-obsolete', | |
71 action='store_true', | |
72 help="Use this flag do delete repositories that are " | |
73 "present in RhodeCode database but not on the filesystem", | |
74 ) |