Show More
@@ -153,8 +153,8 b' class ReposController(BaseController):' | |||||
153 | else: |
|
153 | else: | |
154 | last_rev = 0 |
|
154 | last_rev = 0 | |
155 | c.stats_revision = last_rev |
|
155 | c.stats_revision = last_rev | |
156 | r = ScmModel().get(repo_name) |
|
156 | repo, dbrepo = ScmModel().get(repo_name, retval='repo') | |
157 | c.repo_last_rev = r.revisions[-1] if r.revisions else 0 |
|
157 | c.repo_last_rev = repo.revisions[-1] if repo.revisions else 0 | |
158 |
|
158 | |||
159 | if last_rev == 0: |
|
159 | if last_rev == 0: | |
160 | c.stats_percentage = 0 |
|
160 | c.stats_percentage = 0 | |
@@ -282,7 +282,7 b' class ReposController(BaseController):' | |||||
282 | def edit(self, repo_name, format='html'): |
|
282 | def edit(self, repo_name, format='html'): | |
283 | """GET /repos/repo_name/edit: Form to edit an existing item""" |
|
283 | """GET /repos/repo_name/edit: Form to edit an existing item""" | |
284 | # url('edit_repo', repo_name=ID) |
|
284 | # url('edit_repo', repo_name=ID) | |
285 |
r = ScmModel().get(repo_name) |
|
285 | repo, dbrepo = ScmModel().get(repo_name, retval='repo') | |
286 |
|
286 | |||
287 | repo_model = RepoModel() |
|
287 | repo_model = RepoModel() | |
288 | c.repo_info = repo_model.get_by_repo_name(repo_name) |
|
288 | c.repo_info = repo_model.get_by_repo_name(repo_name) | |
@@ -302,7 +302,7 b' class ReposController(BaseController):' | |||||
302 | last_rev = 0 |
|
302 | last_rev = 0 | |
303 | c.stats_revision = last_rev |
|
303 | c.stats_revision = last_rev | |
304 |
|
304 | |||
305 | c.repo_last_rev = r.revisions[-1] if r.revisions else 0 |
|
305 | c.repo_last_rev = repo.revisions[-1] if repo.revisions else 0 | |
306 |
|
306 | |||
307 | if last_rev == 0 or c.repo_last_rev == 0: |
|
307 | if last_rev == 0 or c.repo_last_rev == 0: | |
308 | c.stats_percentage = 0 |
|
308 | c.stats_percentage = 0 |
@@ -105,12 +105,15 b' class SettingsController(BaseController)' | |||||
105 | rm_obsolete = request.POST.get('destroy', False) |
|
105 | rm_obsolete = request.POST.get('destroy', False) | |
106 | log.debug('Rescanning directories with destroy=%s', rm_obsolete) |
|
106 | log.debug('Rescanning directories with destroy=%s', rm_obsolete) | |
107 | initial = ScmModel().repo_scan() |
|
107 | initial = ScmModel().repo_scan() | |
|
108 | log.debug('invalidating all repositories') | |||
108 | for repo_name in initial.keys(): |
|
109 | for repo_name in initial.keys(): | |
109 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
110 | invalidate_cache('get_repo_cached_%s' % repo_name) | |
110 |
|
111 | |||
111 | repo2db_mapper(initial, rm_obsolete) |
|
112 | added, removed = repo2db_mapper(initial, rm_obsolete) | |
112 |
|
113 | |||
113 |
h.flash(_('Repositories successfully |
|
114 | h.flash(_('Repositories successfully' | |
|
115 | ' rescanned added: %s,removed: %s') % (added, removed) | |||
|
116 | , category='success') | |||
114 |
|
117 | |||
115 | if setting_id == 'whoosh': |
|
118 | if setting_id == 'whoosh': | |
116 | repo_location = self.get_hg_ui_settings()['paths_root_path'] |
|
119 | repo_location = self.get_hg_ui_settings()['paths_root_path'] |
@@ -363,12 +363,12 b' def repo2db_mapper(initial_repo_list, re' | |||||
363 | sa = meta.Session() |
|
363 | sa = meta.Session() | |
364 | rm = RepoModel() |
|
364 | rm = RepoModel() | |
365 | user = sa.query(User).filter(User.admin == True).first() |
|
365 | user = sa.query(User).filter(User.admin == True).first() | |
366 |
|
366 | added = [] | ||
367 | for name, repo in initial_repo_list.items(): |
|
367 | for name, repo in initial_repo_list.items(): | |
368 | group = map_groups(name.split('/')) |
|
368 | group = map_groups(name.split('/')) | |
369 | if not rm.get_by_repo_name(name, cache=False): |
|
369 | if not rm.get_by_repo_name(name, cache=False): | |
370 | log.info('repository %s not found creating default', name) |
|
370 | log.info('repository %s not found creating default', name) | |
371 |
|
371 | added.append(name) | ||
372 | form_data = { |
|
372 | form_data = { | |
373 | 'repo_name':name, |
|
373 | 'repo_name':name, | |
374 | 'repo_type':repo.alias, |
|
374 | 'repo_type':repo.alias, | |
@@ -380,13 +380,16 b' def repo2db_mapper(initial_repo_list, re' | |||||
380 | } |
|
380 | } | |
381 | rm.create(form_data, user, just_db=True) |
|
381 | rm.create(form_data, user, just_db=True) | |
382 |
|
382 | |||
|
383 | removed = [] | |||
383 | if remove_obsolete: |
|
384 | if remove_obsolete: | |
384 | #remove from database those repositories that are not in the filesystem |
|
385 | #remove from database those repositories that are not in the filesystem | |
385 | for repo in sa.query(Repository).all(): |
|
386 | for repo in sa.query(Repository).all(): | |
386 | if repo.repo_name not in initial_repo_list.keys(): |
|
387 | if repo.repo_name not in initial_repo_list.keys(): | |
|
388 | removed.append(repo.repo_name) | |||
387 | sa.delete(repo) |
|
389 | sa.delete(repo) | |
388 | sa.commit() |
|
390 | sa.commit() | |
389 |
|
391 | |||
|
392 | return added, removed | |||
390 | class OrderedDict(dict, DictMixin): |
|
393 | class OrderedDict(dict, DictMixin): | |
391 |
|
394 | |||
392 | def __init__(self, *args, **kwds): |
|
395 | def __init__(self, *args, **kwds): |
@@ -114,6 +114,7 b' class User(Base, BaseModel):' | |||||
114 | repositories = relationship('Repository') |
|
114 | repositories = relationship('Repository') | |
115 | user_followers = relationship('UserFollowing', primaryjoin='UserFollowing.follows_user_id==User.user_id', cascade='all') |
|
115 | user_followers = relationship('UserFollowing', primaryjoin='UserFollowing.follows_user_id==User.user_id', cascade='all') | |
116 |
|
116 | |||
|
117 | group_member = relationship('UsersGroupMember', cascade='all') | |||
117 | @property |
|
118 | @property | |
118 | def full_contact(self): |
|
119 | def full_contact(self): | |
119 | return '%s %s <%s>' % (self.name, self.lastname, self.email) |
|
120 | return '%s %s <%s>' % (self.name, self.lastname, self.email) |
@@ -90,7 +90,9 b' class RepoModel(BaseModel):' | |||||
90 | if invalidate and cache: |
|
90 | if invalidate and cache: | |
91 | repo.invalidate() |
|
91 | repo.invalidate() | |
92 |
|
92 | |||
93 |
ret |
|
93 | ret = repo.scalar() | |
|
94 | self.sa.expunge_all() | |||
|
95 | return ret | |||
94 |
|
96 | |||
95 |
|
97 | |||
96 | def get_users_js(self): |
|
98 | def get_users_js(self): |
@@ -217,7 +217,7 b' class ScmModel(BaseModel):' | |||||
217 | invalidate = self._should_invalidate(repo_name) |
|
217 | invalidate = self._should_invalidate(repo_name) | |
218 | if invalidate: |
|
218 | if invalidate: | |
219 | log.info('invalidating cache for repository %s', repo_name) |
|
219 | log.info('invalidating cache for repository %s', repo_name) | |
220 |
|
|
220 | region_invalidate(_get_repo, None, repo_name) | |
221 | self._mark_invalidated(invalidate) |
|
221 | self._mark_invalidated(invalidate) | |
222 | dbinvalidate = True |
|
222 | dbinvalidate = True | |
223 |
|
223 |
General Comments 0
You need to be logged in to leave comments.
Login now