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