Show More
@@ -0,0 +1,28 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | """ | |||
|
3 | rhodecode.model.db_1_6_0 | |||
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~ | |||
|
5 | ||||
|
6 | Database Models for RhodeCode <=1.5.X | |||
|
7 | ||||
|
8 | :created_on: Apr 08, 2010 | |||
|
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 | ||||
|
26 | #TODO: replace that will db.py content after next | |||
|
27 | ||||
|
28 | from rhodecode.model.db import * |
@@ -0,0 +1,36 b'' | |||||
|
1 | import logging | |||
|
2 | import datetime | |||
|
3 | ||||
|
4 | from sqlalchemy import * | |||
|
5 | from sqlalchemy.exc import DatabaseError | |||
|
6 | from sqlalchemy.orm import relation, backref, class_mapper, joinedload | |||
|
7 | from sqlalchemy.orm.session import Session | |||
|
8 | from sqlalchemy.ext.declarative import declarative_base | |||
|
9 | ||||
|
10 | from rhodecode.lib.dbmigrate.migrate import * | |||
|
11 | from rhodecode.lib.dbmigrate.migrate.changeset import * | |||
|
12 | ||||
|
13 | from rhodecode.model.meta import Base | |||
|
14 | from rhodecode.model import meta | |||
|
15 | from rhodecode.lib.dbmigrate.versions import _reset_base | |||
|
16 | ||||
|
17 | log = logging.getLogger(__name__) | |||
|
18 | ||||
|
19 | ||||
|
20 | def upgrade(migrate_engine): | |||
|
21 | """ | |||
|
22 | Upgrade operations go here. | |||
|
23 | Don't create your own engine; bind migrate_engine to your metadata | |||
|
24 | """ | |||
|
25 | _reset_base(migrate_engine) | |||
|
26 | #========================================================================== | |||
|
27 | # USER LOGS | |||
|
28 | #========================================================================== | |||
|
29 | from rhodecode.lib.dbmigrate.schema.db_1_6_0 import RepositoryField | |||
|
30 | tbl = RepositoryField.__table__ | |||
|
31 | tbl.create() | |||
|
32 | ||||
|
33 | ||||
|
34 | def downgrade(migrate_engine): | |||
|
35 | meta = MetaData() | |||
|
36 | meta.bind = migrate_engine |
@@ -43,6 +43,7 b' from sqlalchemy.engine import create_eng' | |||||
43 | from rhodecode.model.repos_group import ReposGroupModel |
|
43 | from rhodecode.model.repos_group import ReposGroupModel | |
44 | #from rhodecode.model import meta |
|
44 | #from rhodecode.model import meta | |
45 | from rhodecode.model.meta import Session, Base |
|
45 | from rhodecode.model.meta import Session, Base | |
|
46 | from rhodecode.model.repo import RepoModel | |||
46 |
|
47 | |||
47 |
|
48 | |||
48 | log = logging.getLogger(__name__) |
|
49 | log = logging.getLogger(__name__) | |
@@ -289,6 +290,9 b' class DbManage(object):' | |||||
289 | def step_10(self): |
|
290 | def step_10(self): | |
290 | pass |
|
291 | pass | |
291 |
|
292 | |||
|
293 | def step_11(self): | |||
|
294 | self.klass.update_repo_info() | |||
|
295 | ||||
292 | upgrade_steps = [0] + range(curr_version + 1, __dbversion__ + 1) |
|
296 | upgrade_steps = [0] + range(curr_version + 1, __dbversion__ + 1) | |
293 |
|
297 | |||
294 | # CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE |
|
298 | # CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE | |
@@ -549,6 +553,9 b' class DbManage(object):' | |||||
549 | self.populate_default_permissions() |
|
553 | self.populate_default_permissions() | |
550 | return fixed |
|
554 | return fixed | |
551 |
|
555 | |||
|
556 | def update_repo_info(self): | |||
|
557 | RepoModel.update_repoinfo() | |||
|
558 | ||||
552 | def config_prompt(self, test_repo_path='', retries=3): |
|
559 | def config_prompt(self, test_repo_path='', retries=3): | |
553 | defaults = self.cli_args |
|
560 | defaults = self.cli_args | |
554 | _path = defaults.get('repos_location') |
|
561 | _path = defaults.get('repos_location') |
@@ -32,9 +32,10 b' import string' | |||||
32 |
|
32 | |||
33 | from os.path import dirname as dn, join as jn |
|
33 | from os.path import dirname as dn, join as jn | |
34 | from rhodecode.model import init_model |
|
34 | from rhodecode.model import init_model | |
35 |
from rhodecode.lib.utils2 import engine_from_config |
|
35 | from rhodecode.lib.utils2 import engine_from_config | |
36 |
from rhodecode.model.db import |
|
36 | from rhodecode.model.db import Repository | |
37 | from rhodecode.lib.vcs.backends.base import EmptyChangeset |
|
37 | from rhodecode.model.repo import RepoModel | |
|
38 | from rhodecode.model.meta import Session | |||
38 |
|
39 | |||
39 |
|
40 | |||
40 | #to get the rhodecode import |
|
41 | #to get the rhodecode import | |
@@ -70,13 +71,12 b' class UpdateCommand(BasePasterCommand):' | |||||
70 | if self.options.repo_update_list else None |
|
71 | if self.options.repo_update_list else None | |
71 |
|
72 | |||
72 | if repo_update_list: |
|
73 | if repo_update_list: | |
73 |
repo_list = Repository.query() |
|
74 | repo_list = Repository.query()\ | |
|
75 | .filter(Repository.repo_name.in_(repo_update_list)) | |||
74 | else: |
|
76 | else: | |
75 | repo_list = Repository.getAll() |
|
77 | repo_list = Repository.getAll() | |
76 | for repo in repo_list: |
|
78 | RepoModel.update_repoinfo(repositories=repo_list) | |
77 | last_cs = (repo.scm_instance.get_changeset() if repo.scm_instance |
|
79 | Session().commit() | |
78 | else EmptyChangeset()) |
|
|||
79 | repo.update_changeset_cache(last_cs) |
|
|||
80 |
|
80 | |||
81 | def update_parser(self): |
|
81 | def update_parser(self): | |
82 | self.parser.add_option('--update-only', |
|
82 | self.parser.add_option('--update-only', |
@@ -42,6 +42,7 b' from rhodecode.model.db import Repositor' | |||||
42 | RhodeCodeSetting, RepositoryField |
|
42 | RhodeCodeSetting, RepositoryField | |
43 | from rhodecode.lib import helpers as h |
|
43 | from rhodecode.lib import helpers as h | |
44 | from rhodecode.lib.auth import HasRepoPermissionAny |
|
44 | from rhodecode.lib.auth import HasRepoPermissionAny | |
|
45 | from rhodecode.lib.vcs.backends.base import EmptyChangeset | |||
45 |
|
46 | |||
46 |
|
47 | |||
47 | log = logging.getLogger(__name__) |
|
48 | log = logging.getLogger(__name__) | |
@@ -143,6 +144,17 b' class RepoModel(BaseModel):' | |||||
143 | kwargs.update(dict(_=_, h=h, c=c)) |
|
144 | kwargs.update(dict(_=_, h=h, c=c)) | |
144 | return tmpl.render(*args, **kwargs) |
|
145 | return tmpl.render(*args, **kwargs) | |
145 |
|
146 | |||
|
147 | @classmethod | |||
|
148 | def update_repoinfo(cls, repositories=None): | |||
|
149 | if not repositories: | |||
|
150 | repositories = Repository.getAll() | |||
|
151 | for repo in repositories: | |||
|
152 | scm_repo = repo.scm_instance_no_cache | |||
|
153 | last_cs = EmptyChangeset() | |||
|
154 | if scm_repo: | |||
|
155 | last_cs = scm_repo.get_changeset() | |||
|
156 | repo.update_changeset_cache(last_cs) | |||
|
157 | ||||
146 | def get_repos_as_dict(self, repos_list=None, admin=False, perm_check=True, |
|
158 | def get_repos_as_dict(self, repos_list=None, admin=False, perm_check=True, | |
147 | super_user_actions=False): |
|
159 | super_user_actions=False): | |
148 | _render = self._render_datatable |
|
160 | _render = self._render_datatable |
General Comments 0
You need to be logged in to leave comments.
Login now