##// END OF EJS Templates
diffs: use whole chunk diff to calculate if it's oversized or not....
diffs: use whole chunk diff to calculate if it's oversized or not. - This fixes an issue if a file is added that has very large number of small lines. In this case the time to detect if the diff should be limited was very very long and CPU intensive.

File last commit:

r1545:e40bd0a7 default
r2070:7939c6bf default
Show More
070_version_4_7_0.py
56 lines | 1.3 KiB | text/x-python | PythonLexer
import logging
import datetime
from sqlalchemy import *
from rhodecode.lib.utils2 import safe_str
from rhodecode.model import meta
from rhodecode.lib.dbmigrate.versions import _reset_base, notify
log = logging.getLogger(__name__)
def time_to_datetime(tm):
if tm:
if isinstance(tm, basestring):
try:
tm = float(tm)
except ValueError:
return
return datetime.datetime.fromtimestamp(tm)
def upgrade(migrate_engine):
"""
Upgrade operations go here.
Don't create your own engine; bind migrate_engine to your metadata
"""
_reset_base(migrate_engine)
from rhodecode.lib.dbmigrate.schema import db_4_7_0_1
# fixups
fixups(db_4_7_0_1, meta.Session)
def downgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
def _migrate_user(db, user):
last_activity = time_to_datetime(user.user_data.get('last_activity', 0))
user.last_activity = last_activity
return user
def fixups(models, _SESSION):
# move the builtin token to external tokens
query = models.User.query().all()
for user in query:
migrated_user = _migrate_user(models, user)
_SESSION.add(migrated_user)
log.info(
"Migrating last_activity of user '%s'.", safe_str(user.username))
_SESSION().commit()