bloodhound-trac / trac / upgrades /

# -*- coding: utf-8 -*-
# Copyright (C) 2012 Edgewall Software
# All rights reserved.
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at

import shutil

from trac.util import create_unique_file
from trac.util.text import exception_to_unicode

_svn_components = [
_old_path = 'trac.versioncontrol.'
_new_path = 'tracopt.versioncontrol.svn.'

def do_upgrade(env, version, cursor):
    """Automatically enable tracopt.versioncontrol.svn.* components,
    unless they were explicitly disabled or the new svn components are
    already enabled.
    enable = [c for c in _svn_components
              if env.is_component_enabled(_old_path + c) and
              not env.is_component_enabled(_new_path + c)]
    if not enable:
        backup, f = create_unique_file(env.config.filename
                                       + '.tracopt-svn.bak')
        shutil.copyfile(env.config.filename, backup)"Saved backup of configuration file in %s", backup)
    except IOError, e:
        env.log.warn("Couldn't save backup of configuration file (%s)",
    for c in enable:
        env.config.set('components', _new_path + c, 'enabled')"Enabled components %r to cope with the move from %s to %s.",
                 _old_path.replace('.', '/'), _new_path.replace('.', '/'))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.