##// END OF EJS Templates
pull request: use unionrepo instead of outgoing...
pull request: use unionrepo instead of outgoing This makes it possible to look the 'moving target' symbols up in the right repo. Using a revset with the right revisions also removes the need for pruning changesets that are outside the requested range. It will also not be confused by changesets that for some reason has been pulled to the repo but haven't been merged yet. They are going to be 'merged' by the 'pull' request and should thus be a part of what is reviewed.

File last commit:

r1203:6832ef66 beta
r3303:ae5ac36c beta
Show More
sql.py
49 lines | 1.7 KiB | text/x-python | PythonLexer
added dbmigrate package, added model changes...
r833 #!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import shutil
fixed imports on migrate, added getting current version from database
r835 from rhodecode.lib.dbmigrate.migrate.versioning.script import base
from rhodecode.lib.dbmigrate.migrate.versioning.template import Template
added dbmigrate package, added model changes...
r833
log = logging.getLogger(__name__)
class SqlScript(base.BaseScript):
"""A file containing plain SQL statements."""
@classmethod
def create(cls, path, **opts):
"""Create an empty migration script at specified path
source code cleanup: remove trailing white space, normalize file endings
r1203
added dbmigrate package, added model changes...
r833 :returns: :class:`SqlScript instance <migrate.versioning.script.sql.SqlScript>`"""
cls.require_notfound(path)
updated sqlalchemy migrate to latest version
r1061
added dbmigrate package, added model changes...
r833 src = Template(opts.pop('templates_path', None)).get_sql_script(theme=opts.pop('templates_theme', None))
shutil.copy(src, path)
return cls(path)
# TODO: why is step parameter even here?
def run(self, engine, step=None, executemany=True):
"""Runs SQL script through raw dbapi execute call"""
text = self.source()
# Don't rely on SA's autocommit here
# (SA uses .startswith to check if a commit is needed. What if script
# starts with a comment?)
conn = engine.connect()
try:
trans = conn.begin()
try:
# HACK: SQLite doesn't allow multiple statements through
# its execute() method, but it provides executescript() instead
dbapi = conn.engine.raw_connection()
if executemany and getattr(dbapi, 'executescript', None):
dbapi.executescript(text)
else:
conn.execute(text)
trans.commit()
except:
trans.rollback()
raise
finally:
conn.close()