##// END OF EJS Templates
feat(caches): make sure commit-caches propagate to parent repo groups
super-admin -
r5486:a9fbe41d default
parent child Browse files
Show More
@@ -207,7 +207,7 b' def create_repo(form_data, cur_user):'
207 hooks_base.create_repository(created_by=owner.username, **repo.get_dict())
207 hooks_base.create_repository(created_by=owner.username, **repo.get_dict())
208
208
209 # update repo commit caches initially
209 # update repo commit caches initially
210 repo.update_commit_cache()
210 repo.update_commit_cache(recursive=False)
211
211
212 # set new created state
212 # set new created state
213 repo.set_state(Repository.STATE_CREATED)
213 repo.set_state(Repository.STATE_CREATED)
@@ -298,7 +298,7 b' def create_repo_fork(form_data, cur_user'
298 # update repo commit caches initially
298 # update repo commit caches initially
299 config = repo._config
299 config = repo._config
300 config.set('extensions', 'largefiles', '')
300 config.set('extensions', 'largefiles', '')
301 repo.update_commit_cache(config=config)
301 repo.update_commit_cache(config=config, recursive=False)
302
302
303 # set new created state
303 # set new created state
304 repo.set_state(Repository.STATE_CREATED)
304 repo.set_state(Repository.STATE_CREATED)
@@ -390,7 +390,7 b' def sync_last_update_for_objects(*args, '
390 .order_by(Repository.group_id.asc())
390 .order_by(Repository.group_id.asc())
391
391
392 for repo in repos:
392 for repo in repos:
393 repo.update_commit_cache()
393 repo.update_commit_cache(recursive=False)
394
394
395 skip_groups = kwargs.get('skip_groups')
395 skip_groups = kwargs.get('skip_groups')
396 if not skip_groups:
396 if not skip_groups:
@@ -582,7 +582,7 b' def repo2db_mapper(initial_repo_list, re'
582 log.debug('Running update server info')
582 log.debug('Running update server info')
583 git_repo._update_server_info(force=True)
583 git_repo._update_server_info(force=True)
584
584
585 db_repo.update_commit_cache()
585 db_repo.update_commit_cache(recursive=False)
586
586
587 config = db_repo._config
587 config = db_repo._config
588 config.set('extensions', 'largefiles', '')
588 config.set('extensions', 'largefiles', '')
@@ -2571,7 +2571,7 b' class Repository(Base, BaseModel):'
2571 self.update_commit_cache(cs_cache={'raw_id':'0'})
2571 self.update_commit_cache(cs_cache={'raw_id':'0'})
2572 self.update_commit_cache()
2572 self.update_commit_cache()
2573
2573
2574 def update_commit_cache(self, cs_cache=None, config=None):
2574 def update_commit_cache(self, cs_cache=None, config=None, recursive=True):
2575 """
2575 """
2576 Update cache of last commit for repository
2576 Update cache of last commit for repository
2577 cache_keys should be::
2577 cache_keys should be::
@@ -2610,6 +2610,14 b' class Repository(Base, BaseModel):'
2610 if isinstance(cs_cache, BaseCommit):
2610 if isinstance(cs_cache, BaseCommit):
2611 cs_cache = cs_cache.__json__()
2611 cs_cache = cs_cache.__json__()
2612
2612
2613 def maybe_update_recursive(instance, _config, _recursive, _cs_cache, _last_change):
2614 if _recursive:
2615 repo_id = instance.repo_id
2616 _cs_cache['source_repo_id'] = repo_id
2617 for gr in instance.groups_with_parents:
2618 gr.changeset_cache = _cs_cache
2619 gr.updated_on = _last_change
2620
2613 def is_outdated(new_cs_cache):
2621 def is_outdated(new_cs_cache):
2614 if (new_cs_cache['raw_id'] != self.changeset_cache['raw_id'] or
2622 if (new_cs_cache['raw_id'] != self.changeset_cache['raw_id'] or
2615 new_cs_cache['revision'] != self.changeset_cache['revision']):
2623 new_cs_cache['revision'] != self.changeset_cache['revision']):
@@ -2636,6 +2644,7 b' class Repository(Base, BaseModel):'
2636 self.changeset_cache = cs_cache
2644 self.changeset_cache = cs_cache
2637 self.updated_on = last_change
2645 self.updated_on = last_change
2638 Session().add(self)
2646 Session().add(self)
2647 maybe_update_recursive(self, config, recursive, cs_cache, last_change)
2639 Session().commit()
2648 Session().commit()
2640
2649
2641 else:
2650 else:
@@ -2650,6 +2659,7 b' class Repository(Base, BaseModel):'
2650 self.changeset_cache = cs_cache
2659 self.changeset_cache = cs_cache
2651 self.updated_on = _date_latest
2660 self.updated_on = _date_latest
2652 Session().add(self)
2661 Session().add(self)
2662 maybe_update_recursive(self, config, recursive, cs_cache, _date_latest)
2653 Session().commit()
2663 Session().commit()
2654
2664
2655 log.debug('updated repo `%s` with new commit cache %s, and last update_date: %s',
2665 log.debug('updated repo `%s` with new commit cache %s, and last update_date: %s',
General Comments 0
You need to be logged in to leave comments. Login now