Mercurial > kallithea
annotate rhodecode/model/scm.py @ 1324:e272be3244f0 beta
fixed regresion made in previos commit, that introduced bug in handling regular repositories
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 12 May 2011 00:37:40 +0200 |
parents | 70a5a9a57864 |
children | a04fe5986109 |
rev | line source |
---|---|
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
1 # -*- coding: utf-8 -*- |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
2 """ |
811 | 3 rhodecode.model.scm |
4 ~~~~~~~~~~~~~~~~~~~ | |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
5 |
811 | 6 Scm model for RhodeCode |
7 | |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
8 :created_on: Apr 9, 2010 |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
9 :author: marcink |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
12 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
16 # (at your option) any later version. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
17 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
21 # GNU General Public License for more details. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
22 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
25 import os |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
26 import time |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
27 import traceback |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
28 import logging |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
29 |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1005
diff
changeset
|
30 from mercurial import ui |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1005
diff
changeset
|
31 |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1005
diff
changeset
|
32 from sqlalchemy.exc import DatabaseError |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1042
diff
changeset
|
33 from sqlalchemy.orm import make_transient |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1005
diff
changeset
|
34 |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1005
diff
changeset
|
35 from beaker.cache import cache_region, region_invalidate |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1005
diff
changeset
|
36 |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
37 from vcs import get_backend |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
38 from vcs.utils.helpers import get_scm |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
39 from vcs.exceptions import RepositoryError, VCSError |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
40 from vcs.utils.lazy import LazyProperty |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
41 from vcs.nodes import FileNode |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
42 |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
693
diff
changeset
|
43 from rhodecode import BACKENDS |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
535
diff
changeset
|
44 from rhodecode.lib import helpers as h |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
535
diff
changeset
|
45 from rhodecode.lib.auth import HasRepoPermissionAny |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
46 from rhodecode.lib.utils import get_repos as get_filesystem_repos, make_ui, \ |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
47 action_logger |
752
89b9037d68b7
fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents:
747
diff
changeset
|
48 from rhodecode.model import BaseModel |
758 | 49 from rhodecode.model.user import UserModel |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
50 from rhodecode.model.repo import RepoModel |
758 | 51 from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \ |
784
30d3161c6683
Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
767
diff
changeset
|
52 UserFollowing, UserLog |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
53 from rhodecode.model.caching_query import FromCache |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
54 |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
55 log = logging.getLogger(__name__) |
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
56 |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
57 |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
58 class UserTemp(object): |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
59 def __init__(self, user_id): |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
60 self.user_id = user_id |
901
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
61 |
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
62 def __repr__(self): |
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
63 return "<%s('id:%s')>" % (self.__class__.__name__, self.user_id) |
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
64 |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
65 |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
66 class RepoTemp(object): |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
67 def __init__(self, repo_id): |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
68 self.repo_id = repo_id |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
69 |
901
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
70 def __repr__(self): |
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
71 return "<%s('id:%s')>" % (self.__class__.__name__, self.repo_id) |
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
72 |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
73 |
752
89b9037d68b7
fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents:
747
diff
changeset
|
74 class ScmModel(BaseModel): |
811 | 75 """Generic Scm Model |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
76 """ |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
77 |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
78 @LazyProperty |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
79 def repos_path(self): |
811 | 80 """Get's the repositories root path from database |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
81 """ |
811 | 82 |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
83 q = self.sa.query(RhodeCodeUi).filter(RhodeCodeUi.ui_key == '/').one() |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
84 |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
85 return q.ui_value |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
86 |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
87 def repo_scan(self, repos_path=None): |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
88 """Listing of repositories in given path. This path should not be a |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
89 repository itself. Return a dictionary of repository objects |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
90 |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
91 :param repos_path: path to directory containing repositories |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
92 """ |
811 | 93 |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
94 log.info('scanning for repositories in %s', repos_path) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
95 |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
96 if repos_path is None: |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
97 repos_path = self.repos_path |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
98 |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
99 baseui = make_ui('db') |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
100 repos_list = {} |
690
4685f3eafd35
Fixed sumamry page description bug
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
101 |
877
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
851
diff
changeset
|
102 for name, path in get_filesystem_repos(repos_path, recursive=True): |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
103 try: |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
104 if name in repos_list: |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
105 raise RepositoryError('Duplicate repository name %s ' |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
106 'found in %s' % (name, path)) |
248
fb7f066126cc
Added support for repository located in subdirectories.
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
107 else: |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
108 |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
109 klass = get_backend(path[0]) |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
110 |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
693
diff
changeset
|
111 if path[0] == 'hg' and path[0] in BACKENDS.keys(): |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
112 repos_list[name] = klass(path[1], baseui=baseui) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
113 |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
693
diff
changeset
|
114 if path[0] == 'git' and path[0] in BACKENDS.keys(): |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
115 repos_list[name] = klass(path[1]) |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
116 except OSError: |
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
117 continue |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
118 |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
119 return repos_list |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
120 |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
121 def get_repos(self, all_repos=None): |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
122 """Get all repos from db and for each repo create it's |
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
123 backend instance and fill that backed with information from database |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
124 |
690
4685f3eafd35
Fixed sumamry page description bug
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
125 :param all_repos: give specific repositories list, good for filtering |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1042
diff
changeset
|
126 this have to be a list of just the repository names |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
127 """ |
767
632b0761e617
bugfix, when user had no repos he would see all repos in my account, (correct commit)
Marcin Kuzminski <marcin@python-works.com>
parents:
758
diff
changeset
|
128 if all_repos is None: |
1193
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1114
diff
changeset
|
129 repos = self.sa.query(Repository)\ |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1114
diff
changeset
|
130 .order_by(Repository.repo_name).all() |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1114
diff
changeset
|
131 all_repos = [r.repo_name for r in repos] |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
132 |
791
06a98912325c
fixed bug when invalidation was making to many queries when there was no list of invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
784
diff
changeset
|
133 #get the repositories that should be invalidated |
726
04c4e5f94cee
cache list speed improvement
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
134 invalidation_list = [str(x.cache_key) for x in \ |
04c4e5f94cee
cache list speed improvement
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
135 self.sa.query(CacheInvalidation.cache_key)\ |
04c4e5f94cee
cache list speed improvement
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
136 .filter(CacheInvalidation.cache_active == False)\ |
04c4e5f94cee
cache list speed improvement
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
137 .all()] |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1042
diff
changeset
|
138 for r_name in all_repos: |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1042
diff
changeset
|
139 r_dbr = self.get(r_name, invalidation_list) |
1042
ab0a2b69d082
bugfix for getting proper values from cache
Marcin Kuzminski <marcin@python-works.com>
parents:
1039
diff
changeset
|
140 if r_dbr is not None: |
ab0a2b69d082
bugfix for getting proper values from cache
Marcin Kuzminski <marcin@python-works.com>
parents:
1039
diff
changeset
|
141 repo, dbrepo = r_dbr |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1042
diff
changeset
|
142 |
1255
c93234e9ac36
fixes issue #163 RhodeCode will check and report a corrupted repo. A rescan with destroy old data should be perform after such operations
Marcin Kuzminski <marcin@python-works.com>
parents:
1229
diff
changeset
|
143 if repo is None or dbrepo is None: |
1265
08ac2c3ae810
added some info to corrupted repo message that helps diagnose the cause from log itself.
Marcin Kuzminski <marcin@python-works.com>
parents:
1255
diff
changeset
|
144 log.error('Repository "%s" looks somehow corrupted ' |
08ac2c3ae810
added some info to corrupted repo message that helps diagnose the cause from log itself.
Marcin Kuzminski <marcin@python-works.com>
parents:
1255
diff
changeset
|
145 'fs-repo:%s,db-repo:%s both values should be ' |
08ac2c3ae810
added some info to corrupted repo message that helps diagnose the cause from log itself.
Marcin Kuzminski <marcin@python-works.com>
parents:
1255
diff
changeset
|
146 'present', r_name, repo, dbrepo) |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
147 continue |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
148 last_change = repo.last_change |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
149 tip = h.get_changeset_safe(repo, 'tip') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
150 |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
151 tmp_d = {} |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1042
diff
changeset
|
152 tmp_d['name'] = dbrepo.repo_name |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
153 tmp_d['name_sort'] = tmp_d['name'].lower() |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
154 tmp_d['description'] = dbrepo.description |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
155 tmp_d['description_sort'] = tmp_d['description'] |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
156 tmp_d['last_change'] = last_change |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
157 tmp_d['last_change_sort'] = time.mktime(last_change \ |
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
158 .timetuple()) |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
159 tmp_d['tip'] = tip.raw_id |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
160 tmp_d['tip_sort'] = tip.revision |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
161 tmp_d['rev'] = tip.revision |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
162 tmp_d['contact'] = dbrepo.user.full_contact |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
163 tmp_d['contact_sort'] = tmp_d['contact'] |
1005
520e67cbb494
fixed sorting in maing page by owners
Marcin Kuzminski <marcin@python-works.com>
parents:
999
diff
changeset
|
164 tmp_d['owner_sort'] = tmp_d['contact'] |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
165 tmp_d['repo_archives'] = list(repo._get_archives()) |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
166 tmp_d['last_msg'] = tip.message |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
167 tmp_d['repo'] = repo |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1042
diff
changeset
|
168 tmp_d['dbrepo'] = dbrepo.get_dict() |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
169 tmp_d['dbrepo_fork'] = dbrepo.fork.get_dict() if dbrepo.fork \ |
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
170 else {} |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
171 yield tmp_d |
74
cdf4fda66dd9
Started summary page. Added filters to templates. used by n,self.f.filtername prefixed by n to disable other filters. Few other fixes found
Marcin Kuzminski <marcin@python-blog.com>
parents:
73
diff
changeset
|
172 |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
173 def get(self, repo_name, invalidation_list=None, retval='all'): |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
174 """Returns a tuple of Repository,DbRepository, |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
175 Get's repository from given name, creates BackendInstance and |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
176 propagates it's data from database with all additional information |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
177 |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
178 :param repo_name: |
791
06a98912325c
fixed bug when invalidation was making to many queries when there was no list of invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
784
diff
changeset
|
179 :param invalidation_list: if a invalidation list is given the get |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
180 method should not manually check if this repository needs |
791
06a98912325c
fixed bug when invalidation was making to many queries when there was no list of invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
784
diff
changeset
|
181 invalidation and just invalidate the repositories in list |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
182 :param retval: string specifing what to return one of 'repo','dbrepo', |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
183 'all'if repo or dbrepo is given it'll just lazy load chosen type |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
184 and return None as the second |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
185 """ |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
186 if not HasRepoPermissionAny('repository.read', 'repository.write', |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
187 'repository.admin')(repo_name, 'get repo check'): |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
188 return |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
189 |
791
06a98912325c
fixed bug when invalidation was making to many queries when there was no list of invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
784
diff
changeset
|
190 #====================================================================== |
06a98912325c
fixed bug when invalidation was making to many queries when there was no list of invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
784
diff
changeset
|
191 # CACHE FUNCTION |
06a98912325c
fixed bug when invalidation was making to many queries when there was no list of invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
784
diff
changeset
|
192 #====================================================================== |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
193 @cache_region('long_term') |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
194 def _get_repo(repo_name): |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
195 |
690
4685f3eafd35
Fixed sumamry page description bug
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
196 repo_path = os.path.join(self.repos_path, repo_name) |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
197 |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
198 try: |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
199 alias = get_scm(repo_path)[0] |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
200 log.debug('Creating instance of %s repository', alias) |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
201 backend = get_backend(alias) |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
202 except VCSError: |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
203 log.error(traceback.format_exc()) |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
204 log.error('Perhaps this repository is in db and not in ' |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
205 'filesystem run rescan repositories with ' |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
206 '"destroy old data " option from admin panel') |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
207 return |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
208 |
690
4685f3eafd35
Fixed sumamry page description bug
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
209 if alias == 'hg': |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
210 repo = backend(repo_path, create=False, baseui=make_ui('db')) |
690
4685f3eafd35
Fixed sumamry page description bug
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
211 #skip hidden web repository |
4685f3eafd35
Fixed sumamry page description bug
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
212 if repo._get_hidden(): |
4685f3eafd35
Fixed sumamry page description bug
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
213 return |
4685f3eafd35
Fixed sumamry page description bug
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
214 else: |
4685f3eafd35
Fixed sumamry page description bug
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
215 repo = backend(repo_path, create=False) |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
216 |
535
72778dda34cf
some fixups in cache, added fallback and cache invalidation when key not found in cached repos list,
Marcin Kuzminski <marcin@python-works.com>
parents:
531
diff
changeset
|
217 return repo |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
218 |
792
4c16ed1eb699
fixed bug introduced in latest commit
Marcin Kuzminski <marcin@python-works.com>
parents:
791
diff
changeset
|
219 pre_invalidate = True |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
220 dbinvalidate = False |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
221 |
792
4c16ed1eb699
fixed bug introduced in latest commit
Marcin Kuzminski <marcin@python-works.com>
parents:
791
diff
changeset
|
222 if invalidation_list is not None: |
4c16ed1eb699
fixed bug introduced in latest commit
Marcin Kuzminski <marcin@python-works.com>
parents:
791
diff
changeset
|
223 pre_invalidate = repo_name in invalidation_list |
4c16ed1eb699
fixed bug introduced in latest commit
Marcin Kuzminski <marcin@python-works.com>
parents:
791
diff
changeset
|
224 |
4c16ed1eb699
fixed bug introduced in latest commit
Marcin Kuzminski <marcin@python-works.com>
parents:
791
diff
changeset
|
225 if pre_invalidate: |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
226 #this returns object to invalidate |
792
4c16ed1eb699
fixed bug introduced in latest commit
Marcin Kuzminski <marcin@python-works.com>
parents:
791
diff
changeset
|
227 invalidate = self._should_invalidate(repo_name) |
4c16ed1eb699
fixed bug introduced in latest commit
Marcin Kuzminski <marcin@python-works.com>
parents:
791
diff
changeset
|
228 if invalidate: |
4c16ed1eb699
fixed bug introduced in latest commit
Marcin Kuzminski <marcin@python-works.com>
parents:
791
diff
changeset
|
229 log.info('invalidating cache for repository %s', repo_name) |
1039
51b70569c330
extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents:
1038
diff
changeset
|
230 region_invalidate(_get_repo, None, repo_name) |
792
4c16ed1eb699
fixed bug introduced in latest commit
Marcin Kuzminski <marcin@python-works.com>
parents:
791
diff
changeset
|
231 self._mark_invalidated(invalidate) |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
232 dbinvalidate = True |
792
4c16ed1eb699
fixed bug introduced in latest commit
Marcin Kuzminski <marcin@python-works.com>
parents:
791
diff
changeset
|
233 |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
234 r, dbr = None, None |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
235 if retval == 'repo' or 'all': |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
236 r = _get_repo(repo_name) |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
237 if retval == 'dbrepo' or 'all': |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1042
diff
changeset
|
238 dbr = RepoModel().get_full(repo_name, cache=True, |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
239 invalidate=dbinvalidate) |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
240 |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
241 return r, dbr |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
242 |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
243 def mark_for_invalidation(self, repo_name): |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
244 """Puts cache invalidation task into db for |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
245 further global cache invalidation |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
246 |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
247 :param repo_name: this repo that should invalidation take place |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
248 """ |
811 | 249 |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
250 log.debug('marking %s for invalidation', repo_name) |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
251 cache = self.sa.query(CacheInvalidation)\ |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
252 .filter(CacheInvalidation.cache_key == repo_name).scalar() |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
253 |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
254 if cache: |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
255 #mark this cache as inactive |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
256 cache.cache_active = False |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
257 else: |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
258 log.debug('cache key not found in invalidation db -> creating one') |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
259 cache = CacheInvalidation(repo_name) |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
260 |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
261 try: |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
262 self.sa.add(cache) |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
263 self.sa.commit() |
758 | 264 except (DatabaseError,): |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
265 log.error(traceback.format_exc()) |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
266 self.sa.rollback() |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
267 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
268 def toggle_following_repo(self, follow_repo_id, user_id): |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
269 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
270 f = self.sa.query(UserFollowing)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
271 .filter(UserFollowing.follows_repo_id == follow_repo_id)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
272 .filter(UserFollowing.user_id == user_id).scalar() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
273 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
274 if f is not None: |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
275 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
276 try: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
277 self.sa.delete(f) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
278 self.sa.commit() |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
279 action_logger(UserTemp(user_id), |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
280 'stopped_following_repo', |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
281 RepoTemp(follow_repo_id)) |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
282 return |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
283 except: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
284 log.error(traceback.format_exc()) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
285 self.sa.rollback() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
286 raise |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
287 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
288 try: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
289 f = UserFollowing() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
290 f.user_id = user_id |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
291 f.follows_repo_id = follow_repo_id |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
292 self.sa.add(f) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
293 self.sa.commit() |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
294 action_logger(UserTemp(user_id), |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
295 'started_following_repo', |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
296 RepoTemp(follow_repo_id)) |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
297 except: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
298 log.error(traceback.format_exc()) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
299 self.sa.rollback() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
300 raise |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
301 |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
302 def toggle_following_user(self, follow_user_id, user_id): |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
303 f = self.sa.query(UserFollowing)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
304 .filter(UserFollowing.follows_user_id == follow_user_id)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
305 .filter(UserFollowing.user_id == user_id).scalar() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
306 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
307 if f is not None: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
308 try: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
309 self.sa.delete(f) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
310 self.sa.commit() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
311 return |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
312 except: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
313 log.error(traceback.format_exc()) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
314 self.sa.rollback() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
315 raise |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
316 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
317 try: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
318 f = UserFollowing() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
319 f.user_id = user_id |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
320 f.follows_user_id = follow_user_id |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
321 self.sa.add(f) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
322 self.sa.commit() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
323 except: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
324 log.error(traceback.format_exc()) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
325 self.sa.rollback() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
326 raise |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
327 |
999
1951c35483ab
fixed following js snipet. It' can be called multiple times now next to each repository
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
328 def is_following_repo(self, repo_name, user_id, cache=False): |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
329 r = self.sa.query(Repository)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
330 .filter(Repository.repo_name == repo_name).scalar() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
331 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
332 f = self.sa.query(UserFollowing)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
333 .filter(UserFollowing.follows_repository == r)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
334 .filter(UserFollowing.user_id == user_id).scalar() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
335 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
336 return f is not None |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
337 |
999
1951c35483ab
fixed following js snipet. It' can be called multiple times now next to each repository
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
338 def is_following_user(self, username, user_id, cache=False): |
758 | 339 u = UserModel(self.sa).get_by_username(username) |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
340 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
341 f = self.sa.query(UserFollowing)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
342 .filter(UserFollowing.follows_user == u)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
343 .filter(UserFollowing.user_id == user_id).scalar() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
344 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
345 return f is not None |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
346 |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
347 def get_followers(self, repo_id): |
1282
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
348 if not isinstance(repo_id, int): |
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
349 repo_id = getattr(Repository.by_repo_name(repo_id), 'repo_id') |
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
350 |
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
351 return self.sa.query(UserFollowing)\ |
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
352 .filter(UserFollowing.follows_repo_id == repo_id).count() |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
353 |
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
354 def get_forks(self, repo_id): |
1282
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
355 if not isinstance(repo_id, int): |
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
356 repo_id = getattr(Repository.by_repo_name(repo_id), 'repo_id') |
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
357 |
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
358 return self.sa.query(Repository)\ |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
359 .filter(Repository.fork_id == repo_id).count() |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
360 |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
361 def pull_changes(self, repo_name, username): |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
362 repo, dbrepo = self.get(repo_name, retval='all') |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
363 |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
364 try: |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
365 extras = {'ip': '', |
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
366 'username': username, |
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
367 'action': 'push_remote', |
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
368 'repository': repo_name} |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
369 |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
370 #inject ui extra param to log this action via push logger |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
371 for k, v in extras.items(): |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
372 repo._repo.ui.setconfig('rhodecode_extras', k, v) |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
373 |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
374 repo.pull(dbrepo.clone_uri) |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
375 self.mark_for_invalidation(repo_name) |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
376 except: |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
377 log.error(traceback.format_exc()) |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
378 raise |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
379 |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
380 |
1312
70a5a9a57864
logged local commit with special action via action_logger,
Marcin Kuzminski <marcin@python-works.com>
parents:
1311
diff
changeset
|
381 def commit_change(self, repo, repo_name, cs, user, author, message, content, |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
382 f_path): |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
383 |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
384 if repo.alias == 'hg': |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
385 from vcs.backends.hg import MercurialInMemoryChangeset as IMC |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
386 elif repo.alias == 'git': |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
387 from vcs.backends.git import GitInMemoryChangeset as IMC |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
388 |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
389 # decoding here will force that we have proper encoded values |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
390 # in any other case this will throw exceptions and deny commit |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
391 content = content.encode('utf8') |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
392 message = message.encode('utf8') |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
393 path = f_path.encode('utf8') |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
394 author = author.encode('utf8') |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
395 m = IMC(repo) |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
396 m.change(FileNode(path, content)) |
1312
70a5a9a57864
logged local commit with special action via action_logger,
Marcin Kuzminski <marcin@python-works.com>
parents:
1311
diff
changeset
|
397 tip = m.commit(message=message, |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
398 author=author, |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
399 parents=[cs], branch=cs.branch) |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
400 |
1312
70a5a9a57864
logged local commit with special action via action_logger,
Marcin Kuzminski <marcin@python-works.com>
parents:
1311
diff
changeset
|
401 new_cs = tip.short_id |
70a5a9a57864
logged local commit with special action via action_logger,
Marcin Kuzminski <marcin@python-works.com>
parents:
1311
diff
changeset
|
402 action = 'push_local:%s' % new_cs |
70a5a9a57864
logged local commit with special action via action_logger,
Marcin Kuzminski <marcin@python-works.com>
parents:
1311
diff
changeset
|
403 |
70a5a9a57864
logged local commit with special action via action_logger,
Marcin Kuzminski <marcin@python-works.com>
parents:
1311
diff
changeset
|
404 action_logger(user, action, repo_name) |
70a5a9a57864
logged local commit with special action via action_logger,
Marcin Kuzminski <marcin@python-works.com>
parents:
1311
diff
changeset
|
405 |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
406 self.mark_for_invalidation(repo_name) |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
407 |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
408 |
784
30d3161c6683
Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
767
diff
changeset
|
409 def get_unread_journal(self): |
30d3161c6683
Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
767
diff
changeset
|
410 return self.sa.query(UserLog).count() |
30d3161c6683
Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
767
diff
changeset
|
411 |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
412 def _should_invalidate(self, repo_name): |
811 | 413 """Looks up database for invalidation signals for this repo_name |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
414 |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
415 :param repo_name: |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
416 """ |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
417 |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
418 ret = self.sa.query(CacheInvalidation)\ |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
419 .filter(CacheInvalidation.cache_key == repo_name)\ |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
420 .filter(CacheInvalidation.cache_active == False)\ |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
421 .scalar() |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
422 |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
423 return ret |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
424 |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
425 def _mark_invalidated(self, cache_key): |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
426 """ Marks all occurrences of cache to invalidation as already |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
427 invalidated |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
428 |
811 | 429 :param cache_key: |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
430 """ |
811 | 431 |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
432 if cache_key: |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
433 log.debug('marking %s as already invalidated', cache_key) |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
434 try: |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
435 cache_key.cache_active = True |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
436 self.sa.add(cache_key) |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
437 self.sa.commit() |
758 | 438 except (DatabaseError,): |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
439 log.error(traceback.format_exc()) |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
440 self.sa.rollback() |