comparison rhodecode/lib/paster_commands/update_repoinfo.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 rhodecode/lib/update_repoinfo.py@968b28545f93
children e08321d4c106
comparison
equal deleted inserted replaced
3339:b76a595b7a5e 3340:f1491bad8339
1 # -*- coding: utf-8 -*-
2 """
3 rhodecode.lib.paster_commands.make_rcextensions
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
6 uodate-repoinfo paster command for RhodeCode
7
8 :created_on: Jul 14, 2012
9 :author: marcink
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 from __future__ import with_statement
26
27 import os
28 import sys
29 import logging
30 import string
31
32 from os.path import dirname as dn, join as jn
33 #to get the rhodecode import
34 rc_path = dn(dn(dn(os.path.realpath(__file__))))
35 sys.path.append(rc_path)
36 from rhodecode.lib.utils import BasePasterCommand
37
38 from rhodecode.model.db import Repository
39 from rhodecode.model.repo import RepoModel
40 from rhodecode.model.meta import Session
41
42 log = logging.getLogger(__name__)
43
44
45 class Command(BasePasterCommand):
46
47 max_args = 1
48 min_args = 1
49
50 usage = "CONFIG_FILE"
51 group_name = "RhodeCode"
52 takes_config_file = -1
53 parser = BasePasterCommand.standard_parser(verbose=True)
54 summary = "Updates repositories caches for last changeset"
55
56 def command(self):
57 #get SqlAlchemy session
58 self._init_session()
59
60 repo_update_list = map(string.strip,
61 self.options.repo_update_list.split(',')) \
62 if self.options.repo_update_list else None
63
64 if repo_update_list:
65 repo_list = Repository.query()\
66 .filter(Repository.repo_name.in_(repo_update_list))
67 else:
68 repo_list = Repository.getAll()
69 RepoModel.update_repoinfo(repositories=repo_list)
70 Session().commit()
71 log.info('Updated cache for %s repositories' % (len(repo_list)))
72
73 def update_parser(self):
74 self.parser.add_option('--update-only',
75 action='store',
76 dest='repo_update_list',
77 help="Specifies a comma separated list of repositores "
78 "to update last commit info for. OPTIONAL",
79 )