annotate rhodecode/lib/paster_commands/update_repoinfo.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl

Imported some of the GPLv3'd changes from RhodeCode v2.2.5. This imports changes between changesets 21af6c4eab3d and 6177597791c2 in RhodeCode's original repository, including only changes to Python files and HTML. RhodeCode clearly licensed its changes to these files under GPLv3 in their /LICENSE file, which states the following: The Python code and integrated HTML are licensed under the GPLv3 license. (See: https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE or http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE for an online copy of that LICENSE file) Conservancy reviewed these changes and confirmed that they can be licensed as a whole to the Kallithea project under GPLv3-only. While some of the contents committed herein are clearly licensed GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the statement above from RhodeCode indicates that they intend GPLv3-only as their license, per GPLv3ยง14 and other relevant sections of GPLv3.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:03:13 -0400
parents a42bfe8a9335
children e9f6b533a8f6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 # This program is free software: you can redistribute it and/or modify
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 # it under the terms of the GNU General Public License as published by
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 # the Free Software Foundation, either version 3 of the License, or
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 # (at your option) any later version.
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 #
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # This program is distributed in the hope that it will be useful,
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 # GNU General Public License for more details.
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 #
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # You should have received a copy of the GNU General Public License
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
14 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
15 rhodecode.lib.paster_commands.make_rcextensions
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
17
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
18 uodate-repoinfo paster command for RhodeCode
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
19
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
20 :created_on: Jul 14, 2012
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
21 :author: marcink
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
22 :copyright: (c) 2013 RhodeCode GmbH.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
23 :license: GPLv3, see LICENSE for more details.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
24 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3915
diff changeset
25
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 from __future__ import with_statement
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 import os
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 import sys
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 import logging
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 import string
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32
3340
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3334
diff changeset
33 from rhodecode.lib.utils import BasePasterCommand
3309
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
34 from rhodecode.model.db import Repository
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
35 from rhodecode.model.repo import RepoModel
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
36 from rhodecode.model.meta import Session
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37
3915
a42bfe8a9335 moved make-index command to paster_commands module
Marcin Kuzminski <marcin@python-works.com>
parents: 3662
diff changeset
38 # fix rhodecode import
a42bfe8a9335 moved make-index command to paster_commands module
Marcin Kuzminski <marcin@python-works.com>
parents: 3662
diff changeset
39 from os.path import dirname as dn
a42bfe8a9335 moved make-index command to paster_commands module
Marcin Kuzminski <marcin@python-works.com>
parents: 3662
diff changeset
40 rc_path = dn(dn(dn(os.path.realpath(__file__))))
a42bfe8a9335 moved make-index command to paster_commands module
Marcin Kuzminski <marcin@python-works.com>
parents: 3662
diff changeset
41 sys.path.append(rc_path)
a42bfe8a9335 moved make-index command to paster_commands module
Marcin Kuzminski <marcin@python-works.com>
parents: 3662
diff changeset
42
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 log = logging.getLogger(__name__)
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
3340
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3334
diff changeset
46 class Command(BasePasterCommand):
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 max_args = 1
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 min_args = 1
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 usage = "CONFIG_FILE"
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 group_name = "RhodeCode"
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 takes_config_file = -1
3340
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3334
diff changeset
54 parser = BasePasterCommand.standard_parser(verbose=True)
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3334
diff changeset
55 summary = "Updates repositories caches for last changeset"
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 def command(self):
3340
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3334
diff changeset
58 #get SqlAlchemy session
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3334
diff changeset
59 self._init_session()
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 repo_update_list = map(string.strip,
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 self.options.repo_update_list.split(',')) \
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 if self.options.repo_update_list else None
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 if repo_update_list:
3309
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
66 repo_list = Repository.query()\
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
67 .filter(Repository.repo_name.in_(repo_update_list))
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 else:
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 repo_list = Repository.getAll()
3309
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
70 RepoModel.update_repoinfo(repositories=repo_list)
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
71 Session().commit()
3523
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
72
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
73 if self.options.invalidate_cache:
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
74 for r in repo_list:
3662
93795b901b32 update_repoinfo: fix invalidation
Mads Kiilerich <madski@unity3d.com>
parents: 3523
diff changeset
75 r.set_invalidate()
3340
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3334
diff changeset
76 log.info('Updated cache for %s repositories' % (len(repo_list)))
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 def update_parser(self):
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 self.parser.add_option('--update-only',
3523
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
80 action='store',
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
81 dest='repo_update_list',
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
82 help="Specifies a comma separated list of repositores "
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
83 "to update last commit info for. OPTIONAL")
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
84 self.parser.add_option('--invalidate-cache',
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
85 action='store_true',
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
86 dest='invalidate_cache',
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
87 help="Trigger cache invalidation event for repos. "
e08321d4c106 add --invalidate-cache option to update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3340
diff changeset
88 "OPTIONAL")