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