Mercurial > kallithea
comparison rhodecode/model/scm.py @ 1716:7d1fc253549e beta
notification to commit author + gardening
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 23 Nov 2011 22:46:14 +0200 |
parents | e886f91fcb71 |
children | e7eef7a1db6a |
comparison
equal
deleted
inserted
replaced
1715:e1e482093077 | 1716:7d1fc253549e |
---|---|
25 import os | 25 import os |
26 import time | 26 import time |
27 import traceback | 27 import traceback |
28 import logging | 28 import logging |
29 | 29 |
30 from sqlalchemy.exc import DatabaseError | |
31 | |
32 from vcs import get_backend | 30 from vcs import get_backend |
33 from vcs.exceptions import RepositoryError | 31 from vcs.exceptions import RepositoryError |
34 from vcs.utils.lazy import LazyProperty | 32 from vcs.utils.lazy import LazyProperty |
35 from vcs.nodes import FileNode | 33 from vcs.nodes import FileNode |
36 | 34 |
117 tmp_d['dbrepo_fork'] = dbr.fork.get_dict() if dbr.fork \ | 115 tmp_d['dbrepo_fork'] = dbr.fork.get_dict() if dbr.fork \ |
118 else {} | 116 else {} |
119 yield tmp_d | 117 yield tmp_d |
120 | 118 |
121 class ScmModel(BaseModel): | 119 class ScmModel(BaseModel): |
122 """Generic Scm Model | 120 """ |
121 Generic Scm Model | |
123 """ | 122 """ |
124 | 123 |
125 @LazyProperty | 124 @LazyProperty |
126 def repos_path(self): | 125 def repos_path(self): |
127 """Get's the repositories root path from database | 126 """ |
127 Get's the repositories root path from database | |
128 """ | 128 """ |
129 | 129 |
130 q = self.sa.query(RhodeCodeUi).filter(RhodeCodeUi.ui_key == '/').one() | 130 q = self.sa.query(RhodeCodeUi).filter(RhodeCodeUi.ui_key == '/').one() |
131 | 131 |
132 return q.ui_value | 132 return q.ui_value |
133 | 133 |
134 def repo_scan(self, repos_path=None): | 134 def repo_scan(self, repos_path=None): |
135 """Listing of repositories in given path. This path should not be a | 135 """ |
136 Listing of repositories in given path. This path should not be a | |
136 repository itself. Return a dictionary of repository objects | 137 repository itself. Return a dictionary of repository objects |
137 | 138 |
138 :param repos_path: path to directory containing repositories | 139 :param repos_path: path to directory containing repositories |
139 """ | 140 """ |
140 | 141 |
145 | 146 |
146 baseui = make_ui('db') | 147 baseui = make_ui('db') |
147 repos_list = {} | 148 repos_list = {} |
148 | 149 |
149 for name, path in get_filesystem_repos(repos_path, recursive=True): | 150 for name, path in get_filesystem_repos(repos_path, recursive=True): |
150 | 151 |
151 # name need to be decomposed and put back together using the / | 152 # name need to be decomposed and put back together using the / |
152 # since this is internal storage separator for rhodecode | 153 # since this is internal storage separator for rhodecode |
153 name = Repository.url_sep().join(name.split(os.sep)) | 154 name = Repository.url_sep().join(name.split(os.sep)) |
154 | 155 |
155 try: | 156 try: |
156 if name in repos_list: | 157 if name in repos_list: |
157 raise RepositoryError('Duplicate repository name %s ' | 158 raise RepositoryError('Duplicate repository name %s ' |
158 'found in %s' % (name, path)) | 159 'found in %s' % (name, path)) |
159 else: | 160 else: |
196 further global cache invalidation | 197 further global cache invalidation |
197 | 198 |
198 :param repo_name: this repo that should invalidation take place | 199 :param repo_name: this repo that should invalidation take place |
199 """ | 200 """ |
200 CacheInvalidation.set_invalidate(repo_name) | 201 CacheInvalidation.set_invalidate(repo_name) |
201 CacheInvalidation.set_invalidate(repo_name+"_README") | 202 CacheInvalidation.set_invalidate(repo_name + "_README") |
202 | 203 |
203 def toggle_following_repo(self, follow_repo_id, user_id): | 204 def toggle_following_repo(self, follow_repo_id, user_id): |
204 | 205 |
205 f = self.sa.query(UserFollowing)\ | 206 f = self.sa.query(UserFollowing)\ |
206 .filter(UserFollowing.follows_repo_id == follow_repo_id)\ | 207 .filter(UserFollowing.follows_repo_id == follow_repo_id)\ |