##// END OF EJS Templates
diff_block: fix link to file revisions...
diff_block: fix link to file revisions Pull requests would link to file revisions in the wrong repo. That was obviously only visible when merging between different repos - but then it would link to a non-existing revision. diff_block is apparently used pull-request-style with the 'b' revision of the diff shown first. It thus also has to point at the 'other' repo which is where the other revision can be found.

File last commit:

r1203:6832ef66 beta
r3517:f8daaaf1 beta
Show More
base.py
57 lines | 1.7 KiB | text/x-python | PythonLexer
added dbmigrate package, added model changes...
r833 #!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
fixed imports on migrate, added getting current version from database
r835 from rhodecode.lib.dbmigrate.migrate import exceptions
from rhodecode.lib.dbmigrate.migrate.versioning.config import operations
from rhodecode.lib.dbmigrate.migrate.versioning import pathed
added dbmigrate package, added model changes...
r833
log = logging.getLogger(__name__)
class BaseScript(pathed.Pathed):
"""Base class for other types of scripts.
All scripts have the following properties:
source (script.source())
The source code of the script
version (script.version())
The version number of the script
operations (script.operations())
The operations defined by the script: upgrade(), downgrade() or both.
Returns a tuple of operations.
Can also check for an operation with ex. script.operation(Script.ops.up)
""" # TODO: sphinxfy this and implement it correctly
def __init__(self, path):
log.debug('Loading script %s...' % path)
self.verify(path)
super(BaseScript, self).__init__(path)
log.debug('Script %s loaded successfully' % path)
source code cleanup: remove trailing white space, normalize file endings
r1203
added dbmigrate package, added model changes...
r833 @classmethod
def verify(cls, path):
"""Ensure this is a valid script
This version simply ensures the script file's existence
:raises: :exc:`InvalidScriptError <migrate.exceptions.InvalidScriptError>`
"""
try:
cls.require_found(path)
except:
raise exceptions.InvalidScriptError(path)
def source(self):
""":returns: source code of the script.
:rtype: string
"""
fd = open(self.path)
ret = fd.read()
fd.close()
return ret
def run(self, engine):
"""Core of each BaseScript subclass.
This method executes the script.
"""
raise NotImplementedError()