comparison rhodecode/lib/dbmigrate/schema/db_1_5_2.py @ 3708:c15d7b336af5 rhodecode-0.0.1.6.0rc1

freeze schema for 1.6 + fixed migration from version 1.4.X+
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 07 Apr 2013 23:51:53 +0200
parents fa6ba6727475
children 9345065b03c0
comparison
equal deleted inserted replaced
3704:45177757b322 3708:c15d7b336af5
42 42
43 from rhodecode.lib.vcs import get_backend 43 from rhodecode.lib.vcs import get_backend
44 from rhodecode.lib.vcs.utils.helpers import get_scm 44 from rhodecode.lib.vcs.utils.helpers import get_scm
45 from rhodecode.lib.vcs.exceptions import VCSError 45 from rhodecode.lib.vcs.exceptions import VCSError
46 from rhodecode.lib.vcs.utils.lazy import LazyProperty 46 from rhodecode.lib.vcs.utils.lazy import LazyProperty
47 from rhodecode.lib.vcs.backends.base import EmptyChangeset
47 48
48 from rhodecode.lib.utils2 import str2bool, safe_str, get_changeset_safe, \ 49 from rhodecode.lib.utils2 import str2bool, safe_str, get_changeset_safe, \
49 safe_unicode, remove_suffix, remove_prefix 50 safe_unicode, remove_suffix, remove_prefix
50 from rhodecode.lib.compat import json 51 from rhodecode.lib.compat import json
51 from rhodecode.lib.caching_query import FromCache 52 from rhodecode.lib.caching_query import FromCache
977 978
978 :param cs_cache: 979 :param cs_cache:
979 """ 980 """
980 from rhodecode.lib.vcs.backends.base import BaseChangeset 981 from rhodecode.lib.vcs.backends.base import BaseChangeset
981 if cs_cache is None: 982 if cs_cache is None:
982 cs_cache = self.get_changeset() 983 cs_cache = EmptyChangeset()
984 # use no-cache version here
985 scm_repo = self.scm_instance_no_cache()
986 if scm_repo:
987 cs_cache = scm_repo.get_changeset()
988
983 if isinstance(cs_cache, BaseChangeset): 989 if isinstance(cs_cache, BaseChangeset):
984 cs_cache = cs_cache.__json__() 990 cs_cache = cs_cache.__json__()
985 991
986 if cs_cache != self.changeset_cache: 992 if (cs_cache != self.changeset_cache or not self.changeset_cache):
987 last_change = cs_cache.get('date') or self.last_change 993 _default = datetime.datetime.fromtimestamp(0)
988 log.debug('updated repo %s with new cs cache %s' % (self, cs_cache)) 994 last_change = cs_cache.get('date') or _default
995 log.debug('updated repo %s with new cs cache %s'
996 % (self.repo_name, cs_cache))
989 self.updated_on = last_change 997 self.updated_on = last_change
990 self.changeset_cache = cs_cache 998 self.changeset_cache = cs_cache
991 Session().add(self) 999 Session().add(self)
992 Session().commit() 1000 Session().commit()
1001 else:
1002 log.debug('Skipping repo:%s already with latest changes'
1003 % self.repo_name)
993 1004
994 @property 1005 @property
995 def tip(self): 1006 def tip(self):
996 return self.get_changeset('tip') 1007 return self.get_changeset('tip')
997 1008
1062 def set_invalidate(self): 1073 def set_invalidate(self):
1063 """ 1074 """
1064 set a cache for invalidation for this instance 1075 set a cache for invalidation for this instance
1065 """ 1076 """
1066 CacheInvalidation.set_invalidate(repo_name=self.repo_name) 1077 CacheInvalidation.set_invalidate(repo_name=self.repo_name)
1078
1079 def scm_instance_no_cache(self):
1080 return self.__get_instance()
1067 1081
1068 @LazyProperty 1082 @LazyProperty
1069 def scm_instance(self): 1083 def scm_instance(self):
1070 import rhodecode 1084 import rhodecode
1071 full_cache = str2bool(rhodecode.CONFIG.get('vcs_full_cache')) 1085 full_cache = str2bool(rhodecode.CONFIG.get('vcs_full_cache'))